|
|
@@ -40,6 +40,7 @@ local MiddleCommonLogic = require("middle.MiddleCommonLogic")
|
|
|
local RoleDBLogic = require("role.RoleDBLogic")
|
|
|
local Log = require("common.Log")
|
|
|
local lua_mongo = _G.lua_mongo
|
|
|
+local RoleDefine = require("role.RoleDefine")
|
|
|
|
|
|
|
|
|
local rankListCache = {}
|
|
|
@@ -47,6 +48,15 @@ local lastGetRankListTime = 0
|
|
|
local LOGTYPE = "ServerCommerceActBattleGround"
|
|
|
|
|
|
|
|
|
+
|
|
|
+local function initData(human)
|
|
|
+ human.db.ServerCommerce.battleGround =
|
|
|
+ {
|
|
|
+ freeChallengeCnt = ServerCommerceActDefine.COMMERCEACT_DAILY_FREECHALLENGETIMES,
|
|
|
+ resetTime = os.time(),
|
|
|
+ }
|
|
|
+end
|
|
|
+
|
|
|
local function writeLog(logStr)
|
|
|
Log.write(Log.LOGID_OSS_COMMON_ACT, logStr)
|
|
|
end
|
|
|
@@ -66,9 +76,10 @@ local function rankReduceMail(mailId, receiverUuid, arg)
|
|
|
end
|
|
|
|
|
|
-- 排行奖励邮件
|
|
|
-local function sendAwardMail(mailId, receiverUuid, itemArray)
|
|
|
+local function sendAwardMail(mailId, receiverUuid, rank, itemArray)
|
|
|
local mailCfg = MailExcel.mail[mailId]
|
|
|
local content = mailCfg.content
|
|
|
+ content = Util.format(content, rank or ServerCommerceActDefine.COMMERCEACT_NPC_CNT)
|
|
|
MailManager.add(MailManager.SYSTEM, receiverUuid, mailCfg.title, content, itemArray, mailCfg.senderName or "GM")
|
|
|
end
|
|
|
|
|
|
@@ -92,10 +103,9 @@ local function createRewardQueue()
|
|
|
for i=1, maxNum do
|
|
|
local resTag = ServerCommerceActDefine.BG_MAIL_SUCC_TAG
|
|
|
local playerInfo = table.remove(self.playerArray)
|
|
|
- local rank = playerInfo[1]
|
|
|
local playerUuid = playerInfo[2]
|
|
|
|
|
|
- local ok, err = pcall(sendAwardMail, mailId, playerUuid, playerInfo[3])
|
|
|
+ local ok, err = pcall(sendAwardMail, mailId, playerUuid, playerInfo[1], playerInfo[3])
|
|
|
|
|
|
if not ok then
|
|
|
if not self.repeatTb[playerUuid] or self.repeatTb[playerUuid] < self.repeatMaxTimes then
|
|
|
@@ -211,6 +221,7 @@ local function populateHeroMsg(net, heroInfo, heroConfig, heroLv, heroStar, hero
|
|
|
net.heroId = heroInfo[1] or 0
|
|
|
net.heroUuid = heroInfo[2] or ""
|
|
|
net.heroBagIdx = heroBagIdx or 0
|
|
|
+ net.heroJob = heroConfig.job or 1
|
|
|
end
|
|
|
|
|
|
-- 获取可以解锁的英雄信息
|
|
|
@@ -232,7 +243,7 @@ local function unlockHero(human, unlockHeroInfo, isInit)
|
|
|
|
|
|
if #unlockHeroInfo == 0 then
|
|
|
for heroId, heroCfg in pairs(HeroConfig) do
|
|
|
- if heroCfg.grade >= HeroDefine.HERO_SSR_GRADE and not findVal(heroBagData, heroId) then
|
|
|
+ if heroCfg.grade >= HeroDefine.HERO_SSR_GRADE and heroId > 100000 and not findVal(heroBagData, heroId) then
|
|
|
heroBagData[#heroBagData+1] = genHeroGrid(heroId)
|
|
|
end
|
|
|
end
|
|
|
@@ -241,18 +252,24 @@ local function unlockHero(human, unlockHeroInfo, isInit)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
- local heroList = {}
|
|
|
+ -- local heroList = {}
|
|
|
+ local heroArr = {}
|
|
|
for heroId, heroCfg in pairs(HeroConfig) do
|
|
|
- if heroCfg.grade >= HeroDefine.HERO_SSR_GRADE and not findVal(heroBagData, heroId) then
|
|
|
- heroList[heroId] = heroCfg
|
|
|
+ if heroCfg.grade >= HeroDefine.HERO_SSR_GRADE and heroId > 100000 and not findVal(heroBagData, heroId) then
|
|
|
+ -- heroList[heroId] = heroCfg
|
|
|
+ heroArr[#heroArr+1] = {heroId, heroCfg}
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+ table.shuffle(heroArr)
|
|
|
+
|
|
|
for _, heroCond in ipairs(unlockHeroInfo) do
|
|
|
local campCond = heroCond[1] or 0
|
|
|
local numCond = heroCond[2] or 0
|
|
|
for i=1, numCond do
|
|
|
- for heroId, heroCfg in pairs(heroList) do
|
|
|
+ for _, heroData in ipairs(heroArr) do
|
|
|
+ local heroId = heroData[1]
|
|
|
+ local heroCfg = heroData[2]
|
|
|
if heroCfg.camp == campCond and not findVal(heroBagData, heroId) then
|
|
|
heroBagData[#heroBagData+1] = genHeroGrid(heroId)
|
|
|
break
|
|
|
@@ -270,12 +287,14 @@ end
|
|
|
-- 获取上阵英雄
|
|
|
local function getLineupHeroArr(human)
|
|
|
local heroArr
|
|
|
- local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
- local lineUpData = battleGroundData.lineUpData
|
|
|
- for _, heroId in ipairs(lineUpData.heroList) do
|
|
|
- if heroId and heroId ~= 0 then
|
|
|
- heroArr = heroArr or {}
|
|
|
- heroArr[#heroArr+1] = heroId
|
|
|
+ local heroList = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE37)
|
|
|
+ for _, heroUuid in ipairs(heroList) do
|
|
|
+ if heroUuid and heroUuid ~= "" and heroUuid ~= "0" then
|
|
|
+ local heroGrid = getHeroGridByUuid(human, heroUuid)
|
|
|
+ if heroGrid then
|
|
|
+ heroArr = heroArr or {}
|
|
|
+ heroArr[#heroArr+1] = heroGrid.id
|
|
|
+ end
|
|
|
end
|
|
|
end
|
|
|
return heroArr
|
|
|
@@ -295,6 +314,105 @@ local function populatePlayerShowData(human, showData, rank)
|
|
|
showData.heroArr = getLineupHeroArr(human)
|
|
|
end
|
|
|
|
|
|
+-- 排名没变化, 只刷新匹配列表
|
|
|
+local function rankNoChange(msg)
|
|
|
+ local human = ObjHuman.onlineUuid[msg.playerUuid]
|
|
|
+ if not human then
|
|
|
+ local db = RoleDBLogic.getDb(msg.playerUuid)
|
|
|
+ if not db then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ human = {}
|
|
|
+ human.db = db
|
|
|
+ end
|
|
|
+
|
|
|
+ local newMatchList = matchListAlgorithm(msg.newRank)
|
|
|
+ local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
+ battleGroundData.matchList = newMatchList
|
|
|
+
|
|
|
+ -- 玩家在线
|
|
|
+ if human.fd then
|
|
|
+ -- BattleGround_MatchPage_Query(human)
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 玩家不在线,则保存数据
|
|
|
+ ObjHuman.save(human)
|
|
|
+end
|
|
|
+
|
|
|
+-- 排名提高
|
|
|
+local function rankImprove(msg)
|
|
|
+ local human = ObjHuman.onlineUuid[msg.playerUuid]
|
|
|
+ if not human then
|
|
|
+ local db = RoleDBLogic.getDb(msg.playerUuid)
|
|
|
+ if not db then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ human = {}
|
|
|
+ human.db = db
|
|
|
+ end
|
|
|
+
|
|
|
+ human.battleGroundRank = msg.newRank
|
|
|
+ -- local newMatchList = matchListAlgorithm(human.battleGroundRank)
|
|
|
+
|
|
|
+ -- 更新对手列表
|
|
|
+ local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
+ -- battleGroundData.matchList = newMatchList
|
|
|
+
|
|
|
+ rankNoChange(msg)
|
|
|
+
|
|
|
+ -- 检查是否能解锁新英雄
|
|
|
+ local idx, unlockHeroInfo = getUnlockHeroInfoByRank(human.battleGroundRank)
|
|
|
+ if idx ~= battleGroundData.unLockIdx then
|
|
|
+ unlockHero(human, unlockHeroInfo)
|
|
|
+ battleGroundData.unLockIdx = idx
|
|
|
+ battleGroundData.isHaveNewHero = true
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 玩家在线
|
|
|
+ if human.fd then
|
|
|
+ -- BattleGround_MatchPage_Query(human)
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 玩家不在线,则保存数据
|
|
|
+ ObjHuman.save(human)
|
|
|
+end
|
|
|
+
|
|
|
+-- 排名降低
|
|
|
+local function rankReduce(msg)
|
|
|
+ local human = ObjHuman.onlineUuid[msg.playerUuid]
|
|
|
+ if not human then
|
|
|
+ local db = RoleDBLogic.getDb(msg.playerUuid)
|
|
|
+ if not db then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ human = {}
|
|
|
+ human.db = db
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 更新对手列表
|
|
|
+ local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
+ battleGroundData.matchList = matchListAlgorithm(msg.newRank)
|
|
|
+
|
|
|
+ -- 邮件通知
|
|
|
+ local varCfg = battleGroundConfig.var[1]
|
|
|
+ local arg = {msg.atkeServerId - ServerCommerceActDefine.BG_SERVERID_START, msg.atkName, msg.newRank}
|
|
|
+ rankReduceMail(varCfg.defeatMailId, human.db._id, arg)
|
|
|
+
|
|
|
+ -- 玩家在线
|
|
|
+ if human.fd then
|
|
|
+ human.battleGroundRank = msg.newRank
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 玩家不在线,则保存数据
|
|
|
+ ObjHuman.save(human)
|
|
|
+end
|
|
|
+
|
|
|
-- 战斗结束处理
|
|
|
local function fightEndHanle(human, result)
|
|
|
local msgData = InnerMsg.lw.LW_BATTLEGROUND_CHALLENGE_END
|
|
|
@@ -302,29 +420,22 @@ local function fightEndHanle(human, result)
|
|
|
msgData.playerUuid = human.db._id
|
|
|
msgData.atkRank = human.battleGroundRank
|
|
|
msgData.defRank = human.battleGroundCache.defRank
|
|
|
- msgData.challengeRes = CombatDefine.RESULT_WIN
|
|
|
+ msgData.challengeRes = result
|
|
|
msgData.playerShowData = {}
|
|
|
|
|
|
local varCfg = battleGroundConfig.var[1]
|
|
|
local challengeAward = varCfg.defeatAward
|
|
|
|
|
|
if result == CombatDefine.RESULT_WIN then
|
|
|
- human.battleGroundRank = human.battleGroundCache.defRank
|
|
|
- local newMatchList = matchListAlgorithm(human.battleGroundRank)
|
|
|
-
|
|
|
-- 更新对手列表
|
|
|
- local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
- battleGroundData.matchList = newMatchList
|
|
|
-
|
|
|
- -- 检查是否能解锁新英雄
|
|
|
- local idx, unlockHeroInfo = getUnlockHeroInfoByRank(human.battleGroundRank)
|
|
|
- if idx ~= battleGroundData.unLockIdx then
|
|
|
- unlockHero(human, unlockHeroInfo)
|
|
|
- battleGroundData.unLockIdx = idx
|
|
|
- end
|
|
|
+ -- local newMatchList = matchListAlgorithm(human.battleGroundRank)
|
|
|
+ -- local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
+ -- battleGroundData.matchList = newMatchList
|
|
|
|
|
|
-- 展示数据
|
|
|
- populatePlayerShowData(human, msgData.playerShowData, human.battleGroundCache.defRank)
|
|
|
+ --if human.battleGroundRank <= ServerCommerceActDefine.COMMERCEACT_NPC_CNT then
|
|
|
+ populatePlayerShowData(human, msgData.playerShowData, human.battleGroundCache.defRank)
|
|
|
+ --end
|
|
|
|
|
|
-- 挑战奖励
|
|
|
challengeAward = varCfg.winAward
|
|
|
@@ -345,7 +456,7 @@ end
|
|
|
local function getRankAward(rank)
|
|
|
local itemArr
|
|
|
for i, cfg in ipairs(battleGroundConfig.rankAward) do
|
|
|
- if rank >= cfg.rankArea[1] and rank <= cfg.rankArea[1] then
|
|
|
+ if rank >= cfg.rankArea[1] and rank <= cfg.rankArea[2] then
|
|
|
itemArr = {}
|
|
|
for k, itemInfo in ipairs(cfg.rankAward) do
|
|
|
itemArr[k] = {itemInfo[1], itemInfo[2]}
|
|
|
@@ -364,6 +475,10 @@ function updateDaily(human)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
+ if human.db.ServerCommerce and not human.db.ServerCommerce.battleGround then
|
|
|
+ initData(human)
|
|
|
+ end
|
|
|
+
|
|
|
local battleGroundData = human.db.ServerCommerce and human.db.ServerCommerce.battleGround
|
|
|
if not battleGroundData then
|
|
|
return
|
|
|
@@ -382,23 +497,31 @@ function getHeroGridByUuid(human, heroUuid)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
+ if not human.db.ServerCommerce then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
- if not battleGroundData.heroBag then
|
|
|
+ if not battleGroundData or not battleGroundData.heroBag then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
+ local heroGrid
|
|
|
local heroBagData = battleGroundData.heroBag
|
|
|
- local bagIdx = findVal(heroBagData, heroUuid)
|
|
|
- if bagIdx then
|
|
|
- local heroInfo = heroBagData[bagIdx]
|
|
|
- local heroGrid = {
|
|
|
- id = heroInfo[1],
|
|
|
- bagIndex = bagIdx,
|
|
|
- uuid = heroInfo[2]
|
|
|
- }
|
|
|
|
|
|
- return heroGrid
|
|
|
+ for bagIdx, heroInfo in ipairs(heroBagData) do
|
|
|
+ if heroInfo[2] == heroUuid then
|
|
|
+ heroGrid = {
|
|
|
+ id = heroInfo[1],
|
|
|
+ bagIndex = bagIdx,
|
|
|
+ uuid = heroInfo[2],
|
|
|
+ zhandouli = 0
|
|
|
+ }
|
|
|
+ break
|
|
|
+ end
|
|
|
end
|
|
|
+
|
|
|
+ return heroGrid
|
|
|
end
|
|
|
|
|
|
-- 根据英雄id获取英雄信息
|
|
|
@@ -407,8 +530,12 @@ function getHeroGridByheroId(human, heroId)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
+ if not human.db.ServerCommerce then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
- if not battleGroundData.heroBag then
|
|
|
+ if not battleGroundData or not battleGroundData.heroBag then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
@@ -433,6 +560,29 @@ function isGetHero(human, heroId)
|
|
|
return getHeroGridByheroId(human, heroId)
|
|
|
end
|
|
|
|
|
|
+-- 阵容有更新
|
|
|
+function onUpdatePos(human)
|
|
|
+ BattleGround_Lineup_Update(human)
|
|
|
+end
|
|
|
+
|
|
|
+-- 是否有红点
|
|
|
+function isRed(human)
|
|
|
+ -- 兼容老数据
|
|
|
+ if human.db.ServerCommerce and not human.db.ServerCommerce.battleGround then
|
|
|
+ initData(human)
|
|
|
+ end
|
|
|
+
|
|
|
+ if not human.db.ServerCommerce or not human.db.ServerCommerce.battleGround then
|
|
|
+ return false
|
|
|
+ end
|
|
|
+
|
|
|
+ local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
+ if not battleGroundData.freeChallengeCnt or battleGroundData.freeChallengeCnt <= 0 then
|
|
|
+ return false
|
|
|
+ end
|
|
|
+
|
|
|
+ return true
|
|
|
+end
|
|
|
|
|
|
|
|
|
-- 推送主界面信息
|
|
|
@@ -452,8 +602,8 @@ local function sendRankListData(human)
|
|
|
local msgRet = Msg.gc.GC_SERVEERCOMMERCE_ACT_BATTLEGROUND_RANK_QUERY
|
|
|
msgRet.rankList[0] = 0
|
|
|
msgRet.isEnd = 0
|
|
|
- msgRet.myRankInfo.rank = human.battleGroundRank
|
|
|
- msgRet.myRankInfo.serverId = Config.SVR_INDEX
|
|
|
+ msgRet.myRankInfo.rank = ServerCommerceActDefine.COMMERCEACT_NPC_CNT
|
|
|
+ msgRet.myRankInfo.serverId = Config.SVR_INDEX - ServerCommerceActDefine.BG_SERVERID_START
|
|
|
msgRet.myRankInfo.name = human.db.name
|
|
|
msgRet.myRankInfo.heroHeadId = RoleHeadLogic.getRoleAppearance(human, RoleHeadLogic.HEAD_TYPE_1) or 0
|
|
|
msgRet.myRankInfo.heroHeadFrameId = RoleHeadLogic.getRoleAppearance(human, RoleHeadLogic.HEAD_TYPE_2) or 0
|
|
|
@@ -466,11 +616,15 @@ local function sendRankListData(human)
|
|
|
len = len + 1
|
|
|
msgRet.rankList[0] = len
|
|
|
msgRet.rankList[len].rank = rank
|
|
|
- msgRet.rankList[len].serverId = rankInfo.serverId or 0
|
|
|
+ msgRet.rankList[len].serverId = rankInfo.serverId and (rankInfo.serverId - ServerCommerceActDefine.BG_SERVERID_START) or 1
|
|
|
msgRet.rankList[len].name = rankInfo.name
|
|
|
msgRet.rankList[len].heroHeadId = rankInfo.heroHeadId
|
|
|
msgRet.rankList[len].heroHeadFrameId = rankInfo.heroHeadFrameId
|
|
|
|
|
|
+ if rankInfo.playerUuid == human.db._id then
|
|
|
+ msgRet.myRankInfo.rank = rank
|
|
|
+ end
|
|
|
+
|
|
|
if len >= msgMaxLen then
|
|
|
rankNum = rankNum - len
|
|
|
|
|
|
@@ -496,6 +650,10 @@ function BattleGround_MainPage_Query(human)
|
|
|
return Broadcast.sendErr(human, Lang.ACT_NOT_START)
|
|
|
end
|
|
|
|
|
|
+ if human.db.ServerCommerce and not human.db.ServerCommerce.battleGround then
|
|
|
+ initData(human)
|
|
|
+ end
|
|
|
+
|
|
|
if not human.battleGroundRank then
|
|
|
local msgData = InnerMsg.lw.LW_BATTLEGROUND_PLAYER_RANK_QUERY
|
|
|
msgData.sourceServerId = Config.SVR_INDEX
|
|
|
@@ -529,6 +687,22 @@ function BattleGround_MatchPage_Query(human)
|
|
|
InnerMsg.sendMsg(0, msgData)
|
|
|
end
|
|
|
|
|
|
+-- 刷新匹配对手
|
|
|
+function BattleGround_Update_MatchList(human)
|
|
|
+ if not isRunning() then
|
|
|
+ return Broadcast.sendErr(human, Lang.ACT_NOT_START)
|
|
|
+ end
|
|
|
+
|
|
|
+ if not human.battleGroundRank then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
+ battleGroundData.matchList = matchListAlgorithm(human.battleGroundRank)
|
|
|
+
|
|
|
+ BattleGround_MatchPage_Query(human)
|
|
|
+end
|
|
|
+
|
|
|
-- 匹配对手查询
|
|
|
function BattleGround_Player_Query(human, targetRank)
|
|
|
if not isRunning() then
|
|
|
@@ -557,6 +731,32 @@ function BattleGround_Try_Challenge(human, targetRank)
|
|
|
InnerMsg.sendMsg(0, msgData)
|
|
|
end
|
|
|
|
|
|
+-- 一键扫荡
|
|
|
+function BattleGround_OneClickSweep(human)
|
|
|
+ if not isRunning() then
|
|
|
+ return Broadcast.sendErr(human, Lang.ACT_NOT_START)
|
|
|
+ end
|
|
|
+
|
|
|
+ local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
+ if battleGroundData.freeChallengeCnt <= 0 then
|
|
|
+ return Broadcast.sendErr(human, Lang.BG_FREECNT_NOT_ENOUGH)
|
|
|
+ end
|
|
|
+
|
|
|
+ local winAwardCfg = battleGroundConfig.var[1].winAward
|
|
|
+ local winAwardArr = {}
|
|
|
+
|
|
|
+ for i, itemInfo in ipairs(winAwardCfg) do
|
|
|
+ winAwardArr[i] = { itemInfo[1], itemInfo[2] * battleGroundData.freeChallengeCnt }
|
|
|
+ end
|
|
|
+
|
|
|
+ battleGroundData.freeChallengeCnt = 0
|
|
|
+ BattleGround_MatchPage_Query(human)
|
|
|
+
|
|
|
+ BagLogic.addItemList(human, winAwardArr, LOGTYPE)
|
|
|
+
|
|
|
+ ServerCommerceManager.CommerceAct_SendActInfo(human)
|
|
|
+end
|
|
|
+
|
|
|
-- 英雄背包查询
|
|
|
function BattleGround_HeroBag_Query(human)
|
|
|
if not isRunning() then
|
|
|
@@ -572,6 +772,8 @@ function BattleGround_HeroBag_Query(human)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+ -- battleGroundData.isHaveNewHero = false
|
|
|
+
|
|
|
local msgRet = Msg.gc.GC_SERVEERCOMMERCE_ACT_BATTLEGROUND_HEROBAG_QUERY
|
|
|
msgRet.heroArr[0] = 0
|
|
|
msgRet.isEnd = 0
|
|
|
@@ -601,8 +803,20 @@ function BattleGround_HeroBag_Query(human)
|
|
|
msgRet.isEnd = 1
|
|
|
Msg.send(msgRet, human.fd)
|
|
|
end
|
|
|
+
|
|
|
end
|
|
|
|
|
|
+-- 已经知道获得新英雄了
|
|
|
+function BattleGround_AlreadyKonw_GetNewHero(human)
|
|
|
+ if not isRunning() then
|
|
|
+ return Broadcast.sendErr(human, Lang.ACT_NOT_START)
|
|
|
+ end
|
|
|
+
|
|
|
+ local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
+ battleGroundData.isHaveNewHero = false
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
-- 排行榜查询
|
|
|
function BattleGround_RankList_Query(human)
|
|
|
if not isRunning() then
|
|
|
@@ -610,7 +824,7 @@ function BattleGround_RankList_Query(human)
|
|
|
end
|
|
|
|
|
|
local now = os.time()
|
|
|
- if #rankListCache == 0 or now - lastGetRankListTime >= ServerCommerceActDefine.COMMERCEACT_RANKUPDATE then
|
|
|
+ if #rankListCache == 0 or now - lastGetRankListTime >= ServerCommerceActDefine.BG_COMMERCEACT_RANKUPDATE then
|
|
|
local msgData = InnerMsg.lw.LW_BATTLEGROUND_RANKLIST_QUERY
|
|
|
msgData.sourceServerId = Config.SVR_INDEX
|
|
|
msgData.playerUuid = human.db._id
|
|
|
@@ -646,46 +860,46 @@ end
|
|
|
-- 更新阵容数据
|
|
|
function BattleGround_Lineup_Update(human, msg)
|
|
|
if not isRunning() then
|
|
|
- return Broadcast.sendErr(human, Lang.ACT_NOT_START)
|
|
|
+ return
|
|
|
end
|
|
|
|
|
|
- local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
-
|
|
|
- local formation = msg.formation
|
|
|
- local posList = CombatPosLogic.getPosList(formation)
|
|
|
- local heroList = Util.split(msg.heroList, ",", true)
|
|
|
-
|
|
|
- local reapetTb = {}
|
|
|
- for i = 1, CombatDefine.COMBAT_HERO_CNT do
|
|
|
- local heroId = heroList[i]
|
|
|
- if heroId > 0 then
|
|
|
- -- 英雄Id检测
|
|
|
- if HeroConfig[heroId] then
|
|
|
- return Broadcast.sendErr(human, Lang.FUWEN_HERO_GRID_ERR)
|
|
|
- end
|
|
|
-
|
|
|
- -- 英雄背包检测
|
|
|
- if not battleGroundData.heroBag or not table.find(battleGroundData.heroBag, heroId) then
|
|
|
- return Broadcast.sendErr(human, Lang.FUWEN_HERO_GRID_ERR)
|
|
|
- end
|
|
|
-
|
|
|
- -- 相同英雄检测
|
|
|
- if reapetTb[heroId] then
|
|
|
- return Broadcast.sendErr(human, Lang.HERO_SAME)
|
|
|
- end
|
|
|
-
|
|
|
- -- 位置检测
|
|
|
- if posList[i] == nil and i ~= CombatDefine.COMBAT_HERO_CNT then
|
|
|
- return Broadcast.sendErr(human, Lang.POS_ERROR)
|
|
|
- end
|
|
|
+ -- local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
|
|
|
- reapetTb[heroId] = true
|
|
|
- end
|
|
|
- end
|
|
|
+ -- local formation = msg.formation
|
|
|
+ -- local posList = CombatPosLogic.getPosList(formation)
|
|
|
+ -- local heroList = Util.split(msg.heroList, ",", true)
|
|
|
+
|
|
|
+ -- local reapetTb = {}
|
|
|
+ -- for i = 1, CombatDefine.COMBAT_HERO_CNT do
|
|
|
+ -- local heroId = heroList[i]
|
|
|
+ -- if heroId > 0 then
|
|
|
+ -- -- 英雄Id检测
|
|
|
+ -- if HeroConfig[heroId] then
|
|
|
+ -- return Broadcast.sendErr(human, Lang.FUWEN_HERO_GRID_ERR)
|
|
|
+ -- end
|
|
|
+
|
|
|
+ -- -- 英雄背包检测
|
|
|
+ -- if not battleGroundData.heroBag or not table.find(battleGroundData.heroBag, heroId) then
|
|
|
+ -- return Broadcast.sendErr(human, Lang.FUWEN_HERO_GRID_ERR)
|
|
|
+ -- end
|
|
|
+
|
|
|
+ -- -- 相同英雄检测
|
|
|
+ -- if reapetTb[heroId] then
|
|
|
+ -- return Broadcast.sendErr(human, Lang.HERO_SAME)
|
|
|
+ -- end
|
|
|
+
|
|
|
+ -- -- 位置检测
|
|
|
+ -- if posList[i] == nil and i ~= CombatDefine.COMBAT_HERO_CNT then
|
|
|
+ -- return Broadcast.sendErr(human, Lang.POS_ERROR)
|
|
|
+ -- end
|
|
|
+
|
|
|
+ -- reapetTb[heroId] = true
|
|
|
+ -- end
|
|
|
+ -- end
|
|
|
|
|
|
- battleGroundData.lineUp = battleGroundData.lineUp or {}
|
|
|
- battleGroundData.lineUp.formation = formation
|
|
|
- battleGroundData.lineUp.heroList = heroList
|
|
|
+ -- battleGroundData.lineUp = battleGroundData.lineUp or {}
|
|
|
+ -- battleGroundData.lineUp.formation = formation
|
|
|
+ -- battleGroundData.lineUp.heroList = heroList
|
|
|
|
|
|
-- 通知跨服更新
|
|
|
if human.battleGroundRank and human.battleGroundRank <= ServerCommerceActDefine.COMMERCEACT_NPC_CNT then
|
|
|
@@ -758,7 +972,7 @@ function BG_C2N_PlayerData_Res(msg)
|
|
|
|
|
|
local playerInfo = msg.playerInfo
|
|
|
local msgRet = Msg.gc.GC_SERVEERCOMMERCE_ACT_BATTLEGROUND_PLAYER_QUERY
|
|
|
- msgRet.serverId = playerInfo.serverId or 0
|
|
|
+ msgRet.serverId = playerInfo.serverId and (playerInfo.serverId - ServerCommerceActDefine.BG_SERVERID_START) or 1
|
|
|
msgRet.name = playerInfo.name
|
|
|
msgRet.heroHeadId = playerInfo.heroHeadId
|
|
|
msgRet.heroHeadFrameId = playerInfo.heroHeadFrameId
|
|
|
@@ -830,36 +1044,15 @@ function BG_C2N_Challenge_Res(msg)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
--- 跨服通知玩家排名下降
|
|
|
-function BG_C2N_RankReduce(msg)
|
|
|
- local human = ObjHuman.onlineUuid[msg.playerUuid]
|
|
|
- if not human then
|
|
|
- local db = RoleDBLogic.getDb(msg.playerUuid)
|
|
|
- if not db then
|
|
|
- return
|
|
|
- end
|
|
|
-
|
|
|
- human = {}
|
|
|
- human.db = db
|
|
|
- end
|
|
|
-
|
|
|
- -- 更新对手列表
|
|
|
- local battleGroundData = human.db.ServerCommerce.battleGround
|
|
|
- battleGroundData.matchList = matchListAlgorithm(msg.newRank)
|
|
|
-
|
|
|
- -- 邮件通知
|
|
|
- local varCfg = battleGroundConfig.var[1]
|
|
|
- local arg = {msg.atkeServerId - 810537, msg.atkName, msg.newRank}
|
|
|
- rankReduceMail(varCfg.defeatMailId, human.db.id, arg)
|
|
|
-
|
|
|
- -- 玩家在线
|
|
|
- if human.fd then
|
|
|
- human.battleGroundRank = msg.newRank
|
|
|
- return
|
|
|
+-- 跨服通知玩家排名更新
|
|
|
+function BG_C2N_RankUpdate(msg)
|
|
|
+ if msg.updateType == 1 then -- 排名提高
|
|
|
+ rankImprove(msg)
|
|
|
+ elseif msg.updateType == 0 then -- 排名没变化
|
|
|
+ rankNoChange(msg)
|
|
|
+ else
|
|
|
+ rankReduce(msg)
|
|
|
end
|
|
|
-
|
|
|
- -- 玩家不在线,则保存数据
|
|
|
- ObjHuman.save(human)
|
|
|
end
|
|
|
|
|
|
-- 跨服通知发奖
|
|
|
@@ -875,7 +1068,7 @@ function BG_C2N_PrizeAward(msg)
|
|
|
local itemArr = getRankAward(playerInfo[1])
|
|
|
if itemArr then
|
|
|
playerInfo[3] = itemArr
|
|
|
- issueRewardQueue:add(itemArr)
|
|
|
+ issueRewardQueue:add(playerInfo)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
@@ -902,7 +1095,7 @@ function fight(human, args, combatType)
|
|
|
-- end
|
|
|
|
|
|
local heroList = CombatPosLogic.getCombatHeros(human, combatType)
|
|
|
- if not not next(heroList) then
|
|
|
+ if not next(heroList) then
|
|
|
return Broadcast.sendErr(human, Lang.SEAL_GROUND_COMBAT_HERO_ERR)
|
|
|
end
|
|
|
|
|
|
@@ -916,6 +1109,9 @@ function fight(human, args, combatType)
|
|
|
BagLogic.delItem(human, itemId, itemNum, LOGTYPE)
|
|
|
else
|
|
|
battleGroundData.freeChallengeCnt = battleGroundData.freeChallengeCnt - 1
|
|
|
+ if battleGroundData.freeChallengeCnt <= 0 then
|
|
|
+ ServerCommerceManager.CommerceAct_SendActInfo(human)
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
BattleGround_Try_Challenge(human, targetRank)
|
|
|
@@ -926,7 +1122,6 @@ function getCombatMonsterOutID(human, side, args)
|
|
|
return args[1]
|
|
|
end
|
|
|
|
|
|
-
|
|
|
function getCombatObjList(human, side, args, combatType)
|
|
|
if side == CombatDefine.ATTACK_SIDE and not human then return end
|
|
|
|
|
|
@@ -951,11 +1146,21 @@ function getCombatObjList(human, side, args, combatType)
|
|
|
-- end
|
|
|
|
|
|
local heroList, _, formation = CombatPosLogic.getCombatHeros(human, combatType)
|
|
|
- if not not next(heroList) then
|
|
|
+ if not next(heroList) then
|
|
|
return Broadcast.sendErr(human, Lang.SEAL_GROUND_COMBAT_HERO_ERR)
|
|
|
end
|
|
|
|
|
|
- local fakeHuman = {}
|
|
|
+ local heroLv = ServerCommerceActDefine.COMMERCEACT_HERO_LV
|
|
|
+ local heroStar = ServerCommerceActDefine.COMMERCEACT_HERO_STAR
|
|
|
+
|
|
|
+ local attrsChange = {
|
|
|
+ [RoleDefine.ATK] = 2,
|
|
|
+ [RoleDefine.HP] = 2,
|
|
|
+ [RoleDefine.BAOJI] = 1.7,
|
|
|
+ [RoleDefine.HURT_RATE] = 2,
|
|
|
+ }
|
|
|
+
|
|
|
+ local fakeHuman = { db = {} }
|
|
|
local objList = {}
|
|
|
for i = 1, CombatDefine.COMBAT_HERO_CNT do
|
|
|
local heroUuid = heroList[i]
|
|
|
@@ -964,7 +1169,7 @@ function getCombatObjList(human, side, args, combatType)
|
|
|
if not heroInfo then
|
|
|
return Broadcast.sendErr(human, Lang.SEAL_GROUND_COMBAT_HERO_ERR)
|
|
|
end
|
|
|
- objList[i] = CombatLogic.createHeroObj(fakeHuman, heroInfo.id, ServerCommerceActDefine.COMMERCEACT_HERO_LV, ServerCommerceActDefine.COMMERCEACT_HERO_STAR, i)
|
|
|
+ objList[i] = CombatLogic.createHeroObj(fakeHuman, heroInfo.id, heroLv, heroStar, i, nil, attrsChange)
|
|
|
end
|
|
|
end
|
|
|
|