local ThreeTeamFight_Controller = {} local private = {} local EventSystem = require 'Event/EventSystem' local InValidOrder = 999 local THREETEAMFIGHT_EVENT_TIME = "THREETEAMFIGHT_EVENT_TIME" ThreeTeamFight_Controller.LineNumberType = { Defence_1 = 1, Defence_2 = 2, Defence_3 = 3, Attack_1 = 4, Attack_2 = 5, Attack_3 = 6, } --预备阵容索引值 ThreeTeamFight_Controller.TempLineNumberType = { 7, 8, 9, } function ThreeTeamFight_Controller.OnStartup() EventSystem.Regist(EventID.Country_RefreshSelectInfo, private.OnCountryInfoChange) EventSystem.Regist(EventID.Country_OnGetFoundCountry, private.OnCountryInfoChange) EventSystem.Regist(EventID.TimerWheelStartTimeOver, private.OnActivityStart) EventSystem.Regist(EventID.TimerWheelEndTimeOver, private.OnActivityEnd) end function ThreeTeamFight_Controller.OpenMain(isTips) if MDL.ThreeTeamFight.IsSeasonOpen() == false then if isTips then CTL.Tips.AddTipsMsg(CTL.ThreeTeamFight.GetActivityNotOpenTips(true)) end return false end if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.ThreeTeamFight) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIThreeTeamFightMain) return true end if isTips then local activityData = DataSheetManager.ActivityData:GetDataByID(MDL.Unlock.FunctionType.ThreeTeamFight) local isUnlock, content = MDL.Unlock.IsClientUnlockWithText(activityData.FuctionUnlockID, activityData.SheetShowConditionIDS) CTL.Tips.AddTipsMsg(content) end return false end --是否在赛季开启时间 function ThreeTeamFight_Controller.IsActivityOpen() if MDL.ThreeTeamFight.IsSeasonOpen() == false then return false end local countryState = MDL.Country.GetCurStage() if countryState then return countryState >= MDL.Country.Stage.CountryBuild and countryState <= MDL.Country.Stage.CountryReset end return false end function ThreeTeamFight_Controller.TryOpenTimeUp() if not ThreeTeamFight_Controller.IsActivityOpen() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ActivityItem_NotAtActivityTime) return end if CTL.Activities.GetState(LuaConst.ActivityType.ThreeTeamFight) ~= CTL.Activities.ActivityState.Opening then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ActivityItem_NotAtActivityTime) return end if MDL.Purchase.GetAvailablePurchaseTimes(LuaConst.ActivityType.ThreeTeamFight) > 0 then UIManager.OpenView(Const_UI_Lua.UIEnum.UIItemBuyPanel, { type = LuaConst.ActivityType.ThreeTeamFight }) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroBiography_NoPayTime) end end function ThreeTeamFight_Controller.CheckIfHideByIndex(rank, lineIndex) if rank <= 0 then return false end local hideCount = 0 for i, v in DataSheetManager.ThreeTeamsPKCoverTeam:GetEnumerator() do if rank <= v.Rank then hideCount = v.CoverTeamNum break end end --配置了1,表示隐藏第3队;配置了2,表示隐藏第2、3队;配置了3全部隐藏 if hideCount == 1 then return lineIndex == 3 elseif hideCount == 2 then return lineIndex >= 2 elseif hideCount == 3 then return true end return false end function ThreeTeamFight_Controller.OpenReward() UIManager.OpenView(Const_UI_Lua.UIEnum.UIThreeTeamFightReward) end function ThreeTeamFight_Controller.OpenMsg(eventList) UIManager.OpenView(Const_UI_Lua.UIEnum.UIThreeTeamFightMsg, eventList, "SoloFight/UISoloFightMsg") end function ThreeTeamFight_Controller.OpenFormation(isAttack) local titleIDS, lineNumbers if isAttack then lineNumbers = { ThreeTeamFight_Controller.LineNumberType.Attack_1, ThreeTeamFight_Controller.LineNumberType.Attack_2, ThreeTeamFight_Controller.LineNumberType.Attack_3, } titleIDS = Const_IDS.IDS_3TeamsPK_OffensiveFormation else lineNumbers = { ThreeTeamFight_Controller.LineNumberType.Defence_1, ThreeTeamFight_Controller.LineNumberType.Defence_2, ThreeTeamFight_Controller.LineNumberType.Defence_3, } titleIDS = Const_IDS.IDS_3TeamsPK_DefensiveFormation end --9人布阵界面 UIManager.OpenView(Const_UI_Lua.UIEnum.UIThreeTeamFightSelectOfficer, { titleIDS = titleIDS, freeLineupFuncType = MDL.FreeLineUp.FuncType.ThreeTeamFight, lineNumbers = lineNumbers, tempLineNumbers = ThreeTeamFight_Controller.TempLineNumberType, --【optional】空表示实时更换阵容,非空则最后保存才确定阵容,需要将备选阵容复制到正式阵容 sortFunc = ThreeTeamFight_Controller.SortThreeTeamFightHero, --【optional】武将排序方法,为空不排序 noteFunc = ThreeTeamFight_Controller.OpenNote, --【optional】为空不显示说明按钮 }) end function ThreeTeamFight_Controller.OpenNote() local desc1, timeStr1 = UTL.Time.GetDateDescAndTime({ DataSheetManager.ConstData:GetDataByID("ThreeTeamsPKRewardTime").IntValue }) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.ThreeTeamFight, params = { desc1 .. timeStr1 } }) end function ThreeTeamFight_Controller.TryChallenge(acid, rank) if not ThreeTeamFight_Controller.IsActivityOpen() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ActivityItem_NotAtActivityTime) return end if CTL.Activities.GetState(LuaConst.ActivityType.ThreeTeamFight) ~= CTL.Activities.ActivityState.Opening then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ActivityItem_NotAtActivityTime) return end if MDL.ThreeTeamFight.GetLeftTimes() == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroBiography_NoNum) return end UIManager.OpenView(Const_UI_Lua.UIEnum.UIThreeTeamFightPopUp, { acid = acid, rank = rank }) end function ThreeTeamFight_Controller.TryEnterChallenge(isCheckLineNumber) if isCheckLineNumber then for i = CTL.ThreeTeamFight.LineNumberType.Defence_1, CTL.ThreeTeamFight.LineNumberType.Defence_3 do if MDL.FreeLineUp.CheckLineNumberIllegal(MDL.FreeLineUp.FuncType.ThreeTeamFight, i) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_3TeamsPK_LaunchReminder2) return end end end if not ThreeTeamFight_Controller.IsActivityOpen() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ActivityItem_NotAtActivityTime) return end if CTL.Activities.GetState(LuaConst.ActivityType.ThreeTeamFight) ~= CTL.Activities.ActivityState.Opening then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ActivityItem_NotAtActivityTime) return end UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIThreeTeamFightChallenge) end function ThreeTeamFight_Controller.GetChallengeTimesDesc() local totalTimes = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.ThreeTeamFight).DailyRefreshTimes local leftTimes = MDL.ThreeTeamFight.GetLeftTimes() local str if leftTimes == 0 then str = UTL.Color.FormatRedColor(0) .. "/" .. totalTimes else str = leftTimes .. "/" .. totalTimes end return str end function ThreeTeamFight_Controller.FormatMyRankDesc(txt) local myRank = MDL.ThreeTeamFight.GetMyRank() local desc = ThreeTeamFight_Controller.GetRankDesc(myRank, true, true) if desc then txt.text = desc else UIUtils.SetLabelText(txt, Const_IDS.IDS_Rank_Unranked) end end function ThreeTeamFight_Controller.GetMyRankLevel() local myRankLevelCfg = private.GetRankLevelCfg(MDL.ThreeTeamFight.GetMyRank()) if myRankLevelCfg then return myRankLevelCfg.LevelID end return -1 end function ThreeTeamFight_Controller.GetRankDesc(rank, isWithRank, iwWithColor) if rank > 0 then local curRankCfg = private.GetRankLevelCfg(rank) if curRankCfg then if isWithRank then local rankNum = string.FormatByIdsId(Const_IDS.IDS_OfficialPosition_CurrentRanking2, rank - curRankCfg.RankMin + 1) if iwWithColor then return UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[curRankCfg.LevelName]) .. "·" .. rankNum, curRankCfg.LevelColor) else return UIUtils.GetLocalizedTxt(Const_IDS[curRankCfg.LevelName]) .. "·" .. rankNum end else if iwWithColor then return UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[curRankCfg.LevelName]), curRankCfg.LevelColor) else return UIUtils.GetLocalizedTxt(Const_IDS[curRankCfg.LevelName]) end end end end return nil end --获取段位排名 function ThreeTeamFight_Controller.GetLevelRank(rank) if rank > 0 then local curRankCfg = private.GetRankLevelCfg(rank) if curRankCfg then return rank - curRankCfg.RankMin + 1 end end return 0 end function ThreeTeamFight_Controller.GetRankRobotName(rank) if rank and rank > 0 then local curRankCfg = private.GetRankLevelCfg(rank) local rankNum = rank - curRankCfg.RankMin + 1 return UIUtils.GetLocalizedTxt(Const_IDS[curRankCfg.RobotName]) .. "·" .. rankNum end return nil end function private.GetRankLevelCfg(rank) if rank > 0 then for i, v in DataSheetManager.ThreeTeamsPKLevel:GetEnumerator() do if rank >= v.RankMin and rank <= v.RankMax then return v end end end return nil end function ThreeTeamFight_Controller.SortThreeTeamFightHero(a, b) local orderValue_1 = private.GetOrderValue(a) local orderValue_2 = private.GetOrderValue(b) if orderValue_1 == orderValue_2 then if a.heroBaseGs == b.heroBaseGs then return a.heroId > b.heroId end return a.heroBaseGs > b.heroBaseGs else return orderValue_1 < orderValue_2 end end --阵容一>阵容二>阵容三>未上阵 --前中后军 --主将>副将 --战力高>低 --lineNumber * 100 + pos function private.GetOrderValue(heroInfo) local min, max = ThreeTeamFight_Controller.TempLineNumberType[1], ThreeTeamFight_Controller.TempLineNumberType[#ThreeTeamFight_Controller.TempLineNumberType] for i = min, max do local pos = MDL.FreeLineUp.GetHeroPosNumber(heroInfo.heroId, MDL.FreeLineUp.FuncType.ThreeTeamFight, i) if pos > 0 then return i * 100 + pos end end --invalid表示未上阵 return InValidOrder end function ThreeTeamFight_Controller.ShowBattleSummary() CTL.HomeMain.CloseOpenView() UIManager.OpenView(Const_UI_Lua.UIEnum.UIThreeTeamFightBattleOver) end function ThreeTeamFight_Controller.SaveEventTime(value) PersistentData.PlayerData:Set(THREETEAMFIGHT_EVENT_TIME, value, true) end function ThreeTeamFight_Controller.GetEventTime() return PersistentData.PlayerData:Get(THREETEAMFIGHT_EVENT_TIME, 0) end function private.OnCountryInfoChange() ThreeTeamFight_Controller.RefreshRed() end function ThreeTeamFight_Controller.RefreshRed() local leftThumpUpTimes = MDL.ThreeTeamFight.GetLeftThumbsUpTimes() if leftThumpUpTimes == 0 then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.ThreeTeamFight_ThumbsUp) else CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.ThreeTeamFight_ThumbsUp) end if ThreeTeamFight_Controller.IsActivityOpen() and CTL.Activities.GetState(LuaConst.ActivityType.ThreeTeamFight) == CTL.Activities.ActivityState.Opening then local canChallenge = MDL.ThreeTeamFight.GetLeftTimes() > 0 local canGetTask = MDL.ThreeTeamFight.CheckIfTaskGet() if canGetTask then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.ThreeTeamFight_TaskCanGet) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.ThreeTeamFight_TaskCanGet) end EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.ThreeTeamFight, (canChallenge or canGetTask)) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.ThreeTeamFight_TaskCanGet) EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.ThreeTeamFight, false) end end --活动时间开始 function private.OnActivityStart(timeId, activityId, timeIndex) if activityId == LuaConst.ActivityType.ThreeTeamFight then ThreeTeamFight_Controller.RefreshRed() end end --活动时间开始 function private.OnActivityEnd(timeId, activityId, timeIndex) if activityId == LuaConst.ActivityType.ThreeTeamFight then ThreeTeamFight_Controller.RefreshRed() end end --活动未开启提示 function ThreeTeamFight_Controller.GetActivityNotOpenTips(isRedColor) if CTL.WarZone.IsWarZoneOpen() == false then local count = 1 if GameAppInfo.IsChinesePackage() then count = DataSheetManager.ConstData:GetDataByID("ThreeTeamsPKOpenTime_GuoFu").IntValue elseif GameAppInfo.IsJapanesePackage() then count = DataSheetManager.ConstData:GetDataByID("ThreeTeamsPKOpenTime_RiFu").IntValue else if GameAppInfo.IsOverseaHMT() then count = DataSheetManager.ConstData:GetDataByID("ThreeTeamsPKOpenTime_YaFu").IntValue elseif GameAppInfo.IsOverseaAmerica() then count = DataSheetManager.ConstData:GetDataByID("ThreeTeamsPKOpenTime_MeiFu").IntValue elseif GameAppInfo.IsOverseaEurope() then count = DataSheetManager.ConstData:GetDataByID("ThreeTeamsPKOpenTime_OuFu").IntValue end end if isRedColor then return UTL.Color.FormatRedColor(string.FormatByIdsId(Const_IDS.IDS_3TeamsPK_OpenTime2, count)) else return string.FormatByIdsId(Const_IDS.IDS_3TeamsPK_OpenTime2, count) end end if isRedColor then return UTL.Color.FormatRedColor(string.FormatByIdsId(Const_IDS.IDS_3TeamsPK_OpenTime, UTL.Time.GetTimestampDay(MDL.ThreeTeamFight.GetStartTimestamp()))) else return string.FormatByIdsId(Const_IDS.IDS_3TeamsPK_OpenTime, UTL.Time.GetTimestampDay(MDL.ThreeTeamFight.GetStartTimestamp())) end end return ThreeTeamFight_Controller