local KingChallenge_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local KING_CHALLENGE_BUFF_UI_OPEN = "KING_CHALLENGE_BUFF_UI_OPEN" local KING_CHALLENGE_NEW_SEASON_POPUP = "KING_CHALLENGE_NEW_SEASON_POPUP" function KingChallenge_Controller.OnStartup() EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshInfoByFunction) end --GMS开关变化时刷新 function private.RefreshInfoByFunction(funcId, isUnlock) if funcId == MDL.Unlock.FunctionType.KingChallenge then if not isUnlock then if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIKingChallengeMainPanel) then private.CloseKingChallengeAllUI() end end end end function KingChallenge_Controller.IsShowKingChallengeEntry() return MDL.KingChallenge.GetCurBigSeasonId() ~= 0 and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.KingChallenge) end function KingChallenge_Controller.IsShowNewSeasonPopUp() if not (MDL.KingChallenge.GetCurBigSeasonId() ~= 0 and CTL.SubjectMonth.IsOpen()) then return false end local curBigSeasonId = MDL.KingChallenge.GetCurBigSeasonId() local tb = PersistentData.PlayerData:Get(KING_CHALLENGE_NEW_SEASON_POPUP) if tb and tb[curBigSeasonId] then return false end if tb == nil then tb = {} end tb[curBigSeasonId] = true PersistentData.PlayerData:Set(KING_CHALLENGE_NEW_SEASON_POPUP, tb, true) return true end function KingChallenge_Controller.IsHasSeasonBuff() if not KingChallenge_Controller.IsShowKingChallengeEntry() then return false end local curBigSeasonId = MDL.KingChallenge.GetCurBigSeasonId() local bigSeasonCfg = DataSheetManager.KingChallengeSeason:GetDataByID(curBigSeasonId) return bigSeasonCfg.SeasonBuff and #bigSeasonCfg.SeasonBuff > 0 end function KingChallenge_Controller.TryAutoOpenBuffUI() if not KingChallenge_Controller.IsHasSeasonBuff() then return false end local curBigSeasonId = MDL.KingChallenge.GetCurBigSeasonId() local tb = PersistentData.PlayerData:Get(KING_CHALLENGE_BUFF_UI_OPEN) if tb and tb[curBigSeasonId] then return end if tb == nil then tb = {} end tb[curBigSeasonId] = true PersistentData.PlayerData:Set(KING_CHALLENGE_BUFF_UI_OPEN, tb, true) UIManager.OpenView(Const_UI_Lua.UIEnum.UIKingChallengeSeasonBuffPopUp) end --当前赛季结束,关闭界面 function KingChallenge_Controller.CloseKingChallengeMainUI() if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIKingChallengeMainPanel) then private.CloseKingChallengeAllUI() CTL.Tips.AddTipsMsg(Const_IDS["IDS_KingChallenge_Hint8"]) end end --当前赛季结束,关闭界面 function private.CloseKingChallengeAllUI() UIManager.CloseView(Const_UI_Lua.UIEnum.UIKingChallengeMainPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIKingChallengeSeasonReview) UIManager.CloseView(Const_UI_Lua.UIEnum.UIKingChallengeSeasonReviewdetails) UIManager.CloseView(Const_UI_Lua.UIEnum.UIKingChallengeRewardPopUp) end function KingChallenge_Controller.Is1v1ReachKing(littleSeasonId, successSoloSeasonIds) for _, successSoloSeasonId in ipairs(successSoloSeasonIds) do if littleSeasonId == successSoloSeasonId then return true end end return false end function KingChallenge_Controller.Is3v3ReachKing(littleSeasonId, successTVTSeasonIds) for _, successSoloSeasonId in ipairs(successTVTSeasonIds) do if littleSeasonId == successSoloSeasonId then return true end end return false end function KingChallenge_Controller.GetCurSeasonReachRewardCondition() local bigSeasonCfg = DataSheetManager.KingChallengeSeason:GetDataByID(MDL.KingChallenge.GetCurBigSeasonId()) return bigSeasonCfg.RewardRequireNum end return KingChallenge_Controller