local FightThrone_Model = {} local EventSystem = require('Event/EventSystem') local fight_throne_pb = require('Proto/fight_throne_pb') local private = {} local JADE_ITEM_ID = 12023 function FightThrone_Model.OnStartup() private.selectHeroId = nil --首发武将id private.enterCount = 0 -- 战斗中途退出的采集奖励 private.silverFromDropOut = 0 private.goldFromDropOut = 0 private.jadeFromDropOut = 0 -- 排行榜数据 private.guildDamageRecord = nil -- 大乱斗公会伤害排行 private.playerDamageRecord = nil -- 大乱斗个人伤害排行 private.myGuildDmg = nil -- 自身军团伤害 private.myDmg = nil -- 个人伤害 NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushFightThroneResult, private.OnG2CPushFightThroneResult) NetManager.RegisterMsgCB(MessageEnums.MessageEnterFightThrone, private.OnEnterFightThroneResp) NetManager.RegisterMsgCB(MessageEnums.MessageFightThroneSelectHero, private.OnFightThroneSelectHeroResp) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushFightThroneRank, private.OnG2CPushFightThroneRank) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushFightThroneBossResult, private.OnG2CPushFightThroneBossResult) EventSystem.Regist(EventID.FightThrone_SendResult, private.SendResult) end ---------- start 协议相关 start ---------- function FightThrone_Model.SyncFightThroneInfo(info) private.enterCount = info.enterCount if info.CanSelectHero == true then private.selectHeroId = nil else private.selectHeroId = info.SelectHeroId end end function FightThrone_Model.EnterBattle() --前置判断 --活动时间 local state = CTL.FightThrone.GetEntryState() if state ~= CTL.FightThrone.EntryState.Opening then local allowTime = DataSheetManager.ConstData:GetDataByID("FightThroneAllowEntryTime").IntValue CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_FightThrone_CloseTips, UTL.Time.FormatTimeBySecondsToHour(allowTime))) return end --是否组队 if CTL.Team.IsInTeam() then UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_FightThrone_SingleEntry, private.EnterFightThroneReq, nil) return end private.EnterFightThroneReq() end function private.EnterFightThroneReq() local msg = fight_throne_pb.EnterFightThroneReq() NetManager.SendMessage(MessageEnums.MessageEnterFightThrone, msg) end function private.OnEnterFightThroneResp(msgResp) --do nothing end function FightThrone_Model.FightThroneSelectHeroReq(heroId) local msg = fight_throne_pb.FightThroneSelectHeroReq() msg.SelectHeroId = heroId NetManager.SendMessage(MessageEnums.MessageFightThroneSelectHero, msg) end function private.OnFightThroneSelectHeroResp(msgResp) if msgResp.Resp.Code == 0 then UIManager.CloseView(Const_UI_Lua.UIEnum.UIFightThroneSelectHero) EventSystem.Dispatch(EventID.FightThrone_SelectHero, private.selectHeroId) end end function private.SendResult(msg) NetManager.SendMessage(MessageEnums.MessageC2GUploadFightThroneResult, msg) if BattleDataGetter.IsInReconnectFastPlay() then -- 断线重连中结算了 --to do end MDL.FrameCmdStatistic.SetCacheFrame2CmdInfo() end function private.OnG2CPushFightThroneRank(msg) private.guildDamageRecord = msg.guildRank private.playerDamageRecord = msg.playerRank private.myGuildDmg = msg.myGuildDmg private.myDmg = msg.myDmg EventSystem.Dispatch(EventID.FightThrone_RankRefresh) end function private.OnG2CPushFightThroneResult(msg) if msg.IsSuccess == false then EventSystem.Dispatch(EventID.FightThrone_FailRewardPush, msg) end end function private.OnG2CPushFightThroneBossResult(msg) UIManager.OpenView(Const_UI_Lua.UIEnum.UIFightThroneRewardResult, msg) end -- #endregion ---------- end 协议相关 end ---------- ---------- start 数据获取相关 start ---------- function FightThrone_Model.FightThroneGuildRankIsEmpty() return private.guildDamageRecord == nil or #private.guildDamageRecord == 0 end function FightThrone_Model.GetFightThroneGuildRankIterator() return ipairs(private.guildDamageRecord) end function FightThrone_Model.GetMyGuildDmg() return private.myGuildDmg end function FightThrone_Model.FightThronePlayerRankIsEmpty() return private.playerDamageRecord == nil or #private.playerDamageRecord == 0 end function FightThrone_Model.GetFightThronePlayerRankIterator() return ipairs(private.playerDamageRecord) end function FightThrone_Model.GetMyDmg() return private.myDmg end function FightThrone_Model.GetSelectHeroId() return private.selectHeroId end function FightThrone_Model.CanEnter() return private.enterCount == 0 end function FightThrone_Model.GetEnterNums() return private.enterCount end --中途退出,缓存战斗采集的奖励 function FightThrone_Model.SetCollectRewardFromDropOut() private.silverFromDropOut = BattleDataGetter.GetCollectAmountOfPlayerByCollectKey(LuaConst.EFightThroneCollectType.SILVER) or 0 private.goldFromDropOut = BattleDataGetter.GetCollectAmountOfPlayerByCollectKey(LuaConst.EFightThroneCollectType.GOLD) or 0 private.jadeFromDropOut = BattleDataGetter.GetCollectAmountOfPlayerByCollectKey(LuaConst.EFightThroneCollectType.JADE) or 0 end --获取中途退出战斗内采集的奖励 function FightThrone_Model.GetCollectRewardFromDropOut() return private.silverFromDropOut, private.goldFromDropOut, private.jadeFromDropOut end function FightThrone_Model.GetJadeCombineDesc() local composeData = DataSheetManager.ItemCompose:GetDataByID(JADE_ITEM_ID) return string.FormatByIdsId(Const_IDS.IDS_FightThrone_SynthesisTips, composeData.Item_Table[1].ItemNum) end --获取拍卖池奖励 function FightThrone_Model.GetAuctionPoolRewardArray(fightThroneGuildRankData) local isWarZoneOpen = CTL.WarZone.IsWarZoneOpen() if isWarZoneOpen then if fightThroneGuildRankData.CrossSeverRewardPoolID > 0 then return MDL.GuildAuction.GetAuctionRewardsShowList(fightThroneGuildRankData.CrossSeverRewardPoolID, LuaConst.ActivityType.FightThrone, true) end else if fightThroneGuildRankData.RewardPoolID > 0 then return MDL.GuildAuction.GetAuctionRewardsShowList(fightThroneGuildRankData.RewardPoolID, LuaConst.ActivityType.FightThrone, true) end end return nil end ---------- end 数据获取相关 end ---------- return FightThrone_Model