|
|
@@ -304,6 +304,76 @@ local function populatePlayerShowData(human, showData, rank)
|
|
|
showData.heroArr = getLineupHeroArr(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
|
|
|
+
|
|
|
+ -- 检查是否能解锁新英雄
|
|
|
+ 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 - 810537, 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
|
|
|
@@ -318,22 +388,10 @@ local function fightEndHanle(human, result)
|
|
|
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
|
|
|
-
|
|
|
-- 展示数据
|
|
|
- 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
|
|
|
@@ -459,6 +517,20 @@ function onUpdatePos(human)
|
|
|
BattleGround_Lineup_Update(human)
|
|
|
end
|
|
|
|
|
|
+-- 是否有红点
|
|
|
+function isRed(human)
|
|
|
+ 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
|
|
|
+
|
|
|
|
|
|
-- 推送主界面信息
|
|
|
local function sendMainPageData(human)
|
|
|
@@ -477,7 +549,7 @@ 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.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
|
|
|
@@ -496,6 +568,10 @@ local function sendRankListData(human)
|
|
|
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
|
|
|
|
|
|
@@ -554,6 +630,23 @@ 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
|
|
|
@@ -626,6 +719,8 @@ function BattleGround_HeroBag_Query(human)
|
|
|
msgRet.isEnd = 1
|
|
|
Msg.send(msgRet, human.fd)
|
|
|
end
|
|
|
+
|
|
|
+ battleGroundData.isHaveNewHero = false
|
|
|
end
|
|
|
|
|
|
-- 排行榜查询
|
|
|
@@ -855,36 +950,13 @@ 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)
|
|
|
+ else
|
|
|
+ rankReduce(msg)
|
|
|
end
|
|
|
-
|
|
|
- -- 玩家不在线,则保存数据
|
|
|
- ObjHuman.save(human)
|
|
|
end
|
|
|
|
|
|
-- 跨服通知发奖
|