local HeroMatch1v1_Model = {} local private = {} local EventSystem = require('Event/EventSystem') local hero_match_1v1_opt_pb = require "Proto.hero_match_1v1_opt_pb" local hero_match_1v1_pb = require "Proto.hero_match_1v1_pb" local WORSHIP_COUNT_BYDAY = DataSheetManager.ConstData:GetDataByID("HeroMatch1v1SeeTime").IntValue local chat_pb = require("Proto/chat_pb") local _townHomeRPTimerHandle = nil -- 刷新可比赛阶段红点 定时器句柄 local CONST_COUNTRY_HERO_COUNT = 3 HeroMatch1v1_Model.WinColor = "ffe13c" HeroMatch1v1_Model.Enum_State = { Ready = 1, -- 准备阶段 Battle = 2, -- 战斗阶段 Matching = 3, -- 匹配阶段 Finish = 4, -- 今日活动结束 } HeroMatch1v1_Model.Enum_BigStage = { Advance = 1, -- 报名阶段 Screening = 2, -- 筛选赛阶段 Rank = 3, -- 排名赛阶段 Finals = 4, -- 决赛阶段 Display = 5, -- 展示阶段 } --任务状态枚举 HeroMatch1v1_Model.Stage = { Default = 0, Join = 1100, -- 报名阶段 Filtration_1 = 1200, -- 筛选赛第一天 Filtration_2 = 1300, -- 筛选赛第二天 ShowHero = 1400, -- 展示期 match_2T1 = 1500, -- 冠军赛 match_4T2 = 1600, -- 4进2 match_8T4 = 1700, -- 8进4 match_16T8 = 1800, -- 16进8 match_32T16 = 1900, -- 30进16 match_64T32 = 2000, -- 64进32 -- 未来可能扩展赛程 } HeroMatch1v1_Model.Enum_GroupState = { Prepare = hero_match_1v1_pb.Prepare, -- 准备阶段 Battle = hero_match_1v1_pb.Battle, -- 战斗阶段 Finish = hero_match_1v1_pb.Finish, -- 战斗结束 } HeroMatch1v1_Model.IsOpenMainPanel = false -- 在玩法开启时间内打开过界面 local function GuessingSort(guessingA, guessingB) return guessingA.guessCfg.SortId < guessingB.guessCfg.SortId end function HeroMatch1v1_Model.OnStartup() private.MatchAllInfo = {} -- 赛季总数据 private.MyMatchInfo = {} -- 自己的参赛数据,在不同阶段需要判断自己是否进入了当前赛程 private.HeroMatch1v1Info = {} -- 缓存当前排位赛的所有赛程信息,后续查看过往比赛信息从这里取数据 private.MatchGuessingInfo = {} -- 所有竞猜信息 private.MatchAllPlayerInfo = {} -- 64强玩家信息 private.lastStageID = 0 private.worshipRewardCount = 0 private.watchWarRequestOffset = 0 private.WatchWarInfo = {} private.WatchRewardCondition = nil -- 奖励状态 private.WatchBattleChatCount = 0 -- 发送弹幕数量 private.curCountryIdArray = nil -- 当前赛季国别组 EventSystem.Regist(EventID.SyncUnfairSolo_BattleResult, private.SendBattleResult) EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshUnLockFunc) EventSystem.Regist(EventID.WatchBattle_LevelStop, private.OnWatchBattleOver) NetManager.RegisterMsgCB(MessageEnums.MessageGetStatueList, private.OnGetStatueList) -- 获取雕像列表 NetManager.RegisterMsgCB(MessageEnums.MessageGetWorShipReward, private.GetWorShipRewardResp) -- 领取膜拜后奖励 NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushUpdateStatueList, private.OnTryGetStatueList) -- 更新雕像信息 NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushHeroMatchSuccess, private.G2CPushHeroMatchSuccess) -- 匹配成功对阵信息推送 NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushHeroMatchBattleResult, private.G2CPushHeroMatchBattleResult) -- 对战结算协议 NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushHeroMatchPlayerInfo, private.G2CPushHeroMatchPlayerInfo) -- 推送玩家个人信息 NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushHeroMatchStageChange, private.G2CPushHeroMatchStageChange) -- 推送阶段变更信息 NetManager.RegisterMsgCB(MessageEnums.MessageHeroMatchOpen, private.HeroMatchOpenResponse) -- 获取玩法信息 NetManager.RegisterMsgCB(MessageEnums.MessageHeroMatchQuizBet, private.HeroMatchQuizBetResponse) -- 竞猜押注 NetManager.RegisterMsgCB(MessageEnums.MessageHeroMatchBattleBet, private.HeroMatchBattleBetResponse) -- 战斗押注 NetManager.RegisterMsgCB(MessageEnums.MessageHeroMatchGetAllQuizInfo, private.HeroMatchGetAllQuizInfoResponse) -- 获取竞猜信息 NetManager.RegisterMsgCB(MessageEnums.MessageHeroMatchGetAllPlayerInfo, private.HeroMatchGetAllPlayerInfoResponse) -- 请求64强玩家信息 NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushHeroMatchNeedLeave, private.G2CPushHeroMatchNeedLeave) -- 服务器推送退出场景 end function private.RefreshUnLockFunc(funcID, isUnlock) if funcID == MDL.Unlock.FunctionType.HeroMatch1v1 then if not isUnlock then private.ActiveEndCloseViewFunc() end end end function private.ActiveEndCloseViewFunc() UIManager.CloseView(Const_UI_Lua.UIEnum.UIWarzoneList) UIManager.CloseView(Const_UI_Lua.UIEnum.UICommonNoteView) UIManager.CloseView(Const_UI_Lua.UIEnum.UIHeroMatch1v1Store) EventSystem.Dispatch(EventID.UI_HeroMatch1v1_CloseView) end --region ******************* 外界获取数据接口 ******************* function HeroMatch1v1_Model.IsCurActivityInOpenTime() if HeroMatch1v1_Model.GetCurMatchTimeID() == 0 then return false end local MatchTime = DataSheetManager.MatchTime:GetDataByID(HeroMatch1v1_Model.GetCurMatchTimeID()) return private.MatchAllInfo.curTitle >= MDL.HeroMatch1v1.Enum_BigStage.Screening and private.MatchAllInfo.curTitle <= MDL.HeroMatch1v1.Enum_BigStage.Finals and UTL.Time.IsServerInOpeningTime(MatchTime.StartTime, MatchTime.EndTime) end ---@return boolean 活动是否开启 function HeroMatch1v1_Model.IsShowHeroMatch1v1Entry() return MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HeroMatch1v1) and private.MatchAllInfo.seasonId > 0 and UTL.Time.GetServerTimestamp() - private.MatchAllInfo.startTm >= 5 * UTL.Time.TotalSecondsOneMinute end function HeroMatch1v1_Model.GetCurStoreTabID() return private.MatchAllInfo.storeId end ---@return table 活动总信息 function HeroMatch1v1_Model.GetHeroMatch1v1AllInfo() return private.MatchAllInfo end ---@return enum 当前赛程大阶段编号 function HeroMatch1v1_Model.GetCurMatchTimeID() return private.MatchAllInfo.curTitle or 0 end ---@return enum 当前赛程阶段ID function HeroMatch1v1_Model.GetCurStageID() return private.MatchAllInfo.curStage or 0 end ---@return number 当前赛季编号 function HeroMatch1v1_Model.GetCurSeasonID() return private.MatchAllInfo.seasonId or 0 end ---@return table 当前比赛个人参赛信息 function HeroMatch1v1_Model.GetMyMatchInfo() return private.MyMatchInfo end ---@return 指定比赛阶段对战信息 function HeroMatch1v1_Model.GetMatchStageInfo(stageId) return private.HeroMatch1v1Info[stageId] end ---@return 自己当前最高阶段 function HeroMatch1v1_Model.GetMyHighestStage() -- 0是参与过程中还未结束,-1表示没参加活动 local bestStage = private.MyMatchInfo.myStage or -1 if bestStage == 0 then if private.MatchAllInfo.curStage == MDL.HeroMatch1v1.Stage.match_2T1 then return MDL.HeroMatch1v1.Stage.match_4T2 else return private.MatchAllInfo.curStage end else return bestStage end end ---@return int 返回大战区分组ID function HeroMatch1v1_Model.GetActivityWarZoneGroupID() return private.MatchAllInfo.groupId end ---@public number 获取膜拜剩余次数 function HeroMatch1v1_Model.GetCurDayWorshipCount() return WORSHIP_COUNT_BYDAY - private.worshipRewardCount end ---@return table 获取话题竞猜数据 function HeroMatch1v1_Model.GetHeroMatch1v1GuessingInfo() local guessingInfo = {} for _, guessCfg in DataSheetManager.MatchTalkGuess:GetEnumerator() do for _, guessServer in pairs(private.MatchGuessingInfo) do if guessServer.questionId == guessCfg.ID then table.insert(guessingInfo, { serverInfo = guessServer, guessCfg = guessCfg }) break end end end table.sort(guessingInfo, GuessingSort) return guessingInfo end ---@return ipairs 商城展示商品 function HeroMatch1v1_Model.GetStoreGoodsEnumerator() local goods = {} local tabID = HeroMatch1v1_Model.GetCurStoreTabID() for _, v in MDL.OperationActivity.StoreGoodsData:GetEnumerator() do if v.TabID == tabID then table.insert(goods, v) end end return ipairs(goods) end ---@return table 检查是否竞猜了该选手 function HeroMatch1v1_Model.CheckIsGuessByGroupID_ACID(groupId, acid) for k, v in ipairs(private.MyMatchInfo.betInfo) do if v.groupId == groupId and v.betAcid == acid then return true end end return false end ---@return table 获取玩家头像信息 function HeroMatch1v1_Model.GetPlayerInfoByACID(acid) if acid ~= "" then return private.MatchAllPlayerInfo[acid] end return nil end ---@return table 检查是否处在比赛阶段 function HeroMatch1v1_Model.CheckIsBattleStage() local curMatchTimeID = HeroMatch1v1_Model.GetCurMatchTimeID() return HeroMatch1v1_Model.IsShowHeroMatch1v1Entry() and curMatchTimeID > HeroMatch1v1_Model.Enum_BigStage.Advance and curMatchTimeID < HeroMatch1v1_Model.Enum_BigStage.Display end ---@return number 活动开启后,获取距离活动结束的时间 function HeroMatch1v1_Model.GetTimeToClose() local MatchTime = DataSheetManager.MatchTime:GetDataByID(HeroMatch1v1_Model.GetCurMatchTimeID()) local closeTime = 0 local offsetTime = UTL.Time.GetServerIntervalTimeByTimeId(MatchTime.EndTime) if offsetTime > 0 then if closeTime == 0 then closeTime = offsetTime elseif closeTime > offsetTime then closeTime = offsetTime end end return closeTime end ---@return number 自己所在的分组 function HeroMatch1v1_Model.GetMyGroupAndIndex(stageID) local groupNum = 1 for group, groupInfo in ipairs(private.HeroMatch1v1Info[stageID].groupInfos) do for _, playerInfo in ipairs(groupInfo.playerInfos) do if playerInfo.acid == BattleDataGetter.GetAcID() then local groupCount = #private.HeroMatch1v1Info[stageID].groupInfos / 4 groupNum = math.ceil(group / groupCount) break end end end return groupNum end function HeroMatch1v1_Model.GetCurCountryId() if private.curCountryIdArray == nil then return 0 end return MDL.FreeLineUp.GetMultiCountryId(private.curCountryIdArray) end --该国家武将数量是否足够 function HeroMatch1v1_Model.IsCountryHeroEnough() local sumCount = 0 for i, v in ipairs(private.curCountryIdArray) do sumCount = sumCount + MDL.HeroSelect.GetHasCountryHeroCount(v) end return sumCount >= CONST_COUNTRY_HERO_COUNT end function HeroMatch1v1_Model.GetCurCountryDesc() local linkSym if Localization.IsAllChinese() then linkSym = "、" else linkSym = ", " end local desc = "" for i, v in ipairs(private.curCountryIdArray) do if i == 1 then desc = CTL.Country.GetCountryFullName(v) else desc = desc .. linkSym .. CTL.Country.GetCountryFullName(v) end end return desc end --endregion ******************* 外界获取数据接口 ******************* --region ******************* 交互协议 **************************** function private.SetMatchInfo(info, myInfo) if myInfo then logging.log(LTAG.LOG, "[gyy ]推送个人信息 : ", myInfo) private.MyMatchInfo = myInfo end if info then private.curCountryIdArray = info.countryId private.MatchAllInfo = info private.InitDelayOpenEntryTimer() if info.stageInfos then for _, matchInfo in ipairs(info.stageInfos) do --logging.log(LTAG.LOG, "[gyy ]比赛各阶段详细信息 : ", matchInfo) private.HeroMatch1v1Info[matchInfo.stageId] = matchInfo end end if private.MatchAllInfo.seasonId == 0 then private.ActiveEndCloseViewFunc() end end EventSystem.Dispatch(EventID.UI_HeroMatch1v1_RefreshInfo) end function private.InitDelayOpenEntryTimer() if private.delayOpenEntryTimer then return end local time = private.MatchAllInfo.startTm + 5 * UTL.Time.TotalSecondsOneMinute - UTL.Time.GetServerTimestamp() + 1 if time > 0 then private.delayOpenEntryTimer = TimerUtil.Interval(function() private.delayOpenEntryTimer = nil EventSystem.Dispatch(EventID.UI_HeroMatch1v1_RefreshInfo) end, time, 1) end end ---@public 登录推送比赛数据 function HeroMatch1v1_Model.SyncHeroMatch1v1Info(msgResp) --logging.log(LTAG.LOG, "[gyy]登录推送秘闻数据 : ", msgResp) if msgResp then private.SetMatchInfo(msgResp, nil) -- 红点 if HeroMatch1v1_Model.GetCurMatchTimeID() >= MDL.HeroMatch1v1.Enum_BigStage.Screening and HeroMatch1v1_Model.GetCurMatchTimeID() <= MDL.HeroMatch1v1.Enum_BigStage.Finals then local MatchTime = DataSheetManager.MatchTime:GetDataByID(HeroMatch1v1_Model.GetCurMatchTimeID()) if UTL.Time.IsServerInOpeningTime(MatchTime.StartTime, MatchTime.EndTime) then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.HeroMatch1v1_Login) end _townHomeRPTimerHandle = TimerUtil.Interval(private.UpdateTownHomeRP, 1, 1) end end end ---@public 推送阶段变更推送 function private.G2CPushHeroMatchStageChange(msgResp) --logging.log(LTAG.LOG, "[gyy]推送阶段变更推送 : ", msgResp) if msgResp and msgResp.info.seasonId > 0 then private.SetMatchInfo(msgResp.info, nil) if private.lastStageID > 0 and BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown) then if private.HeroMatch1v1Info[private.lastStageID] and private.HeroMatch1v1Info[private.lastStageID].state == 4 then CTL.HeroMatch1v1.OpenHeroMatch1v1MainView() MDL.HeroMatch1v1.HeroMatchGetAllPlayerInfoRequest() end end private.lastStageID = private.MatchAllInfo.curStage CTL.HeroMatch1v1.RefreshWorshipRed() elseif msgResp.info.seasonId == 0 then private.MatchAllInfo.seasonId = 0 private.ActiveEndCloseViewFunc() EventSystem.Dispatch(EventID.UI_HeroMatch1v1_RefreshInfo) end end ---@public 推送个人信息 function private.G2CPushHeroMatchPlayerInfo(msgResp) logging.log(LTAG.LOG, "[gyy]推送个人信息 : ", msgResp) if msgResp then private.SetMatchInfo(nil, msgResp.myInfo) end end ---@public 登陆更新膜拜信息 function HeroMatch1v1_Model.SyncHeroMatchWorshipInfo(msgResp) if msgResp.rewardCount then private.worshipRewardCount = msgResp.rewardCount CTL.HeroMatch1v1.RefreshWorshipRed() end end ---@private 推送匹配成功对阵信息 function private.G2CPushHeroMatchSuccess(msgResp) local battleMatchResult = {} if msgResp.showInfo1.acid == BattleDataGetter.GetAcID() then battleMatchResult.showInfo1 = msgResp.showInfo1 battleMatchResult.showInfo2 = msgResp.showInfo2 battleMatchResult.lineUpHeroIds1 = msgResp.lineUpHeroIds1 battleMatchResult.lineUpHeroAwakens1 = msgResp.lineUpHeroAwakens1 battleMatchResult.lineUpHeroIds2 = msgResp.lineUpHeroIds2 battleMatchResult.lineUpHeroAwakens2 = msgResp.lineUpHeroAwakens2 else battleMatchResult.showInfo1 = msgResp.showInfo2 battleMatchResult.showInfo2 = msgResp.showInfo1 battleMatchResult.lineUpHeroIds1 = msgResp.lineUpHeroIds2 battleMatchResult.lineUpHeroAwakens1 = msgResp.lineUpHeroAwakens2 battleMatchResult.lineUpHeroIds2 = msgResp.lineUpHeroIds1 battleMatchResult.lineUpHeroAwakens2 = msgResp.lineUpHeroAwakens1 end UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroMatch1v1MatchPanel, battleMatchResult) end ---@private 结算协议推送 function private.G2CPushHeroMatchBattleResult(msgResp) if BattleDataGetter.IsInLevelWatchBattle() and not BattleDataGetter.HadStopLevel() then private.watchBattleSummary = msgResp else private.OnG2CPushHeroMatchBattleResult(msgResp) end end function private.OnG2CPushHeroMatchBattleResult(msgResp) private.cacheBattleSummary = msgResp if msgResp.winnerCampId < 0 then -- 当前比赛轮空 private.ShowFilterRewardsPanel(msgResp.Rewards) else CTL.HomeMain.CloseOpenView() EventSystem.Regist(EventID.UI_HeroMatch1v1_OnShowBattleSummary, private.ShowBattleResult) if #msgResp.Rewards > 0 then private.ShowFilterRewardsPanel(msgResp.Rewards) else private.ShowBattleResult() end end end --- battleResult { --- isWin = true, --- LeftInfo = { campID = 0, BattleResult = {}, PlayerInfo}, --- RightInfo = { campID = 0, BattleResult = {}, PlayerInfo} ---} ---@param result table 结算结果内容 ---@return 获取左右对战结算结果 function private.ShowBattleResult() EventSystem.UnRegist(EventID.UI_HeroMatch1v1_OnShowBattleSummary, private.ShowBattleResult) local result = private.cacheBattleSummary local battleResult = {} local isWin = BattleDataGetter.GetMyCampID() == result.winnerCampId and true or false local LeftInfo, RightInfo, playerLeftInfo, playerRightInfo = {}, {}, nil, nil if BattleDataGetter.GetCurPlayerID() == result.camp1PlayerId then LeftInfo.BattleResult = result.camp1 playerLeftInfo = BattleDataGetter.GetPlayerInfo(result.camp1PlayerId) LeftInfo.PlayerInfo = playerLeftInfo LeftInfo.campID = playerLeftInfo.campID LeftInfo.score = result.camp1Score RightInfo.BattleResult = result.camp2 playerRightInfo = BattleDataGetter.GetPlayerInfo(result.camp2PlayerId) RightInfo.PlayerInfo = playerRightInfo RightInfo.campID = playerRightInfo.campID RightInfo.score = result.camp2Score else LeftInfo.BattleResult = result.camp2 playerLeftInfo = BattleDataGetter.GetPlayerInfo(result.camp2PlayerId) LeftInfo.PlayerInfo = playerLeftInfo LeftInfo.campID = playerLeftInfo.campID LeftInfo.score = result.camp2Score RightInfo.BattleResult = result.camp1 playerRightInfo = BattleDataGetter.GetPlayerInfo(result.camp1PlayerId) RightInfo.PlayerInfo = playerRightInfo RightInfo.campID = playerRightInfo.campID RightInfo.score = result.camp1Score end battleResult = { isWin = isWin, LeftInfo = LeftInfo, RightInfo = RightInfo, } UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroMatch1v1Summary, battleResult) end function private.ShowFilterRewardsPanel(rewardList) UIManager.OpenView( Const_UI_Lua.UIEnum.UIRewardGainPanel, { tipsIDS = "IDS_HeroMatch1v1_RewardTips", topContentIDS = "IDS_HeroMatch1v1_JoinReward", duration = 3, itemList = rewardList } ) end ---@public 请求全部比赛信息 function HeroMatch1v1_Model.HeroMatchOpenRequest() local msg = hero_match_1v1_opt_pb.HeroMatchOpenReq() NetManager.SendMessage(MessageEnums.MessageHeroMatchOpen, msg) end function private.HeroMatchOpenResponse(msgResp) logging.log(LTAG.LOG, "[gyy]请求全部比赛信息 : ", msgResp.info.info.curStage) if msgResp.Resp.Code <= 0 then private.SetMatchInfo(msgResp.info.info, msgResp.info.myInfo) end end ---@public 请求64强玩家信息 function HeroMatch1v1_Model.HeroMatchGetAllPlayerInfoRequest() local msg = hero_match_1v1_opt_pb.HeroMatchGetAllPlayerInfoReq() NetManager.SendMessage(MessageEnums.MessageHeroMatchGetAllPlayerInfo, msg) end function private.HeroMatchGetAllPlayerInfoResponse(msgResp) --logging.log(LTAG.LOG, "[gyy]请求64强玩家信息 : ", msgResp) for k,v in ipairs(msgResp.infos) do private.MatchAllPlayerInfo[v.acid] = v.showInfo end EventSystem.Dispatch(EventID.UI_HeroMatch1v1_RefreshPlayerInfo) end ---@public 膜拜奖励完成领奖 function HeroMatch1v1_Model.GetWorShipRewardReq() local msg = hero_match_1v1_opt_pb.GetWorShipRewardReq() NetManager.SendMessage(MessageEnums.MessageGetWorShipReward, msg) end function private.GetWorShipRewardResp(msgResp) if msgResp.Resp.Code == 0 then -- 膜拜成功 发送喊话 CTL.ChannelChat.SendTextMsg( UIUtils.GetLocalizedTxt(Const_IDS["IDS_HeroMatch1v1_SeeWord"]), MDL.ChannelChat.GetChannelIdByCfgID(MDL.ChannelChat.ChannelCfgId.Current), nil, chat_pb.Room ) end end --请求获取雕像列表 function HeroMatch1v1_Model.GetStatueReq() local msg = hero_match_1v1_opt_pb.GetWorShipRewardReq() NetManager.SendMessage(MessageEnums.MessageGetStatueList, msg) end --获得到雕像列表 function private.OnGetStatueList(msgResp) if msgResp.Resp.Code == 0 then CTL.HeroMatch1v1.RefreshStatueList(msgResp.BasicInfo, msgResp.canWorship) end end -- 服务器让我向它请求列表 function private.OnTryGetStatueList(msgResp) local curLevelID = BattleDataGetter.GetLevelID() local statueData = CTL.HeroMatch1v1.GetStatueConfig(curLevelID) if statueData then -- 删除旧的雕像 CTL.HeroMatch1v1.ClearStatues(true) if msgResp.opt == 1 then -- 拉取最新雕像 HeroMatch1v1_Model.GetStatueReq() end end end --- 服务器推送退出场景 function private.G2CPushHeroMatchNeedLeave() logging.log(LTAG.LOG, "G2CPushHeroMatchNeedLeave") CTL.HeroMatch1v1.QuitFromMatchLobby(true) end --region ********************** 竞猜协议 ***************** ---@public 请求全部竞猜题目信息 function HeroMatch1v1_Model.HeroMatchGetAllQuizInfoRequest() local msg = hero_match_1v1_opt_pb.HeroMatchGetAllQuizInfoReq() NetManager.SendMessage(MessageEnums.MessageHeroMatchGetAllQuizInfo, msg) end ---@public 请求全部竞猜题目信息 function private.HeroMatchGetAllQuizInfoResponse(msgResp) --logging.log(LTAG.LOG, "请求全部竞猜题目信息 : ", msgResp) for k,v in ipairs(msgResp.quizInfo) do private.MatchGuessingInfo[v.questionId] = v end EventSystem.Dispatch(EventID.UI_HeroMatch1v1_RefreshGuessing) end ---@public 胜负押注 function HeroMatch1v1_Model.HeroMatchBattleBetRequest(stageId, groupId, betAcid) local msg = hero_match_1v1_opt_pb.HeroMatchBattleBetReq() msg.stageId = stageId msg.groupId = groupId msg.betAcid = betAcid NetManager.SendMessage(MessageEnums.MessageHeroMatchBattleBet, msg) end ---@public 胜负押注 function private.HeroMatchBattleBetResponse(msgResp) --logging.log(LTAG.LOG, "胜负押注 : ", msgResp.myInfo) if msgResp.Resp.Code <= 0 then private.SetMatchInfo(nil, msgResp.myInfo) EventSystem.Dispatch(EventID.UI_HeroMatch1v1_RefreshInfo) end end ---@public 竞猜押注 function HeroMatch1v1_Model.HeroMatchQuizBetRequest(questionId, optionId, betNum) local msg = hero_match_1v1_opt_pb.HeroMatchQuizBetReq() msg.questionId = questionId msg.optionId = optionId msg.betNum = betNum NetManager.SendMessage(MessageEnums.MessageHeroMatchQuizBet, msg) end ---@public 竞猜押注 function private.HeroMatchQuizBetResponse(msgResp) --logging.log(LTAG.LOG, "竞猜押注 : ", msgResp) for k,v in ipairs(msgResp.quizInfo) do private.MatchGuessingInfo[v.questionId] = v end EventSystem.Dispatch(EventID.UI_HeroMatch1v1_RefreshGuessing) end --endregion ********************** 竞猜协议 ***************** --endregion ******************* 交互协议 **************************** function private.SendBattleResult(msg) NetManager.SendMessage(MessageEnums.MessageC2GUploadHeroMatchBattleResult, msg) end function private.OnWatchBattleOver(isClickExitBtn) if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncUnfairSolo) then if private.watchBattleSummary then private.OnG2CPushHeroMatchBattleResult(private.watchBattleSummary) private.watchBattleSummary = nil else if not isClickExitBtn then-- 是否是按下退出按钮退出 。处理case:关卡结束时不是玩家点击退出而是自然看完且未收到服务器的战斗结果,此时不能被卡在关卡内要主动离开。 EventSystem.Dispatch(EventID.Level_SendRoleLeaveFuben ,true) end end end end function private.UpdateTownHomeRP() if _townHomeRPTimerHandle then TimerUtil.Remove(_townHomeRPTimerHandle) _townHomeRPTimerHandle = nil end local curMatchTimeID = MDL.HeroMatch1v1.GetCurMatchTimeID() if curMatchTimeID >= MDL.HeroMatch1v1.Enum_BigStage.Screening and curMatchTimeID <= MDL.HeroMatch1v1.Enum_BigStage.Finals then local MatchTime = DataSheetManager.MatchTime:GetDataByID(curMatchTimeID) if UTL.Time.IsServerInOpeningTime(MatchTime.StartTime, MatchTime.EndTime) then if not MDL.HeroMatch1v1.IsOpenMainPanel then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.HeroMatch1v1_Login) end _townHomeRPTimerHandle = TimerUtil.Interval(private.UpdateTownHomeRP, UTL.Time.GetServerIntervalTimeByTimeId(MatchTime.StartTime) + UTL.Time.TotalSecondsOneDay, 1) else _townHomeRPTimerHandle = TimerUtil.Interval(private.UpdateTownHomeRP, UTL.Time.GetServerIntervalTimeByTimeId(MatchTime.StartTime), 1) end end end return HeroMatch1v1_Model