2020-06-23 18:36:24 +08:00
|
|
|
|
ArenaTopMatchManager = {};
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local this = ArenaTopMatchManager
|
2020-07-17 10:28:02 +08:00
|
|
|
|
this.CurTabIndex = 0
|
2020-07-10 13:38:50 +08:00
|
|
|
|
this.curIsShowDoGuessPopup = false
|
2020-07-22 19:40:23 +08:00
|
|
|
|
local isChange = false
|
2020-07-10 15:16:50 +08:00
|
|
|
|
local stageNameTable = {
|
|
|
|
|
[1] = 32 .. Language[10097],--强
|
|
|
|
|
[2] = 16 .. Language[10097],--强
|
|
|
|
|
[3] = 8 .. Language[10097],--强
|
|
|
|
|
[4] = 4 .. Language[10097],--强
|
|
|
|
|
[5] = Language[10126],
|
|
|
|
|
[8] = 32 .. Language[10097],--强
|
|
|
|
|
[9] = 16 .. Language[10097],--强
|
|
|
|
|
[10] = 8 .. Language[10097],--强
|
|
|
|
|
[11] = 4 .. Language[10097],--强
|
|
|
|
|
[12] = Language[10126],
|
|
|
|
|
}
|
2020-05-09 13:31:21 +08:00
|
|
|
|
function this.Initialize()
|
|
|
|
|
this.baseInfo = {}
|
|
|
|
|
this.myBattleInfo = {}
|
|
|
|
|
this.battleHistoryInfo = {}
|
|
|
|
|
this.myTeamRankInfo = {}
|
|
|
|
|
--- 竞猜数据
|
|
|
|
|
this.isCanBet = false -- 是否可以竞猜
|
|
|
|
|
this.betBattleInfo = {}
|
|
|
|
|
this.betRateInfo = {}
|
|
|
|
|
this.myBetTarget = nil
|
2020-07-22 19:40:23 +08:00
|
|
|
|
this.myBetCoins = 0
|
2020-07-08 20:48:43 +08:00
|
|
|
|
this.process = nil
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.betHistoryInfo = {}
|
|
|
|
|
this.coinNum=0 --竞猜币临时数据
|
|
|
|
|
-- this.isGuessTipView=false--是否打开竞猜提示面板
|
|
|
|
|
|
|
|
|
|
-- 淘汰赛数据
|
|
|
|
|
this.EliminationData_32 = {}
|
|
|
|
|
this.EliminationData_4 = {}
|
|
|
|
|
|
2020-07-03 16:09:15 +08:00
|
|
|
|
--倍率
|
|
|
|
|
this.rate = 1.5
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--奖励数据
|
|
|
|
|
this.rewardData={}
|
|
|
|
|
for k, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.ChampionshipReward)) do
|
|
|
|
|
table.insert(this.rewardData, v)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 拍脸完成,获取一次基础数据,判断是否需要弹出巅峰赛拍脸
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.PatFace.PatFaceSendFinish, function()
|
|
|
|
|
this.RequestTopMatchBaseInfo()
|
|
|
|
|
end)
|
|
|
|
|
-- 赛季结束时获取下一赛季的数据
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnFunctionClose, function(typeId)
|
|
|
|
|
if typeId == FUNCTION_OPEN_TYPE.TOP_MATCH then
|
|
|
|
|
this.RequestTopMatchBaseInfo()
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 判断巅峰战是否激活
|
|
|
|
|
function this.IsTopMatchActive()
|
|
|
|
|
return ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.TOP_MATCH)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 获取时间
|
|
|
|
|
function this.GetTopMatchTime()
|
|
|
|
|
local serData = ActTimeCtrlManager.GetSerDataByTypeId(FUNCTION_OPEN_TYPE.TOP_MATCH)
|
|
|
|
|
if serData then
|
|
|
|
|
return serData.startTime, serData.endTime
|
|
|
|
|
end
|
2020-07-03 16:09:15 +08:00
|
|
|
|
return
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
---=============巅峰战基础信息========================
|
|
|
|
|
|
|
|
|
|
-- 向服务器请求基础信息
|
|
|
|
|
function this.RequestTopMatchBaseInfo(func)
|
|
|
|
|
-- 获取巅峰战信息
|
|
|
|
|
NetManager.GetTopMatchBaseInfo(function(msg)
|
|
|
|
|
if not this.baseInfo then
|
|
|
|
|
this.baseInfo = {}
|
|
|
|
|
end
|
|
|
|
|
this.baseInfo.joinState = msg.joinState
|
|
|
|
|
this.baseInfo.progress = msg.progress
|
|
|
|
|
this.baseInfo.endTime = msg.endTime
|
|
|
|
|
this.baseInfo.myrank = msg.myrank
|
|
|
|
|
this.baseInfo.maxRank = msg.maxRank
|
|
|
|
|
this.baseInfo.myscore = msg.myscore
|
2020-07-08 20:48:43 +08:00
|
|
|
|
this.baseInfo.process = msg.process--2 胜 3 负 4 胜负 5 负胜
|
2020-07-10 13:38:50 +08:00
|
|
|
|
this.baseInfo.loser = msg.loser--是否被淘汰
|
2020-07-08 15:02:16 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.myBattleInfo = msg.championBattleInfo
|
2020-07-22 19:40:23 +08:00
|
|
|
|
isChange = false
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.RefreshBaseInfo()
|
|
|
|
|
-- 发送更新事件
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.TopMatch.OnTopMatchDataUpdate)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(string.format(Language[10108], msg.joinState, msg.progress, msg.endTime, msg.myrank))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if func then func() end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 阶段信息刷新
|
|
|
|
|
function this.UpdateTopMatchStage(msg)
|
|
|
|
|
-- 没有数据或者未开启时重新获取数据
|
|
|
|
|
if not this.baseInfo or not this.baseInfo.progress or this.baseInfo.progress <= 0 then
|
|
|
|
|
this.RequestTopMatchBaseInfo()
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取新的阶段信息
|
|
|
|
|
this.baseInfo.progress = msg.progress
|
|
|
|
|
this.baseInfo.endTime = msg.endTime
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(string.format(Language[10109],
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.baseInfo.joinState, this.baseInfo.progress, this.baseInfo.endTime, this.baseInfo.myrank))
|
2020-07-15 18:23:40 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 刷新基础信息
|
|
|
|
|
this.RefreshBaseInfo()
|
2020-08-05 21:28:16 +08:00
|
|
|
|
-- Game.GlobalEvent:DispatchEvent(GameEvent.TopMatch.OnTopMatchDataUpdate)
|
|
|
|
|
-- --刷新排行信息
|
|
|
|
|
-- Game.GlobalEvent:DispatchEvent(GameEvent.ATM_RankView.OnRankChange)
|
2020-07-03 16:09:15 +08:00
|
|
|
|
LogGreen("this.baseInfo.battleState "..this.baseInfo.battleState)
|
2020-07-15 18:23:40 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 切换到准备阶段刷新一遍数据
|
2020-07-15 18:23:40 +08:00
|
|
|
|
-- if this.baseInfo.battleState == TOP_MATCH_TIME_STATE.OPEN_IN_READY then
|
|
|
|
|
-- this.RequestTopMatchBaseInfo()
|
|
|
|
|
-- --this.RequestBetBaseInfo()
|
|
|
|
|
-- -- 竞猜阶段刷新竞猜数据
|
|
|
|
|
-- else
|
|
|
|
|
if this.baseInfo.battleState == TOP_MATCH_TIME_STATE.OPEN_IN_GUESS then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.RequestTopMatchBaseInfo()
|
|
|
|
|
this.RequestBetBaseInfo()
|
2020-07-03 16:09:15 +08:00
|
|
|
|
-- 战斗阶段不刷新
|
|
|
|
|
--elseif this.baseInfo.battleState == TOP_MATCH_TIME_STATE.OPEN_IN_GUESS then
|
|
|
|
|
-- 切换到结算阶段刷新一遍所有数据
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif this.baseInfo.battleState == TOP_MATCH_TIME_STATE.OPEN_IN_END then
|
|
|
|
|
this.RequestTopMatchBaseInfo()
|
2020-07-03 16:09:15 +08:00
|
|
|
|
this.RequestBetBaseInfo(nil,true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-08-05 21:28:16 +08:00
|
|
|
|
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.TopMatch.OnTopMatchDataUpdate)
|
|
|
|
|
--刷新排行信息
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.ATM_RankView.OnRankChange)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取战斗记录
|
|
|
|
|
function this.RequestBattleHistory(func)
|
|
|
|
|
-- 获取巅峰赛战斗记录
|
|
|
|
|
NetManager.GetTopMatchHistoryBattle(function(msg)
|
|
|
|
|
this.battleHistoryInfo = msg.enemyPairInfo
|
|
|
|
|
-- 对历史记录排序
|
|
|
|
|
table.sort(this.battleHistoryInfo, function(a, b)
|
|
|
|
|
return a.roundTimes > b.roundTimes
|
|
|
|
|
end)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[10110]..#this.battleHistoryInfo)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if func then func() end
|
|
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取选拔赛小组排名数据
|
|
|
|
|
function this.RequestMyTeamRank(func)
|
|
|
|
|
--
|
|
|
|
|
NetManager.GetTopMatchMyTeamRank(function(msg)
|
|
|
|
|
this.myTeamRankInfo = msg.rankInfos
|
|
|
|
|
-- 对历史记录排序
|
|
|
|
|
table.sort(this.myTeamRankInfo, function(a, b)
|
|
|
|
|
return a.personInfo.rank < b.personInfo.rank
|
|
|
|
|
end)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[10111]..#this.myTeamRankInfo)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if func then func() end
|
|
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 刷新基础信息
|
|
|
|
|
function this.RefreshBaseInfo()
|
|
|
|
|
if this.baseInfo.progress == -1 then -- 未开始
|
|
|
|
|
this.baseInfo.battleStage = TOP_MATCH_STAGE.CLOSE
|
|
|
|
|
this.baseInfo.battleTurn = -1
|
|
|
|
|
this.baseInfo.battleState = TOP_MATCH_TIME_STATE.CLOSE
|
|
|
|
|
|
|
|
|
|
elseif this.baseInfo.progress == -2 then -- 已结束
|
|
|
|
|
this.baseInfo.battleStage = TOP_MATCH_STAGE.OVER
|
|
|
|
|
this.baseInfo.battleTurn = -2
|
|
|
|
|
this.baseInfo.battleState = TOP_MATCH_TIME_STATE.OVER
|
|
|
|
|
|
|
|
|
|
elseif this.baseInfo.progress > 0 then
|
|
|
|
|
local oldState = this.baseInfo.battleState
|
|
|
|
|
this.baseInfo.battleStage = tonumber(string.sub(this.baseInfo.progress, 1, 1))
|
|
|
|
|
this.baseInfo.battleTurn = tonumber(string.sub(this.baseInfo.progress, 2, 2))
|
|
|
|
|
this.baseInfo.battleState = tonumber(string.sub(this.baseInfo.progress, 3, 3))
|
2020-07-10 13:38:50 +08:00
|
|
|
|
LogPink("this.baseInfo.battleStage "..this.baseInfo.battleStage.." "..this.baseInfo.progress)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
-- 判断阶段切换,并检测是否需要弹窗提示
|
|
|
|
|
if UIManager.IsOpen(UIName.ArenaTopMatchPanel) then return end
|
|
|
|
|
if not this.IsTopMatchActive() then return end
|
|
|
|
|
if oldState ~= this.baseInfo.battleState then
|
|
|
|
|
if this.baseInfo.battleState == TOP_MATCH_TIME_STATE.OPEN_IN_READY and this.baseInfo.joinState == 1 then
|
|
|
|
|
--检测拍脸
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[10112])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSend,FacePanelType.Championship)
|
|
|
|
|
elseif this.baseInfo.battleState == TOP_MATCH_TIME_STATE.OPEN_IN_GUESS then
|
|
|
|
|
--检测拍脸
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[10113])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSend,FacePanelType.Championship)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 获取巅峰战基础信息
|
|
|
|
|
function this.GetBaseData()
|
2020-07-17 10:28:02 +08:00
|
|
|
|
this.ChangeData(this.CurTabIndex)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return this.baseInfo
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取对战信息
|
|
|
|
|
function this.GetBattleInfo()
|
2020-07-17 10:28:02 +08:00
|
|
|
|
this.ChangeData(this.CurTabIndex)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return this.myBattleInfo
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取历史战斗记录
|
|
|
|
|
function this.GetBattleHistory()
|
|
|
|
|
return this.battleHistoryInfo
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取小组赛排名
|
|
|
|
|
function this.GetMyTeamRankInfo()
|
|
|
|
|
return this.myTeamRankInfo
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- =================== end ==========================
|
|
|
|
|
|
|
|
|
|
--- ====================竞猜相关=======================
|
2020-07-03 16:09:15 +08:00
|
|
|
|
--- 获取竞猜基础数据 isPlayBattle 是否自动播放战斗
|
|
|
|
|
function this.RequestBetBaseInfo(func,isPlayBattle)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 未开启
|
|
|
|
|
if not this.IsTopMatchActive() then
|
2020-07-03 16:09:15 +08:00
|
|
|
|
LogGreen("this.isCanBet = false ")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.isCanBet = false
|
|
|
|
|
if func then func() end
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
-- 获取巅峰战信息
|
|
|
|
|
NetManager.GetBetMatchInfo(0, function(msg)
|
|
|
|
|
this.betBattleInfo = msg.championBattleInfo
|
2020-07-22 19:40:23 +08:00
|
|
|
|
isChange = false
|
2020-07-10 13:38:50 +08:00
|
|
|
|
LogGreen("竞猜双方uid "..msg.championBattleInfo.myInfo.uid.." "..msg.championBattleInfo.enemyInfo.uid)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.betRateInfo = msg.championBetInfo
|
|
|
|
|
this.myBetTarget = msg.winUid
|
2020-07-22 19:40:23 +08:00
|
|
|
|
this.myBetCoins = msg.myBetCoins
|
2020-07-10 13:38:50 +08:00
|
|
|
|
LogGreen("this.myBetTarget = msg.winUid "..this.myBetTarget.." "..msg.winUid)
|
2020-07-08 20:48:43 +08:00
|
|
|
|
this.process = msg.process
|
2020-07-10 13:38:50 +08:00
|
|
|
|
LogGreen("竞猜msg.process "..msg.process)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(string.format(Language[10114], msg.winUid, msg.championBetInfo.id, msg.championBetInfo.redCoins, msg.championBetInfo.blueCoins))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 可以竞猜了
|
|
|
|
|
this.isCanBet = true
|
2020-07-23 21:18:46 +08:00
|
|
|
|
LogGreen("this.isCanBet = true ")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.TopMatch.OnGuessDataUpdate)
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.TopMatch.OnGuessRateUpdate)
|
2020-07-03 16:09:15 +08:00
|
|
|
|
LogGreen("this.baseInfo.battleState "..this.baseInfo.battleState)
|
|
|
|
|
if this.baseInfo.battleState == TOP_MATCH_TIME_STATE.OPEN_IN_END and isPlayBattle then
|
|
|
|
|
LogGreen("this.baseInfo.battleState "..this.baseInfo.battleState)
|
2020-07-22 19:40:23 +08:00
|
|
|
|
--当历史战斗记录以决出胜负 说明此时是第三场 不需要自动播放战斗动画
|
|
|
|
|
if not ArenaTopMatchManager.GetIsBattleEndState(this.CurTabIndex) then
|
|
|
|
|
--推送信息的not时候判断是否需要播放动画
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.ATM_RankView.OnOpenBattle)
|
|
|
|
|
end
|
2020-07-03 16:09:15 +08:00
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if func then func() end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 刷新赔率信息
|
|
|
|
|
function this.RequestBetRateInfo(func)
|
|
|
|
|
-- 未开启
|
|
|
|
|
if not this.IsTopMatchActive() then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
-- 不在竞猜阶段不刷新
|
|
|
|
|
if this.baseInfo.battleState ~= TOP_MATCH_TIME_STATE.OPEN_IN_GUESS then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
-- 积分赛不设置竞猜环节 32强才显示
|
|
|
|
|
if this.baseInfo.battleStage~=TOP_MATCH_STAGE.ELIMINATION then return end
|
|
|
|
|
-- 获取巅峰战信息
|
|
|
|
|
NetManager.GetBetMatchInfo(1, function(msg)
|
|
|
|
|
this.betRateInfo = msg.championBetInfo
|
2020-07-03 16:09:15 +08:00
|
|
|
|
--Log(string.format(Language[10115], msg.championBetInfo.id, msg.championBetInfo.redCoins, msg.championBetInfo.blueCoins))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.TopMatch.OnGuessRateUpdate)
|
|
|
|
|
if func then func() end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 请求下注
|
|
|
|
|
function this.RequestBet(uid, coins, func)
|
|
|
|
|
-- 未开启
|
|
|
|
|
if not this.IsTopMatchActive() then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
-- 第一个准备阶段无竞猜信息
|
|
|
|
|
if this.baseInfo.battleState ~= TOP_MATCH_TIME_STATE.OPEN_IN_GUESS then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10116])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
-- 判断竞猜币是否足够
|
|
|
|
|
if coins == 0 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10117])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
local guessCoinId = ArenaTopMatchManager.GetGuessCoinID()
|
|
|
|
|
local haveNum = BagManager.GetItemCountById(guessCoinId)
|
|
|
|
|
if coins > haveNum then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10118])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
-- 判断是否已经参与过竞猜
|
|
|
|
|
if this.myBetTarget and this.myBetTarget ~= 0 then
|
|
|
|
|
-- 已经参与过竞猜
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10119])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
-- 获取巅峰战信息
|
|
|
|
|
NetManager.RequestBet(uid, coins, function()
|
|
|
|
|
-- 保存下注对象
|
|
|
|
|
this.myBetTarget = uid
|
|
|
|
|
-- 刷新
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.TopMatch.OnGuessDataUpdate)
|
|
|
|
|
if func then func() end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取历史竞猜信息
|
|
|
|
|
function this.RequestBetHistory(func)
|
|
|
|
|
|
|
|
|
|
-- 获取我得竞猜信息
|
|
|
|
|
NetManager.GetBetHistoryInfo(function(msg)
|
|
|
|
|
this.betHistoryInfo = msg.championMyBetDetails
|
|
|
|
|
-- 对历史记录排序
|
|
|
|
|
table.sort(this.betHistoryInfo, function(a, b)
|
|
|
|
|
return a.enemyPairInfo.roundTimes > b.enemyPairInfo.roundTimes
|
|
|
|
|
end)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[10120]..#this.betHistoryInfo)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if func then func() end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 竞猜成功回调
|
|
|
|
|
function this.OnGuessSuccess(msg)
|
2020-07-10 13:38:50 +08:00
|
|
|
|
LogGreen("竞猜成功回调")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if this.isLogin then return end--上来就弹新关卡界面 所以不弹
|
2020-07-23 20:39:21 +08:00
|
|
|
|
if MapManager.isInMap or UIManager.IsOpen(UIName.BattlePanel) or UIManager.IsOpen(UIName.ArenaTopMatchPanel) then return end--在关卡里 副本里不弹 新加巅峰赛界面不弹
|
2020-05-09 13:31:21 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.GuessCoinDropPopup, msg.roundTimes, msg.itemId, msg.itemNum)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 判断是否可以竞猜
|
|
|
|
|
function this.IsCanBet()
|
|
|
|
|
return this.isCanBet
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 获取竞猜战斗信息
|
|
|
|
|
function this.GetBetBattleInfo()
|
2020-07-17 10:28:02 +08:00
|
|
|
|
this.ChangeData(this.CurTabIndex)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return this.betBattleInfo
|
|
|
|
|
end
|
|
|
|
|
--- 获取赔率信息
|
|
|
|
|
function this.GetBetRateInfo()
|
|
|
|
|
return this.betRateInfo
|
|
|
|
|
end
|
|
|
|
|
--- 获取我下注的对象
|
|
|
|
|
function this.GetMyBetTarget()
|
|
|
|
|
return this.myBetTarget
|
|
|
|
|
end
|
2020-07-22 19:40:23 +08:00
|
|
|
|
--- 获取我下注的竞猜币数量
|
|
|
|
|
function this.GetMyBetCoins()
|
|
|
|
|
return this.myBetCoins
|
|
|
|
|
end
|
2020-07-08 20:48:43 +08:00
|
|
|
|
--- 获取竞猜三局两胜数据
|
|
|
|
|
function this.GetProcess()
|
|
|
|
|
return this.process
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 获取历史竞猜记录
|
|
|
|
|
function this.GetBetHistory()
|
|
|
|
|
return this.betHistoryInfo
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 设置竞猜币数量
|
|
|
|
|
function this.SetCoinNum(num)
|
|
|
|
|
this.coinNum=num
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取竞猜币数量
|
|
|
|
|
function this.GetCoinNum()
|
|
|
|
|
return this.coinNum
|
|
|
|
|
end
|
|
|
|
|
--- =================== end ==========================
|
|
|
|
|
|
|
|
|
|
--- ======================32强赛数据=====================
|
|
|
|
|
|
|
|
|
|
--- 请求淘汰赛数据(32强)
|
|
|
|
|
function this.Request_32_EliminationData(func)
|
|
|
|
|
-- 未开启
|
|
|
|
|
if not this.IsTopMatchActive() then return end
|
|
|
|
|
--
|
|
|
|
|
if this.baseInfo.battleStage ~= TOP_MATCH_STAGE.ELIMINATION and this.baseInfo.battleStage~= TOP_MATCH_STAGE.OVER then return end
|
|
|
|
|
|
|
|
|
|
NetManager.GetTopMatchEliminationInfo(1, function(msg)
|
2020-07-16 14:13:27 +08:00
|
|
|
|
LogPink("获取32强数据成功, 数据长度 = "..#msg.championBattlePairInfo)
|
|
|
|
|
for i = 1, #msg.championBattlePairInfo do
|
2020-07-23 11:08:11 +08:00
|
|
|
|
LogPink("roundTImes "..msg.championBattlePairInfo[i].roundTImes.." .teamId "..msg.championBattlePairInfo[i].teamId.." .position ".. msg.championBattlePairInfo[i].position
|
|
|
|
|
.." attackInfo.uid ".. msg.championBattlePairInfo[i].attackInfo.uid.." defInfo.uid ".. msg.championBattlePairInfo[i].defInfo.uid.." fightResult ".. msg.championBattlePairInfo[i].fightResult)
|
2020-07-16 14:13:27 +08:00
|
|
|
|
end
|
2020-07-16 10:13:32 +08:00
|
|
|
|
this.EliminationData_32 = this.RequestEliminationDataMerge(msg.championBattlePairInfo)
|
|
|
|
|
-- this.EliminationData_32 = msg.championBattlePairInfo
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if func then func() end
|
|
|
|
|
end)
|
|
|
|
|
end
|
2020-07-16 10:13:32 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--- 请求淘汰赛数据(4强)
|
|
|
|
|
function this.Request_4_EliminationData(func)
|
|
|
|
|
-- 未开启
|
|
|
|
|
if not this.IsTopMatchActive() then return end
|
|
|
|
|
--
|
|
|
|
|
if this.baseInfo.battleStage ~= TOP_MATCH_STAGE.ELIMINATION and this.baseInfo.battleStage~= TOP_MATCH_STAGE.OVER then return end
|
|
|
|
|
|
|
|
|
|
NetManager.GetTopMatchEliminationInfo(2, function(msg)
|
2020-07-16 10:13:32 +08:00
|
|
|
|
-- this.EliminationData_4 = msg.championBattlePairInfo
|
2020-07-16 14:13:27 +08:00
|
|
|
|
LogPink("获取4强数据成功, 数据长度 = "..#msg.championBattlePairInfo)
|
2020-07-22 19:40:23 +08:00
|
|
|
|
for i = 1, #msg.championBattlePairInfo do
|
|
|
|
|
LogPink("roundTImes "..msg.championBattlePairInfo[i].roundTImes.." .teamId "..msg.championBattlePairInfo[i].teamId.." .position ".. msg.championBattlePairInfo[i].position)
|
|
|
|
|
end
|
2020-07-16 10:13:32 +08:00
|
|
|
|
this.EliminationData_4 = this.RequestEliminationDataMerge(msg.championBattlePairInfo)
|
2020-07-16 14:13:27 +08:00
|
|
|
|
LogPink("获取4强数据成功, 数据长度 = "..#this.EliminationData_4)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if func then func() end
|
|
|
|
|
end)
|
|
|
|
|
end
|
2020-07-16 10:13:32 +08:00
|
|
|
|
--32 16 8 4 强数据合并
|
|
|
|
|
--三局两胜 需要将三局 或者两局数据 合并 算出战斗结果 胜利 失败 未打 和 竞猜结果 只要有过1就等于1
|
|
|
|
|
function this.RequestEliminationDataMerge(EliminationData)
|
|
|
|
|
local newEliminationData = {}
|
|
|
|
|
for EliminationDataI, EliminationDataV in ipairs(EliminationData) do
|
|
|
|
|
local curKey = tonumber(tostring(EliminationDataV.roundTImes)..tostring(EliminationDataV.teamId)..tostring(EliminationDataV.position))
|
|
|
|
|
if newEliminationData[curKey] then
|
|
|
|
|
table.insert(newEliminationData[curKey],EliminationDataV)
|
|
|
|
|
else
|
|
|
|
|
newEliminationData[curKey] = {}
|
|
|
|
|
table.insert(newEliminationData[curKey],EliminationDataV)
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-07-16 14:13:27 +08:00
|
|
|
|
LogPink("newEliminationData, 数据长度 = "..LengthOfTable(newEliminationData))
|
2020-07-16 10:13:32 +08:00
|
|
|
|
local datas = {}
|
|
|
|
|
for newEliminationDataI, newEliminationDataV in pairs(newEliminationData) do
|
|
|
|
|
-- LogPink("newEliminationDataI "..newEliminationDataI)
|
|
|
|
|
if newEliminationDataV and #newEliminationDataV > 0 then
|
|
|
|
|
local singledata = newEliminationDataV[1]
|
2020-07-23 12:19:45 +08:00
|
|
|
|
-- singledata.dataList = newEliminationDataV
|
2020-08-05 21:28:16 +08:00
|
|
|
|
local fightResult = -1 ---1 无记录 0前两场负 1 前两场胜 2 胜 3 负 4 胜负 5 负胜
|
2020-08-24 21:46:19 +08:00
|
|
|
|
if #newEliminationDataV >= 2 then
|
|
|
|
|
for i = 1, #newEliminationDataV do
|
|
|
|
|
if i == 1 and newEliminationDataV[i].fightResult == 0 then
|
|
|
|
|
fightResult = 3
|
|
|
|
|
elseif i == 1 and newEliminationDataV[i].fightResult == 1 then
|
|
|
|
|
fightResult = 2
|
|
|
|
|
elseif i == 1 and newEliminationDataV[i].fightResult == -1 then
|
|
|
|
|
fightResult = -1
|
2020-07-16 14:13:27 +08:00
|
|
|
|
end
|
2020-08-24 21:46:19 +08:00
|
|
|
|
if i == 2 and newEliminationDataV[i].fightResult == 0 then
|
|
|
|
|
if fightResult == 3 then
|
|
|
|
|
fightResult = 0
|
|
|
|
|
elseif fightResult == 2 then
|
|
|
|
|
fightResult = 4
|
|
|
|
|
end
|
|
|
|
|
elseif i == 2 and newEliminationDataV[i].fightResult == 1 then
|
|
|
|
|
if fightResult == 3 then
|
|
|
|
|
fightResult = 5
|
|
|
|
|
elseif fightResult == 2 then
|
|
|
|
|
fightResult = 1
|
|
|
|
|
end
|
|
|
|
|
elseif i == 2 and newEliminationDataV[i].fightResult == -1 then
|
|
|
|
|
fightResult = -1
|
2020-07-16 10:13:32 +08:00
|
|
|
|
end
|
2020-08-24 21:46:19 +08:00
|
|
|
|
if i == 3 then
|
|
|
|
|
if fightResult == 4 then
|
|
|
|
|
fightResult = newEliminationDataV[i].fightResult
|
|
|
|
|
elseif fightResult == 5 then
|
|
|
|
|
fightResult = newEliminationDataV[i].fightResult
|
|
|
|
|
end
|
|
|
|
|
elseif i == 3 and newEliminationDataV[i].fightResult == -1 then
|
|
|
|
|
if fightResult == 4 or fightResult == 5 then
|
|
|
|
|
fightResult = -1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if newEliminationDataV[i].isGUess <= 0 then
|
|
|
|
|
singledata.isGUess = newEliminationDataV[i].isGUess
|
2020-07-16 10:13:32 +08:00
|
|
|
|
end
|
2020-07-16 14:13:27 +08:00
|
|
|
|
end
|
2020-07-16 10:13:32 +08:00
|
|
|
|
end
|
2020-07-16 14:13:27 +08:00
|
|
|
|
singledata.fightResult = fightResult
|
2020-07-16 10:13:32 +08:00
|
|
|
|
-- LogPink("fightResult "..singledata.fightResult)
|
|
|
|
|
-- LogPink("isGUess "..singledata.isGUess)
|
|
|
|
|
-- newEliminationData_32V = singledata
|
2020-07-23 12:19:45 +08:00
|
|
|
|
table.insert(datas,{_singleData = singledata,_listData = newEliminationDataV})
|
2020-07-16 10:13:32 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
table.sort(datas, function(a, b)
|
2020-07-23 12:19:45 +08:00
|
|
|
|
if a._singleData.roundTImes == b._singleData.roundTImes then
|
|
|
|
|
if a._singleData.teamId == b._singleData.teamId then
|
|
|
|
|
return a._singleData.position < b._singleData.position
|
2020-07-16 10:13:32 +08:00
|
|
|
|
else
|
2020-07-23 12:19:45 +08:00
|
|
|
|
return a._singleData.teamId < b._singleData.teamId
|
2020-07-16 10:13:32 +08:00
|
|
|
|
end
|
|
|
|
|
else
|
2020-07-23 12:19:45 +08:00
|
|
|
|
return a._singleData.roundTImes < b._singleData.roundTImes
|
2020-07-16 10:13:32 +08:00
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
return datas
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--- 获取32强数据
|
|
|
|
|
function this.Get_32_EliminationData()
|
|
|
|
|
-- body
|
|
|
|
|
return this.EliminationData_32
|
|
|
|
|
end
|
|
|
|
|
-- 获取4强数据
|
|
|
|
|
function this.Get_4_EliminationData()
|
|
|
|
|
-- body
|
|
|
|
|
return this.EliminationData_4
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- =================== end ==========================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ==================== 其他接口==========================
|
|
|
|
|
-- 请求回放数据
|
|
|
|
|
function this.RequestRecordFightData(result, fightId, nameStr, func)
|
|
|
|
|
NetManager.FightRePlayRequest(2, fightId, function(msg)
|
|
|
|
|
local fightData = msg.fightData
|
|
|
|
|
if not fightData then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10089])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
-- local nameStr = fight.attackName.."|"..fight.defName
|
|
|
|
|
this.RequestReplayRecord(result, fightData, nameStr, func)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
--- 请求开始播放回放
|
|
|
|
|
--- isWin 战斗结果 1 胜利 0 失败
|
|
|
|
|
--- fightData 战斗数据
|
|
|
|
|
--- nameStr 交战双方名称
|
|
|
|
|
--- doneFunc 战斗播放完成要回调的事件
|
|
|
|
|
function this.RequestReplayRecord(isWin, fightData, nameStr, doneFunc)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local fightData = BattleManager.GetBattleServerData({fightData = fightData}, 1)
|
|
|
|
|
local battlePanel = UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.BACK, doneFunc)
|
|
|
|
|
battlePanel:ShowNameShow(isWin, nameStr)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取当前阶段名称
|
|
|
|
|
function this.GetCurTopMatchName()
|
2020-07-10 13:38:50 +08:00
|
|
|
|
LogPink("```````````````````````````````````````````````````")
|
|
|
|
|
LogPink("this.baseInfo.progress "..this.baseInfo.progress)
|
|
|
|
|
local titleName = Language[10121]--逐胜之巅
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local stageName = ""
|
|
|
|
|
if this.baseInfo.progress == -1 then
|
2020-07-10 13:38:50 +08:00
|
|
|
|
return titleName, Language[10122], Language[10123]--未开始 即将开始
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif this.baseInfo.progress == -2 then
|
2020-07-10 13:38:50 +08:00
|
|
|
|
return titleName, Language[10124], Language[10124]--已结束
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if this.baseInfo.battleStage == TOP_MATCH_STAGE.CHOOSE then
|
2020-07-10 13:38:50 +08:00
|
|
|
|
stageName = Language[10125]..NumToSimplenessFont[this.baseInfo.battleTurn]--选拔赛
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-07-10 13:38:50 +08:00
|
|
|
|
-- local maxTurn = this.GetEliminationMaxRound()
|
|
|
|
|
-- local curTurn = this.baseInfo.battleTurn
|
|
|
|
|
-- LogPink("this.baseInfo.battleTurn "..this.baseInfo.battleTurn.." maxTurn "..maxTurn)
|
|
|
|
|
-- local opTurn = maxTurn - curTurn + 1 --- 将服务器发过来的轮数倒序,方便计算
|
|
|
|
|
-- LogPink("opTurn "..opTurn.." math.pow(2, opTurn) "..math.pow(2, opTurn))
|
|
|
|
|
-- if opTurn == 1 then
|
|
|
|
|
-- stageName = Language[10126]--决赛
|
|
|
|
|
-- else
|
|
|
|
|
-- stageName = math.pow(2, opTurn) .. Language[10097]--强
|
|
|
|
|
-- end
|
2020-07-10 15:16:50 +08:00
|
|
|
|
stageName = stageNameTable[this.baseInfo.battleTurn] or "不知道"..this.baseInfo.battleTurn
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-07-10 13:38:50 +08:00
|
|
|
|
local stateName = TOP_MATCH_STATE_NAME[this.baseInfo.battleState] or Language[10127]--未知
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return titleName, stageName, stateName
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 通过总轮数获取当前阶段名称
|
2020-07-10 15:16:50 +08:00
|
|
|
|
function this.GetTurnNameByRoundTimes(roundTimes,curTurn)
|
|
|
|
|
LogGreen("roundTimes "..roundTimes)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if not roundTimes or roundTimes <= 0 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10122]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
-- 选拔赛
|
|
|
|
|
local maxRound = this.GetChooseMaxRound()
|
|
|
|
|
if roundTimes <= maxRound then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10125]..NumToSimplenessFont[roundTimes]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-07-10 15:16:50 +08:00
|
|
|
|
-- 淘汰赛
|
|
|
|
|
return stageNameTable[roundTimes] or "不知道"..this.baseInfo.battleTurn
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-07-10 15:16:50 +08:00
|
|
|
|
|
|
|
|
|
-- local curTurn = roundTimes - maxRound -- 当前淘汰赛轮数
|
|
|
|
|
-- local maxTurn = this.GetEliminationMaxRound()
|
|
|
|
|
-- local opTurn = maxTurn - curTurn + 1 --- 将服务器发过来的轮数倒序,方便计算
|
|
|
|
|
-- LogGreen("opTurn "..opTurn.." maxTurn "..maxTurn.." curTurn "..curTurn)
|
|
|
|
|
-- if opTurn == 1 then
|
|
|
|
|
-- return Language[10126]
|
|
|
|
|
-- else
|
|
|
|
|
-- return math.pow(2, opTurn) .. Language[10097]
|
|
|
|
|
-- end
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10127]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取选拔赛最大轮数
|
|
|
|
|
local CHOOSE_MAX_ROUND
|
|
|
|
|
function this.GetChooseMaxRound()
|
|
|
|
|
if not CHOOSE_MAX_ROUND then
|
|
|
|
|
CHOOSE_MAX_ROUND = ConfigManager.GetConfigData(ConfigName.ChampionshipSetting, 1).TrialsGroup - 1--选拔赛最大轮数 = 每组人数 - 1
|
|
|
|
|
end
|
|
|
|
|
return CHOOSE_MAX_ROUND
|
|
|
|
|
end
|
|
|
|
|
-- 获取淘汰赛最大轮数
|
|
|
|
|
local ELIMINATION_MAX_ROUND
|
|
|
|
|
function this.GetEliminationMaxRound()
|
|
|
|
|
if not ELIMINATION_MAX_ROUND then
|
|
|
|
|
local config = ConfigManager.GetConfigData(ConfigName.ChampionshipSetting, 1)
|
|
|
|
|
local eliminationNum = config.ChampionshipPlayer/config.TrialsGroup*config.TrialsGroupWinner -- 参与淘汰赛得人数
|
|
|
|
|
ELIMINATION_MAX_ROUND = math.log(eliminationNum, 2)
|
|
|
|
|
end
|
|
|
|
|
return ELIMINATION_MAX_ROUND
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取选拔赛每场积分变化值常量
|
|
|
|
|
function this.GetMatchDeltaIntegral()
|
|
|
|
|
return ConfigManager.GetConfigData(ConfigName.ChampionshipSetting, 1).WinnerIntegral
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 通过排名获取相应的排名位置
|
|
|
|
|
function this.GetRankNameByRank(rank)
|
|
|
|
|
--
|
2020-07-10 13:38:50 +08:00
|
|
|
|
LogPink("rank "..rank)
|
|
|
|
|
if rank <= 0 then return Language[10041] end--未上榜
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local curStage = this.baseInfo.battleStage
|
|
|
|
|
local curTurn = this.baseInfo.battleTurn
|
|
|
|
|
local curState = this.baseInfo.battleState
|
2020-07-16 10:13:32 +08:00
|
|
|
|
LogPink("rank "..rank.." curStage "..curStage.." curTurn "..curTurn.." curState "..curState)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--- 未获取到数据
|
|
|
|
|
if curStage == -1 or curTurn == -1 or curState == -1 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10041]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
--- 选拔赛阶段都是相应得强数
|
2020-07-16 10:13:32 +08:00
|
|
|
|
-- if curStage == 1 then
|
|
|
|
|
-- local config = ConfigManager.GetConfigData(ConfigName.ChampionshipSetting, 1)
|
|
|
|
|
-- return config.ChampionshipPlayer..Language[10097]
|
|
|
|
|
-- -- 判断淘汰赛阶段的轮数
|
|
|
|
|
-- elseif curStage == 2 or curStage == -2 then
|
|
|
|
|
-- -- if curState == TOP_MATCH_TIME_STATE.OPEN_IN_END or curState == TOP_MATCH_TIME_STATE.OVER then
|
2020-07-10 13:38:50 +08:00
|
|
|
|
-- if rank == 1 then
|
|
|
|
|
-- return Language[10095]--冠军
|
|
|
|
|
-- elseif rank == 2 then
|
|
|
|
|
-- return Language[10096]--亚军
|
|
|
|
|
-- end
|
2020-07-16 10:13:32 +08:00
|
|
|
|
-- return rank..Language[10097]--几强
|
|
|
|
|
-- elseif curStage == -1 then
|
|
|
|
|
-- return Language[10041]
|
2020-07-10 13:38:50 +08:00
|
|
|
|
-- end
|
2020-07-16 15:52:19 +08:00
|
|
|
|
-- 选拔赛阶段都是相应得强数
|
|
|
|
|
if curStage == 1 then
|
|
|
|
|
local config = ConfigManager.GetConfigData(ConfigName.ChampionshipSetting, 1)
|
|
|
|
|
return config.ChampionshipPlayer..Language[10097]
|
|
|
|
|
end
|
2020-07-16 10:13:32 +08:00
|
|
|
|
--- 判断淘汰赛阶段的轮数
|
|
|
|
|
local maxTurn = this.GetEliminationMaxRound()
|
|
|
|
|
LogPink("maxTurn "..maxTurn)
|
|
|
|
|
if curTurn <= 0 then curTurn = maxTurn end
|
|
|
|
|
local opTurn = maxTurn - curTurn + 1 --- 将服务器发过来的轮数倒序,方便计算
|
|
|
|
|
--- 如果是结算状态,按下一轮处理
|
|
|
|
|
LogPink("opTurn "..opTurn)
|
|
|
|
|
if curState == TOP_MATCH_TIME_STATE.OPEN_IN_END or curState == TOP_MATCH_TIME_STATE.OVER then
|
|
|
|
|
opTurn = opTurn - 1
|
|
|
|
|
end
|
|
|
|
|
LogPink("opTurn "..opTurn)
|
|
|
|
|
--- 轮数为0表示决赛的结算阶段
|
|
|
|
|
if opTurn == 0 then
|
|
|
|
|
if rank == 1 then
|
|
|
|
|
return Language[10095]--冠军
|
|
|
|
|
elseif rank == 2 then
|
|
|
|
|
return Language[10096]--亚军
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--- 如果大于淘汰赛最大轮数的最大名次
|
|
|
|
|
if rank > math.pow(2, maxTurn) then
|
|
|
|
|
local config = ConfigManager.GetConfigData(ConfigName.ChampionshipSetting, 1)
|
|
|
|
|
LogPink(config.ChampionshipPlayer..Language[10097])
|
|
|
|
|
return config.ChampionshipPlayer..Language[10097]--几强
|
|
|
|
|
end
|
|
|
|
|
--- 如果小于当前轮数的最大排名,则返回当前轮数的名称
|
|
|
|
|
local opTurnMaxRank = math.pow(2, opTurn)
|
|
|
|
|
if rank <= opTurnMaxRank then
|
|
|
|
|
LogPink(opTurnMaxRank..Language[10097])
|
|
|
|
|
return opTurnMaxRank..Language[10097]
|
|
|
|
|
end
|
|
|
|
|
--- 如果大于当前的轮数,则可能已被淘汰,返回相应的被淘汰轮数的名称
|
|
|
|
|
for turn = opTurn + 1, maxTurn do
|
|
|
|
|
local turnMaxRank = math.pow(2, turn)
|
|
|
|
|
if rank <= turnMaxRank then
|
|
|
|
|
LogPink(turnMaxRank..Language[10097])
|
|
|
|
|
return turnMaxRank..Language[10097]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- 数据没错的情况下不会出现这种情况
|
|
|
|
|
return Language[10041]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 竞猜币ID
|
|
|
|
|
function this.GetGuessCoinID()
|
|
|
|
|
return 77
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- -- 是否可换阵容
|
|
|
|
|
function this.CanChangeTeam()
|
|
|
|
|
if this.myBattleInfo.result ~= -1 then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
local state = this.baseInfo.battleState -- 当前阶段状态
|
|
|
|
|
local isJoin = this.baseInfo.joinState == 1 -- 参与状态
|
2020-07-08 15:02:16 +08:00
|
|
|
|
if isJoin and state == TOP_MATCH_TIME_STATE.OPEN_IN_GUESS then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
--- =================== end ==========================
|
|
|
|
|
|
|
|
|
|
-----淘汰赛相关-----
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
-----巅峰战排名相关-----
|
|
|
|
|
this.rankData={}--排行滚动数据
|
|
|
|
|
this.myRankData={} --我的数据
|
|
|
|
|
this.requestCountDown=1--允许请求倒计时
|
|
|
|
|
this.requestTimer=nil--允许请求计时器
|
|
|
|
|
this.CurPage=0
|
|
|
|
|
|
|
|
|
|
--请求排名数据
|
|
|
|
|
function this.RequestRankData(page,func)
|
|
|
|
|
-- if this.CurPage >= page or #this.rankData>128 then return end
|
|
|
|
|
-- this.CurPage=page
|
|
|
|
|
|
|
|
|
|
--防连续切标签不断请求数据
|
|
|
|
|
--if this.requestTimer~=nil then return end
|
|
|
|
|
--this.requestTimer = Timer.New(function()
|
|
|
|
|
-- this.requestCountDown=this.requestCountDown-1
|
|
|
|
|
-- if this.requestCountDown<0 then
|
|
|
|
|
-- this.requestCountDown=0
|
|
|
|
|
-- this.requestTimer:Stop()
|
|
|
|
|
-- this.requestTimer=nil
|
|
|
|
|
-- this.requestCountDown=1
|
|
|
|
|
-- end
|
|
|
|
|
--end, 1,-1)
|
|
|
|
|
--this.requestTimer:Start()
|
|
|
|
|
|
|
|
|
|
--if this.baseInfo.battleStage== TOP_MATCH_STAGE.ELIMINATION
|
|
|
|
|
-- and this.baseInfo.battleTurn > 0
|
|
|
|
|
-- or this.baseInfo.battleStage == TOP_MATCH_STAGE.OVER then
|
2020-07-03 16:09:15 +08:00
|
|
|
|
NetManager.GetTopMatchRankInfo(page,function(msg)
|
|
|
|
|
this.myRankData=msg.myInfo.personInfo
|
|
|
|
|
if page==1 then
|
|
|
|
|
this.rankData={}
|
|
|
|
|
end
|
|
|
|
|
local length=#this.rankData
|
|
|
|
|
for i, v in ipairs(msg.rankInfos) do
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if v.personInfo.rank<=8 then
|
2020-07-22 19:40:23 +08:00
|
|
|
|
LogGreen("前八名数据 "..length+i.." uid "..v.personInfo.uid)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.rankData[length+i]=v.personInfo
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if func then
|
|
|
|
|
func()
|
|
|
|
|
end
|
|
|
|
|
-- for i, v in pairs(this.rankData) do
|
2020-07-03 16:09:15 +08:00
|
|
|
|
-- Log(tostring(v))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- end
|
2020-07-03 16:09:15 +08:00
|
|
|
|
-- Log("<color=green>排行请求成功 请求页签"..page.."</color>")
|
|
|
|
|
-- Game.GlobalEvent:DispatchEvent(GameEvent.ATM_RankView.OnRankChange)
|
|
|
|
|
end)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--end
|
|
|
|
|
end
|
|
|
|
|
--获取排行数据
|
|
|
|
|
function this.GetRankData()
|
|
|
|
|
return this.rankData,this.myRankData
|
|
|
|
|
end
|
|
|
|
|
--请求下页数据
|
|
|
|
|
-- function this.GetNextRankData()
|
|
|
|
|
-- Log("请求下一页数据")
|
|
|
|
|
-- --判断是否符合刷新条件
|
|
|
|
|
-- local MaxNum = 128
|
|
|
|
|
-- if #this.rankData >= MaxNum then return end
|
|
|
|
|
-- --上一页数据少于20条,则没有下一页数,不再刷新
|
|
|
|
|
-- if #this.rankData % 20 > 0 then
|
|
|
|
|
-- return
|
|
|
|
|
-- end
|
|
|
|
|
-- this.RequestRankData(this.CurPage + 1)
|
|
|
|
|
-- end
|
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
|
|
-----巅峰战奖励相关-----
|
|
|
|
|
--获取奖励数据
|
|
|
|
|
function this.GetRewardData()
|
|
|
|
|
return this.rewardData
|
|
|
|
|
end
|
2020-07-08 20:48:43 +08:00
|
|
|
|
--三局两胜获取显示数据
|
|
|
|
|
function this.GetTwoOutOfThreeInfo(type)
|
2020-07-16 14:13:27 +08:00
|
|
|
|
local oldTwoOutOfThreeIndex = nil---历史记录(上次的结果 当前胜负根据战斗结果判断) -1 无记录 0前两场负 1 前两场胜 2 胜 3 负 4 胜负 5 负胜
|
2020-07-08 20:48:43 +08:00
|
|
|
|
local curBattleResult = nil--当前胜负 -1 未开始 0 负 1 胜
|
2020-07-16 14:13:27 +08:00
|
|
|
|
if type == 1 then--我的
|
2020-07-08 20:48:43 +08:00
|
|
|
|
oldTwoOutOfThreeIndex = this.GetBaseData().process
|
|
|
|
|
curBattleResult = this.GetBattleInfo().result
|
2020-07-16 14:13:27 +08:00
|
|
|
|
elseif type == 2 then--竞猜
|
2020-07-08 20:48:43 +08:00
|
|
|
|
oldTwoOutOfThreeIndex = this.GetProcess()
|
|
|
|
|
curBattleResult = this.GetBetBattleInfo().result
|
|
|
|
|
end
|
|
|
|
|
LogGreen("oldTwoOutOfThreeIndex "..oldTwoOutOfThreeIndex)
|
|
|
|
|
if curBattleResult then
|
|
|
|
|
LogGreen(" curBattleResult "..curBattleResult)
|
|
|
|
|
end
|
|
|
|
|
if oldTwoOutOfThreeIndex == -1 then--无记录
|
|
|
|
|
if not curBattleResult then
|
|
|
|
|
LogGreen(" return 0,0")
|
|
|
|
|
return 0,0
|
|
|
|
|
else
|
|
|
|
|
if curBattleResult == -1 then
|
|
|
|
|
LogGreen(" return 0,0")
|
|
|
|
|
return 0,0
|
|
|
|
|
elseif curBattleResult == 0 then
|
|
|
|
|
LogGreen(" return 0,1")
|
|
|
|
|
return 0,1
|
|
|
|
|
elseif curBattleResult == 1 then
|
|
|
|
|
LogGreen(" return 1,0")
|
|
|
|
|
return 1,0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
elseif oldTwoOutOfThreeIndex == 2 then--胜
|
|
|
|
|
if not curBattleResult then
|
|
|
|
|
LogGreen(" return 1,0")
|
|
|
|
|
return 1,0
|
|
|
|
|
else
|
|
|
|
|
if curBattleResult == -1 then
|
|
|
|
|
LogGreen(" return 1,0")
|
|
|
|
|
return 1,0
|
|
|
|
|
elseif curBattleResult == 0 then
|
|
|
|
|
LogGreen(" return 1,1")
|
|
|
|
|
return 1,1
|
|
|
|
|
elseif curBattleResult == 1 then
|
|
|
|
|
LogGreen(" return 2,0")
|
|
|
|
|
return 2,0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
elseif oldTwoOutOfThreeIndex == 3 then--负
|
|
|
|
|
if not curBattleResult then
|
|
|
|
|
LogGreen(" return 0,1")
|
|
|
|
|
return 0,1
|
|
|
|
|
else
|
|
|
|
|
if curBattleResult == -1 then
|
|
|
|
|
LogGreen(" return 0,1")
|
|
|
|
|
return 0,1
|
|
|
|
|
elseif curBattleResult == 0 then
|
|
|
|
|
LogGreen(" return 0,2")
|
|
|
|
|
return 0,2
|
|
|
|
|
elseif curBattleResult == 1 then
|
|
|
|
|
LogGreen(" return 1,1")
|
|
|
|
|
return 1,1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
elseif oldTwoOutOfThreeIndex == 4 then--胜负
|
|
|
|
|
if not curBattleResult then
|
|
|
|
|
LogGreen(" return 1,1")
|
|
|
|
|
return 1,1
|
|
|
|
|
else
|
|
|
|
|
if curBattleResult == -1 then
|
|
|
|
|
LogGreen(" return 1,1")
|
|
|
|
|
return 1,1
|
|
|
|
|
elseif curBattleResult == 0 then
|
|
|
|
|
LogGreen(" return 1,2")
|
|
|
|
|
return 1,2
|
|
|
|
|
elseif curBattleResult == 1 then
|
|
|
|
|
LogGreen(" return 2,1")
|
|
|
|
|
return 2,1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
elseif oldTwoOutOfThreeIndex == 5 then--负胜
|
|
|
|
|
if not curBattleResult then
|
|
|
|
|
LogGreen(" return 1,1")
|
|
|
|
|
return 1,1
|
|
|
|
|
else
|
|
|
|
|
if curBattleResult == -1 then
|
|
|
|
|
LogGreen(" return 1,1")
|
|
|
|
|
return 1,1
|
|
|
|
|
elseif curBattleResult == 0 then
|
|
|
|
|
LogGreen(" return 1,2")
|
|
|
|
|
return 1,2
|
|
|
|
|
elseif curBattleResult == 1 then
|
|
|
|
|
LogGreen(" return 2,1")
|
|
|
|
|
return 2,1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
elseif oldTwoOutOfThreeIndex == 0 then--负负
|
|
|
|
|
LogGreen(" return 0,2")
|
|
|
|
|
return 0,2
|
|
|
|
|
elseif oldTwoOutOfThreeIndex == 1 then--胜胜
|
|
|
|
|
LogGreen(" return 2,0")
|
|
|
|
|
return 2,0
|
|
|
|
|
end
|
2020-07-24 10:01:48 +08:00
|
|
|
|
return 0,0
|
2020-07-08 20:48:43 +08:00
|
|
|
|
end
|
2020-07-16 14:13:27 +08:00
|
|
|
|
--获取当前三局两胜是否结束
|
|
|
|
|
function this.GetIsBattleEndState(type)
|
|
|
|
|
local oldTwoOutOfThreeIndex = nil---历史记录(上次的结果 当前胜负根据战斗结果判断) -1 无记录 0前两场负 1 前两场胜 2 胜 3 负 4 胜负 5 负胜
|
|
|
|
|
if type == 1 then--我的
|
2020-07-14 10:12:07 +08:00
|
|
|
|
oldTwoOutOfThreeIndex = this.GetBaseData().process
|
2020-07-16 14:13:27 +08:00
|
|
|
|
elseif type == 2 then--竞猜
|
2020-07-14 10:12:07 +08:00
|
|
|
|
oldTwoOutOfThreeIndex = this.GetProcess()
|
2020-07-24 10:01:48 +08:00
|
|
|
|
LogPink("oldTwoOutOfThreeIndex "..oldTwoOutOfThreeIndex)
|
2020-07-14 10:12:07 +08:00
|
|
|
|
end
|
2020-07-16 14:13:27 +08:00
|
|
|
|
local baseData = ArenaTopMatchManager.GetBaseData()
|
|
|
|
|
-- 没开启或者开启没参赛都属于未参赛
|
|
|
|
|
local isJoin = baseData.joinState == 1
|
|
|
|
|
local isOver = baseData.progress == -2
|
2020-07-22 19:40:23 +08:00
|
|
|
|
if (oldTwoOutOfThreeIndex == 0 or oldTwoOutOfThreeIndex == 1) and isJoin and not isOver then
|
2020-07-14 10:12:07 +08:00
|
|
|
|
return true
|
|
|
|
|
else
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--屏幕索引 没啥用了
|
2020-07-10 13:38:50 +08:00
|
|
|
|
function this.SetCurTabIndex(index)
|
|
|
|
|
this.CurTabIndex = index
|
|
|
|
|
end
|
|
|
|
|
function this.GetCurTabIndex()
|
|
|
|
|
return this.CurTabIndex
|
|
|
|
|
end
|
2020-07-14 10:12:07 +08:00
|
|
|
|
--是否显示竞猜结果
|
2020-07-10 13:38:50 +08:00
|
|
|
|
function this.SetcurIsShowDoGuessPopup(isShow)
|
|
|
|
|
this.curIsShowDoGuessPopup = isShow
|
|
|
|
|
end
|
|
|
|
|
function this.GetcurIsShowDoGuessPopup()
|
|
|
|
|
return this.curIsShowDoGuessPopup
|
|
|
|
|
end
|
2020-07-17 10:28:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local old_baseInfo_battleState = 0--状态 准备 还是 战斗
|
|
|
|
|
local old_baseInfo_endTime = 0--倒计时时间戳
|
|
|
|
|
local old_myBattleInfo_result = 0--我的当前战斗结果
|
|
|
|
|
local old_betBattleInfo_result = 0--竞猜当前战斗结果
|
|
|
|
|
--当第三场不需要时 需要先端自己改变数据
|
|
|
|
|
function this.ChangeData(type)
|
2020-07-23 11:08:11 +08:00
|
|
|
|
-- if true then return end
|
2020-07-17 10:28:02 +08:00
|
|
|
|
if not type then return end
|
|
|
|
|
local isJoin = this.baseInfo.joinState == 1
|
|
|
|
|
local isOver = this.baseInfo.progress == -2
|
2020-07-22 19:40:23 +08:00
|
|
|
|
if not isJoin or isOver or this.baseInfo.battleStage ~= TOP_MATCH_STAGE.ELIMINATION or this.baseInfo.loser then return end
|
2020-07-17 10:28:02 +08:00
|
|
|
|
local oldTwoOutOfThreeIndex = nil---历史记录(上次的结果 当前胜负根据战斗结果判断) -1 无记录 0前两场负 1 前两场胜 2 胜 3 负 4 胜负 5 负胜
|
|
|
|
|
if type == 1 then--我的
|
|
|
|
|
oldTwoOutOfThreeIndex = this.baseInfo.process
|
|
|
|
|
elseif type == 2 then--竞猜
|
|
|
|
|
oldTwoOutOfThreeIndex = this.GetProcess()
|
|
|
|
|
end
|
|
|
|
|
if oldTwoOutOfThreeIndex == 0 or oldTwoOutOfThreeIndex == 1 then
|
2020-07-22 19:40:23 +08:00
|
|
|
|
LogPink("isChange "..tostring(isChange))
|
2020-07-17 10:28:02 +08:00
|
|
|
|
if not isChange then
|
|
|
|
|
old_baseInfo_battleState = this.baseInfo.battleState
|
|
|
|
|
old_baseInfo_endTime = this.baseInfo.endTime
|
|
|
|
|
|
|
|
|
|
this.baseInfo.battleState = TOP_MATCH_TIME_STATE.OPEN_IN_END
|
|
|
|
|
this.baseInfo.endTime = PlayerManager.serverTime
|
|
|
|
|
if type == 1 then--我的
|
2020-07-23 12:19:45 +08:00
|
|
|
|
-- LogRed("当第三场不需要时 需要先端自己改变数据 修改我的")
|
2020-07-17 10:28:02 +08:00
|
|
|
|
old_myBattleInfo_result = this.myBattleInfo.result
|
|
|
|
|
this.myBattleInfo.result = oldTwoOutOfThreeIndex--1
|
2020-07-23 12:19:45 +08:00
|
|
|
|
-- LogRed("当第三场不需要时 需要先端自己改变数据 修改我的 ".. this.myBattleInfo.result)
|
2020-07-17 10:28:02 +08:00
|
|
|
|
elseif type == 2 then--竞猜
|
|
|
|
|
old_betBattleInfo_result = this.betBattleInfo.result
|
|
|
|
|
this.betBattleInfo.result = oldTwoOutOfThreeIndex--1
|
2020-07-23 12:19:45 +08:00
|
|
|
|
-- LogRed("当第三场不需要时 需要先端自己改变数据 修改竞猜 ".. this.betBattleInfo.result)
|
2020-07-17 10:28:02 +08:00
|
|
|
|
end
|
|
|
|
|
isChange = true
|
|
|
|
|
else
|
|
|
|
|
--不动
|
|
|
|
|
-- LogRed("当第三场不需要时 需要先端自己改变数据 不动")
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if not isChange then
|
|
|
|
|
--不动
|
|
|
|
|
-- LogRed("当第三场不需要时 需要先端自己改变数据 不动")
|
|
|
|
|
else
|
|
|
|
|
this.baseInfo.battleState = old_baseInfo_battleState
|
|
|
|
|
this.baseInfo.endTime = old_baseInfo_endTime
|
|
|
|
|
|
|
|
|
|
if type == 1 then--我的
|
2020-07-23 12:19:45 +08:00
|
|
|
|
-- LogRed("当第三场不需要时 需要先端自己改变数据 返回我的 "..this.myBattleInfo.result)
|
2020-07-17 10:28:02 +08:00
|
|
|
|
this.myBattleInfo.result = old_myBattleInfo_result
|
|
|
|
|
elseif type == 2 then--竞猜
|
2020-07-23 12:19:45 +08:00
|
|
|
|
-- LogRed("当第三场不需要时 需要先端自己改变数据 返回竞猜 "..this.betBattleInfo.result)
|
2020-07-17 10:28:02 +08:00
|
|
|
|
this.betBattleInfo.result = old_betBattleInfo_result
|
|
|
|
|
end
|
2020-07-22 19:40:23 +08:00
|
|
|
|
isChange = false
|
2020-07-17 10:28:02 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
----------------------
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return this
|