--[[ 天下会武3V3 ]] local EventSystem = require('Event/EventSystem') local TeamFairChampionshipToalMatchInfo = require "Modules.TeamFairChampionship.TeamFairChampionshipToalMatchInfo" local TeamFairChampionshipMyMatchInfo = require "Modules.TeamFairChampionship.TeamFairChampionshipMyMatchInfo" local TeamFairChampionship_Model = {} local private = {} TeamFairChampionship_Model.Enum_State = { Ready = 1, -- 准备阶段 Matching = 2, -- 匹配阶段 Roll = 3, --掷骰子 BanPick = 4, --禁选武将 Battle = 5, -- 战斗阶段 Finish = 6, -- 活动结束 } TeamFairChampionship_Model.Enum_BigStage = { Advance = 1, -- 报名阶段 Screening = 2, -- 筛选赛阶段 Rank = 3, -- 排名赛阶段 Finals = 4, -- 决赛阶段 Display = 5, -- 展示阶段 } --任务状态枚举 TeamFairChampionship_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 -- 未来可能扩展赛程 } TeamFairChampionship_Model.BanPickState = { None = 0, Dice = 1, -- 掷骰子 Show = 2, -- 掷骰子展示 Ban1 = 3, Ban2 = 4, Pick1_2 = 5, -- 先手选2 Pick2_4 = 6, -- 后手选4 Pick1_4 = 7, -- 先手选4 Pick2_2 = 8, -- 后手选2 Change = 9, -- 调整 Finish = 10, -- 倒计时 } function TeamFairChampionship_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushTeamFairStageChange, private.OnG2CPushTeamFairStageChange) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushTeamBanPickInfoNotify, private.OnG2CPushTeamBanPickInfoNotify) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushTeamFairBPInfo, private.OnG2CPushTeamFairBPInfo) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushTeamFairNeedLeave, private.OnG2CPushTeamFairNeedLeave) NetManager.RegisterMsgCB(MessageEnums.MessageG2CTeamFairGroupStateChangeNotify, private.OnG2CTeamFairGroupStateChangeNotify) NetManager.RegisterMsgCB(MessageEnums.MessageG2CTeamFairStageInfoChangeNotify, private.OnG2CTeamFairStageInfoChangeNotify) NetManager.RegisterMsgCB(MessageEnums.MessageG2CFairClassTeamInfosChangeMsg, private.OnG2CFairClassTeamInfosChangeMsg) NetManager.RegisterMsgCB(MessageEnums.MessageG2CTeamFairForceWinRewardMsg, private.OnG2CTeamFairForceWinRewardMsg) NetManager.RegisterMsgCB(MessageEnums.MessageG2CTeamFairTaskHasRewardMsg, private.OnG2CTeamFairTaskHahRewardMsg) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairGetAllPlayerInfo, private.TeamFairGetAllPlayerInfoResp) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairGetClassTeamInfo, private.TeamFairGetClassTeamInfoResp) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairOpen, private.TeamFairOpenResp) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairBattleBet, private.TeamFairBattleBetResp) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairBPWatch, nil) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairGetAllQuizInfo, private.OnTeamFairGetAllQuizInfoResp) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairTaskInfo, private.OnTeamFairTaskInfoResp) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairTaskReward, private.OnTeamFairTaskRewardResp) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairQuizBet, private.OnTeamFairQuizBetResp) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairGetWatchBattleInfo, private.OnTeamFairGetWatchBattleInfoResp) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairThumbsUp, private.OnTeamFairThumbsUpResp) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairGetStageInfo, private.TeamFairGetStageInfoResp) NetManager.RegisterMsgCB(MessageEnums.MessageTeamFairGetFamous, private.TeamFairGetFamousResp) EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshUnLockFunc) private.totalMatchAllInfo = TeamFairChampionshipToalMatchInfo:new() -- 赛季总数据 private.myMatchInfo = TeamFairChampionshipMyMatchInfo:new() -- 自己的参赛数据,在不同阶段需要判断自己是否进入了当前赛程 private.matchGuessingInfo = {} -- 所有竞猜信息 private.matchAllPlayerInfo = {} -- 参赛玩家信息 private.matchGroupTeamInfo = {} -- 队伍的比赛场输赢数量信息 private.hasGetAllPlayerInfo = false -- 已经获取了全部的玩家显示信息 private.curBattleMatchGroup = nil -- 当前正在战斗或者玩家观战的组 end function private.RefreshUnLockFunc(funcID, isUnlock) if funcID == MDL.Unlock.FunctionType.TeamFairChampionship then if not isUnlock then CTL.TeamFairChampionship.OnTotalMatchOver() EventSystem.Dispatch(EventID.UI_TeamFairChampionship_RefreshInfo) end end end -- 上线初始化赛制信息 function TeamFairChampionship_Model.InitTeamFairChampionshipInfo(teamFairInitInfo) private.SetTotalMatchInfo(teamFairInitInfo) private.myMatchInfo:SetMyServerMatchInfo(teamFairInitInfo.myTeamInfo) CTL.TeamFairChampionship.SetTaskRed(teamFairInitInfo.hasTaskReward) end function private.OnG2CTeamFairGroupStateChangeNotify(msgNotify) private.totalMatchAllInfo:UpdateMatchGroupInfo(msgNotify.stageId, msgNotify.ChangeGroupInfo, 0) EventSystem.Dispatch(EventID.UI_TeamFairChampionship_RefreshOneStage, msgNotify.stageId, 0) if CTL.TeamFairChampionship.IsFilterMatchStage() then MDL.TeamFairChampionship.TeamFairGetStageInfoReq(msgNotify.stageId) end end --赛制未开始到开始,或者开始到结束的推送 function private.OnG2CPushTeamFairStageChange(msgNotify) TeamFairChampionship_Model.InitTeamFairChampionshipInfo(msgNotify.info) EventSystem.Dispatch(EventID.UI_TeamFairChampionship_RefreshInfo) end function private.OnG2CTeamFairTaskHahRewardMsg(msgNotify) CTL.TeamFairChampionship.SetTaskRed(true) end --大赛段或者小赛段改变 function private.OnG2CTeamFairStageInfoChangeNotify(msgNotify) local lastStage = TeamFairChampionship_Model.GetCurStageID() private.totalMatchAllInfo:UpdateMatchStageInfo(msgNotify.changeInfo) EventSystem.Dispatch(EventID.UI_TeamFairChampionship_RefreshInfo) if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.TeamFairChampionshipTown) and TeamFairChampionship_Model.GetCurStageID() == TeamFairChampionship_Model.Stage.ShowHero and lastStage == TeamFairChampionship_Model.Stage.match_2T1 then CTL.TeamFairChampionship.OpenMainPanel() end logging.crit(LTAG.CRIT, "TeamFairChampionship_Model.OnG2CTeamFairStageInfoChangeNotify", lastStage, TeamFairChampionship_Model.GetCurStageID()) end --打开界面请求比赛信息 function TeamFairChampionship_Model.TeamFairOpenReq() local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairOpenReq() NetManager.SendMessage(MessageEnums.MessageTeamFairOpen, msg) end function private.TeamFairOpenResp(msgResp) if msgResp.Resp.Code == 0 then private.myMatchInfo:SetMyServerMatchInfo(msgResp.myInfo) EventSystem.Dispatch(EventID.UI_TeamFairChampionship_RefreshMyMatchInfo) end end function TeamFairChampionship_Model.GetMyMatchInfo() return private.myMatchInfo end function TeamFairChampionship_Model.GetMyTeamId() return private.myMatchInfo.serverInfo.myTeamId end function TeamFairChampionship_Model.GetMyFilterGroupId() return private.myMatchInfo.serverInfo.classId end function TeamFairChampionship_Model.GetMyFilterGroupRank() return private.myMatchInfo.serverInfo.myIndex end --获取竞猜信息 function TeamFairChampionship_Model.GetMatchGroupTeamBetInfo(betStageId, betMatchGroupId, betTeamId) return private.myMatchInfo:GetTeamBetInfo(betStageId, betMatchGroupId, betTeamId) end function TeamFairChampionship_Model.GetGroupBetInfo(betStageId, betMatchGroupId, betGroupId) return private.myMatchInfo:GetGroupBetInfo(betStageId, betMatchGroupId, betGroupId) end function private.SetTotalMatchInfo(info) local lastMatchId = private.totalMatchAllInfo.serverInfo.curMatchId or 0 private.totalMatchAllInfo:SetServerInfo(info) local curMatchId = private.totalMatchAllInfo.serverInfo.curMatchId if lastMatchId==0 and curMatchId>0 then MDL.SpecialTeam.SetSpecialTeamType(MDL.Unlock.FunctionType.TeamFairChampionship) elseif lastMatchId>0 and curMatchId==0 then --活动结束了,需要做处理 CTL.TeamFairChampionship.OnTotalMatchOver() elseif lastMatchId>0 and curMatchId>0 then --因为断线可能会丢失一部分推送消息,因此重连的时候请求一下当前stage的信息 MDL.TeamFairChampionship.TeamFairGetStageInfoReq(TeamFairChampionship_Model.GetCurStageID()) end if curMatchId>0 then logging.crit(LTAG.CRIT, "TeamFairChampionship_Model.SetTotalMatchInfo", private.totalMatchAllInfo.serverInfo.startTm, private.totalMatchAllInfo.serverInfo.curMatchId) end end function TeamFairChampionship_Model.GetEnterMatchTeamCount() return private.totalMatchAllInfo.serverInfo.enterMatchTeamCount end --小组赛前几晋级 function TeamFairChampionship_Model.GetEnterEachGroup() return private.totalMatchAllInfo.serverInfo.enterEachGroup end function TeamFairChampionship_Model.GetMatchStartTime() return private.totalMatchAllInfo.serverInfo.startTm end function TeamFairChampionship_Model.GetBigMatchStartTime(bigMatchStageId) return private.totalMatchAllInfo:GetBigMatchStartTime(bigMatchStageId) end function TeamFairChampionship_Model.GetBigMatchZeroStartTime(bigMatchStageId) return UTL.Time.GetServerZeroTimestampByTimestamp(TeamFairChampionship_Model.GetBigMatchStartTime(bigMatchStageId)) end function TeamFairChampionship_Model.GetMatchStageInfo(stageId) return private.totalMatchAllInfo:GetMatchStageInfo(stageId) end function TeamFairChampionship_Model.GetCurMatchStageState() return private.totalMatchAllInfo:GetCurMatchStageState() end function TeamFairChampionship_Model.GetMatchFilterGroupNum() return private.totalMatchAllInfo.serverInfo.groupNum end function TeamFairChampionship_Model.GetCurBigStageID() return private.totalMatchAllInfo.serverInfo.curMatchId end function TeamFairChampionship_Model.GetStoreId() return private.totalMatchAllInfo.serverInfo.storeId end --todo 当前阶段枚举 function TeamFairChampionship_Model.GetCurStageID() return private.totalMatchAllInfo.serverInfo.curStage end --当前第几赛季 function TeamFairChampionship_Model.GetCurSeasonID() return private.totalMatchAllInfo.serverInfo.seasonId end ---@return table 获取话题竞猜数据 function TeamFairChampionship_Model.GetGuessingInfo() return private.matchGuessingInfo end function TeamFairChampionship_Model.GetTaskInfo() return private.taskInfoArray end --0:未参赛 -1:参与中 >0:对应阶段id,表示参赛止步于当前阶段 function TeamFairChampionship_Model.GetMyHighestStage() return private.myMatchInfo.serverInfo.myStage end --按stageId请求信息 function TeamFairChampionship_Model.TeamFairGetStageInfoReq(targetStageId) local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairGetStageInfoReq() msg.stage = targetStageId NetManager.SendMessage(MessageEnums.MessageTeamFairGetStageInfo, msg) end function TeamFairChampionship_Model.GetMyStageMatchGroupIndex(stageId) return private.totalMatchAllInfo.myStageMatchGroupArr[stageId] or 0 end function private.TeamFairGetStageInfoResp(msgResp) if msgResp.Resp.Code == 0 then if msgResp.info.stageId>0 then private.totalMatchAllInfo:SetServerMatchStageInfo(msgResp.info, msgResp.myMatchGroupId) CTL.TeamFairChampionship.InitTeamFairChampionshipData() EventSystem.Dispatch(EventID.UI_TeamFairChampionship_RefreshOneStage, msgResp.info.stageId, msgResp.myMatchGroupId) end end end --请求所有参赛玩家信息 function TeamFairChampionship_Model.TeamFairGetAllPlayerInfoReq() if not hasGetAllPlayerInfo then local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairGetAllPlayerInfoReq() NetManager.SendMessage(MessageEnums.MessageTeamFairGetAllPlayerInfo, msg) end end function private.TeamFairGetAllPlayerInfoResp(msgResp) if msgResp.Resp.Code == 0 then private.hasGetAllPlayerInfo = true for __, showInfo in ipairs(msgResp.infos) do private.matchAllPlayerInfo[showInfo.acid] = showInfo end EventSystem.Dispatch(EventID.UI_TeamFairChampionship_AllPlayerInfo) end end function TeamFairChampionship_Model.GetPlayerInfoByACID(acid) return private.matchAllPlayerInfo[acid] end -----------------------------天下会武小组赛----------------------------------------------- --获取小组赛队伍比赛结果输赢次数 function TeamFairChampionship_Model.TeamFairGetClassTeamInfoReq() local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairGetClassTeamInfoReq() NetManager.SendMessage(MessageEnums.MessageTeamFairGetClassTeamInfo, msg) end function private.OnG2CFairClassTeamInfosChangeMsg(msgNotify) for __, serverClassPlayerInfo in ipairs(msgNotify.infos) do private.matchGroupTeamInfo[serverClassPlayerInfo.teamId] = serverClassPlayerInfo end EventSystem.Dispatch(EventID.UI_TeamFairChampionship_MatchGroupTeamInfo) end function private.TeamFairGetClassTeamInfoResp(msgResp) if msgResp.Resp.Code == 0 then for __, serverClassPlayerInfo in ipairs(msgResp.infos) do private.matchGroupTeamInfo[serverClassPlayerInfo.teamId] = serverClassPlayerInfo end EventSystem.Dispatch(EventID.UI_TeamFairChampionship_MatchGroupTeamInfo) end end function TeamFairChampionship_Model.GetMatchGroupTeamInfoByTeamId(teamId) return private.matchGroupTeamInfo[teamId] end function TeamFairChampionship_Model.SetSeasonPlayerValue(name, value) local localPlayerDict = private.GetCurSeasonPlayerDict() localPlayerDict[name] = value PersistentData.PlayerData:Set("TEAMFAIR_PLAYERDATA", localPlayerDict, true) end function TeamFairChampionship_Model.GetSeasonPlayerValue(name) local localPlayerDict = private.GetCurSeasonPlayerDict() return localPlayerDict[name] end function private.GetCurSeasonPlayerDict() if private.localPlayerDict == nil then private.localPlayerDict = PersistentData.PlayerData:Get("TEAMFAIR_PLAYERDATA", {}) if private.localPlayerDict.seasonId and private.localPlayerDict.seasonId ~= TeamFairChampionship_Model.GetCurSeasonID() then table.clear(private.localPlayerDict) private.localPlayerDict.seasonId = TeamFairChampionship_Model.GetCurSeasonID() end end return private.localPlayerDict end --请求进入匹配场景 function TeamFairChampionship_Model.TryEnterBattleMatchLobby() if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.TeamFairChampionshipTown) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_BeInScene) return false end CTL.MiniMap.GoToMap(630001) return true end --请求竞猜 function TeamFairChampionship_Model.TeamFairBattleBetReq(stageId, matchGroupId, groupId, betTeamId, betNum) local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairBattleBetReq() msg.stageId = stageId -- msg.matchGroupId = matchGroupId msg.groupId = groupId msg.betTeamId = betTeamId msg.betNum = betNum NetManager.SendMessage(MessageEnums.MessageTeamFairBattleBet, msg) end function private.TeamFairBattleBetResp(msgResp) if msgResp.Resp.Code == 0 then private.myMatchInfo:UpdateMyBetInfo(msgResp.battleBetNum, msgResp.betInfo) EventSystem.Dispatch(EventID.UI_TeamFairChampionship_BattleBet) end end -------------------------------战斗Roll和BP-------------------------------------- function private.OnG2CTeamFairForceWinRewardMsg(msgNotify) UIManager.OpenView(Const_UI_Lua.UIEnum.UIRewardGainPanel, { tipsIDS = "IDS_HeroMatch3v3_RewardTips", topContentIDS = "IDS_HeroMatch3v3_JoinReward", duration = 3, itemList = msgNotify.Rewards, } ) end function private.OnG2CPushTeamFairNeedLeave(msgNotify) if msgNotify.isBye then local watchParam = TeamFairChampionship_Model.GetWatchParam() if watchParam and watchParam.watchGroupId == msgNotify.groupId then --观战者 UIManager.CloseView(Const_UI_Lua.UIEnum.UITeamFairChampionshipBanSelect) TeamFairChampionship_Model.ClearWatchParam() else --参赛者 CTL.Tips.AddTipsMsg(Const_IDS["IDS_FairTournament_NoOpponent"]) UIManager.CloseView(Const_UI_Lua.UIEnum.UITeamFairChampionshipBanSelect) end else CTL.Level.ConveyLevelByLevelID(CTL.Level.GetMainCityId()) end end --请求BanPick战斗状态 function TeamFairChampionship_Model.C2GTeamFairRequireBPState() local msg = NetManager.GetPB("team_fair_opt_pb").C2GTeamFairRequireBPState() NetManager.SendMessage(MessageEnums.MessageC2GTeamFairRequireBPState, msg) end function TeamFairChampionship_Model.GetCurBattleMatchGroup() return private.curBattleMatchGroup end --是否观战者,服务器发过来的战斗队伍没有自己,就是观战 function TeamFairChampionship_Model.IsTeamMatchWatcher() if private.curBattleMatchGroup.teamInfos[1].teamId == TeamFairChampionship_Model.GetMyTeamId() then return false end if private.curBattleMatchGroup.teamInfos[2].teamId == TeamFairChampionship_Model.GetMyTeamId() then return false end return true end function private.OnG2CPushTeamBanPickInfoNotify(msgResp) if msgResp.isInit then private.curBattleMatchGroup = msgResp.fightGroup for __, battlePlayerInfo in ipairs(msgResp.playerShowInfo) do private.matchAllPlayerInfo[battlePlayerInfo.acid] = battlePlayerInfo end end if msgResp.state == TeamFairChampionship_Model.BanPickState.Dice then if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UITeamFairChampionshipRoll) then UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamFairChampionshipRoll, {leftAcid=TeamFairChampionship_Model.GetMyTeamId(),stateData=msgResp}) end elseif msgResp.state >= TeamFairChampionship_Model.BanPickState.Ban1 then if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UITeamFairChampionshipBanSelect) then UIManager.CloseView(Const_UI_Lua.UIEnum.UITeamFairChampionshipRoll) if TeamFairChampionship_Model.IsTeamMatchWatcher() then UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamFairChampionshipBanSelect, {leftShowTeamId=private.watchParam.watchTeamId}) else UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamFairChampionshipBanSelect, {leftShowTeamId=TeamFairChampionship_Model.GetMyTeamId()}) end end --小组赛是盲ban if not TeamFairChampionship_Model.IsTeamMatchWatcher() and CTL.TeamFairChampionship.IsFilterMatchStage() then msgResp.opTeamId=TeamFairChampionship_Model.GetMyTeamId() table.insert(msgResp.opAcid, BattleDataGetter.GetAcID()) end end EventSystem.Dispatch(EventID.UI_TeamFairChampionship_RefreshBPState, msgResp) end function TeamFairChampionship_Model.C2GTeamFairBP(dice, banArray, pickArray) local msg = NetManager.GetPB("team_fair_opt_pb").C2GTeamFairBP() msg.GroupID = private.curBattleMatchGroup.matchGroupId msg.Dice = dice if banArray and #banArray > 0 then for i, v in ipairs(banArray) do msg.BanHero:append(v) end end if pickArray and #pickArray > 0 then for i, v in ipairs(pickArray) do local id, isAwaken = CTL.HeroAwaken.DecodeHeroId(v) msg.PickHero:append(id) msg.PickHeroAwaken:append(isAwaken) end end NetManager.SendMessage(MessageEnums.MessageC2GTeamFairBP, msg) end function private.OnG2CPushTeamFairBPInfo(msgResp) for i, info in ipairs(msgResp.BPInfo) do private.PreprocessPickHero(info) end EventSystem.Dispatch(EventID.UI_TeamFairChampionship_NoticeBPHeroInfo, msgResp.BPInfo, msgResp.BanPickState) end function private.PreprocessPickHero(info) for i, heroId in ipairs(info.PickHero) do if info.PickHeroAwaken[i] then info.PickHero[i] = CTL.HeroAwaken.EncodeHeroId(heroId) end end end --观战请求battleRoomId function TeamFairChampionship_Model.TeamFairGetWatchBattleInfoReq(teamId, isAfterBpWatch) local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairGetWatchBattleInfoReq() msg.teamId = teamId msg.AfterBpWatch = isAfterBpWatch NetManager.SendMessage(MessageEnums.MessageTeamFairGetWatchBattleInfo, msg) end function private.OnTeamFairGetWatchBattleInfoResp(msgResp) if msgResp.Resp.Code == 0 then if not string.isNilOrEmpty(msgResp.gRoomId) then MDL.WatchBattle.WatchBattleRequest(msgResp.gRoomId, MDL.WatchBattle.WatchBattleType.TeamFairChampionship, msgResp.playerIds[1], TeamFairChampionship_Model.GetCurStageID()) elseif not msgResp.AfterBpWatch then CTL.Tips.AddTipsMsg(Const_IDS["IDS_FairTournament_OutWatchTime"]) end end end --请求观战 function TeamFairChampionship_Model.TeamFairBPWatchReq(isWatch, teamId) local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairBPWatchReq() msg.teamId = teamId msg.watchType = isWatch and 1 or 2 NetManager.SendMessage(MessageEnums.MessageTeamFairBPWatch, msg) end function TeamFairChampionship_Model.SetWatchParam(watchStageId, watchMatchGroupId, groupId, teamId) private.watchParam = {watchStageId = watchStageId, watchMatchGroupId = watchMatchGroupId, watchGroupId=groupId, watchTeamId=teamId} end function TeamFairChampionship_Model.GetWatchParam() return private.watchParam end function TeamFairChampionship_Model.ClearWatchParam() private.watchParam = nil end --请求任务信息 function TeamFairChampionship_Model.TeamFairTaskInfoReq() local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairTaskInfoReq() NetManager.SendMessage(MessageEnums.MessageTeamFairTaskInfo, msg) end function private.OnTeamFairTaskInfoResp(msgResp) if msgResp.Resp.Code == 0 then private.taskInfoArray = msgResp.taskInfos --处理任务红点 CTL.TeamFairChampionship.RefreshTaskRed() EventSystem.Dispatch(EventID.UI_TeamFairChampionship_UpdateTask) end end function TeamFairChampionship_Model.TeamFairQuizBetReq(id, index, count) local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairQuizBetReq() msg.questionId = id msg.optionId = index msg.betNum = count NetManager.SendMessage(MessageEnums.MessageTeamFairQuizBet, msg) end function private.OnTeamFairQuizBetResp(msgResp) private.OnTeamFairGetAllQuizInfoResp(msgResp) end function TeamFairChampionship_Model.TeamFairTaskRewardReq(taskId) local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairTaskRewardReq() msg.teamFairTaskId = taskId NetManager.SendMessage(MessageEnums.MessageTeamFairTaskReward, msg) end function private.OnTeamFairTaskRewardResp(msgResp) logging.log(LTAG.LOG,"OnTeamFairTaskRewardResp", msgResp) if msgResp.Resp.Code == 0 then for i, v in ipairs(private.taskInfoArray) do if v.teamFairTaskId == msgResp.taskInfo.teamFairTaskId then v.taskProgress = msgResp.taskInfo.taskProgress v.state = msgResp.taskInfo.state break end end CTL.TeamFairChampionship.RefreshTaskRed() EventSystem.Dispatch(EventID.UI_TeamFairChampionship_UpdateTask) end end function TeamFairChampionship_Model.TeamFairGetAllQuizInfoReq(taskId) local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairGetAllQuizInfoReq() NetManager.SendMessage(MessageEnums.MessageTeamFairGetAllQuizInfo, msg) end function private.OnTeamFairGetAllQuizInfoResp(msgResp) logging.log(LTAG.LOG,"OnTeamFairGetAllQuizInfoResp", msgResp) if msgResp.Resp.Code == 0 then if private.matchGuessingInfo == nil or next( private.matchGuessingInfo) == nil then private.InitGuessingInfo() end local guessingInfo = {} for _, guessInfo in ipairs(private.matchGuessingInfo) do for _, guessServer in pairs(msgResp.quizInfo) do if guessServer.questionId == guessInfo.guessCfg.ID then guessInfo.serverInfo = guessServer end end end EventSystem.Dispatch(EventID.UI_TeamFairChampionship_RefreshGuessing) end end function private.InitGuessingInfo() private.matchGuessingInfo = {} for _, guessCfg in DataSheetManager.TeamFairMatchTalkGuess:GetEnumerator() do table.insert(private.matchGuessingInfo, {guessCfg = guessCfg }) end end --天下会武名人堂 function TeamFairChampionship_Model.TeamFairGetFamousReq() local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairGetFamousReq() NetManager.SendMessage(MessageEnums.MessageTeamFairGetFamous, msg) end function private.TeamFairGetFamousResp(msgResp) if msgResp.Resp.Code == 0 then EventSystem.Dispatch(EventID.UI_FairSoloTournament_UpdateFamousInfo, msgResp.info.seasonFamous) end end function TeamFairChampionship_Model.TeamFairThumbsUpReq() local msg = NetManager.GetPB("team_fair_opt_pb").TeamFairThumbsUpReq() NetManager.SendMessage(MessageEnums.MessageTeamFairThumbsUp, msg) end function private.OnTeamFairThumbsUpResp(msgResp) if msgResp.Resp.Code == 0 then EventSystem.Dispatch(EventID.UI_TeamFairChampionship_UpdateThumbsUpParam, msgResp.thumbsUpNum, msgResp.todayMyNum) end end return TeamFairChampionship_Model