local MonthBossChallenge_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') function MonthBossChallenge_Controller.OnStartup() EventSystem.Regist(EventID.UI_SubjectMonth_UpdateBossChallengeInfo, private.CheckRedPoint) end function private.CheckRedPoint() if MDL.MonthBossChallenge.HasReward() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.SubjectMonth_BossChallenge) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.SubjectMonth_BossChallenge) end end function MonthBossChallenge_Controller.GetLevelCfg(bossId) for k, v in DataSheetManager.VersionsBossChallengeLevel:GetEnumerator() do if v.BossID == bossId then return v end end end function MonthBossChallenge_Controller.GetShowBossList() local modeId = CTL.SubjectMonth.GetSubActivityModeId(MDL.SubjectMonth.SubActivityType.BossChallenge) local bossList = DataSheetManager.VersionsBossChallengeData:GetDataByBossChallengeModeID(modeId).BossID local list = {} local curBossId = MDL.MonthBossChallenge.GetCurBossId() if curBossId ~= 0 then table.insert(list, curBossId) for i, v in ipairs(bossList) do if v == curBossId and i ~= #bossList then table.insert(list, bossList[i + 1]) break end end else table.insert(list, bossList[#bossList]) end return list end function private.SortScoreRewardData(a, b) if a.status == b.status then return a.cfg.ID < b.cfg.ID else return CTL.OACommon.SortByStatus(a.status, b.status) end end function MonthBossChallenge_Controller.CanReceiveScoreRewardByBossId(bossId) local score = MDL.MonthBossChallenge.GetScoreByBossId(bossId) for i, v in DataSheetManager.VersionsBossChallengeReward:GetEnumerator() do if v.BossChallengeID == bossId then if score >= v.RankMin and not MDL.MonthBossChallenge.IsScoreRewardReceived(bossId, v.ID) then return true end end end return false end function MonthBossChallenge_Controller.GetScoreRewardDataByBossId(bossId) local list = {} local score = MDL.MonthBossChallenge.GetScoreByBossId(bossId) for i, v in DataSheetManager.VersionsBossChallengeReward:GetEnumerator() do if v.BossChallengeID == bossId then local status if score >= v.RankMin then status = MDL.MonthBossChallenge.IsScoreRewardReceived(bossId, v.ID) and MDL.OACommon.ActivityTaskState.Commit or MDL.OACommon.ActivityTaskState.Done else status = MDL.OACommon.ActivityTaskState.UnDone end table.insert(list, {cfg = v, status = status}) end end table.sort(list, private.SortScoreRewardData) return list end function MonthBossChallenge_Controller.GetStateByBossId(bossId) local curBossId = MDL.MonthBossChallenge.GetCurBossId() if curBossId == 0 then return CTL.Activities.ActivityState.End end local modeId = CTL.SubjectMonth.GetSubActivityModeId(MDL.SubjectMonth.SubActivityType.BossChallenge) local cfg = DataSheetManager.VersionsBossChallengeData:GetDataByBossChallengeModeID(modeId) local bossList = cfg.BossID local index, curBossIndex for i, id in ipairs(bossList) do if id == curBossId then curBossIndex = i end if id == bossId then index = i end end local activityId = MDL.SubjectMonth.GetActivityId() local activityInfo = MDL.OperationActivity.GetOperationActivityInfo(MDL.OperationActivity.ActivityType.SubjectMonth, activityId) if bossId == curBossId then local timeRefreshCfg = DataSheetManager.TimeRefresh:GetDataByID(cfg.BossRankEndTime) local endTime = timeRefreshCfg.HMS + UTL.Time.GetServerZeroTimestampByTimestamp(activityInfo.startTime + (cfg.BossLastTime * index - 1) * UTL.Time.TotalSecondsOneDay) local curDate = UTL.Time.GetServerTimestamp() if curDate < endTime then return CTL.Activities.ActivityState.Opening else return CTL.Activities.ActivityState.End end end if index < curBossIndex then return CTL.Activities.ActivityState.End else local startTime = activityInfo.startTime + cfg.BossLastTime * (index - 1) * UTL.Time.TotalSecondsOneDay return CTL.Activities.ActivityState.NotOpen, startTime - UTL.Time.GetServerTimestamp() end end function MonthBossChallenge_Controller.GetOpenTimeByBossId(bossId) local modeId = CTL.SubjectMonth.GetSubActivityModeId(MDL.SubjectMonth.SubActivityType.BossChallenge) local cfg = DataSheetManager.VersionsBossChallengeData:GetDataByBossChallengeModeID(modeId) local bossList = cfg.BossID local index for i, id in ipairs(bossList) do if id == bossId then index = i break end end local activityId = MDL.SubjectMonth.GetActivityId() local activityInfo = MDL.OperationActivity.GetOperationActivityInfo(MDL.OperationActivity.ActivityType.SubjectMonth, activityId) local timeFormat = UTL.Time.FormatDateEnum.YMDHM local linkFormat = "%s - %s" local startTimeStr = os.date(timeFormat, activityInfo.startTime + cfg.BossLastTime * (index - 1) * UTL.Time.TotalSecondsOneDay) local timeRefreshCfg = DataSheetManager.TimeRefresh:GetDataByID(cfg.BossRankEndTime) local endTime = timeRefreshCfg.HMS + UTL.Time.GetServerZeroTimestampByTimestamp(activityInfo.startTime + (cfg.BossLastTime * index - 1) * UTL.Time.TotalSecondsOneDay) local endTimeStr = os.date(timeFormat, endTime) return string.format(linkFormat, startTimeStr, endTimeStr) end function MonthBossChallenge_Controller.GetRankSettlementTime() local modeId = CTL.SubjectMonth.GetSubActivityModeId(MDL.SubjectMonth.SubActivityType.BossChallenge) local cfg = DataSheetManager.VersionsBossChallengeData:GetDataByBossChallengeModeID(modeId) local timeRefreshCfg = DataSheetManager.TimeRefresh:GetDataByID(cfg.BossRankEndTime) return UTL.Time.FormatTimeClockBySeconds(timeRefreshCfg.HMS, "%02d:%02d") end function MonthBossChallenge_Controller.GetBossLevelBuffInfluenceList(bossId, heroId) local influenceList = {} local cfg = MonthBossChallenge_Controller.GetLevelCfg(bossId) local buffTable = cfg.BuffID for i, v in ipairs(buffTable) do influenceList[i] = CTL.BossChallenge.IsHeroBenefitBuffByBuffId(v, heroId) end return influenceList end function MonthBossChallenge_Controller.GetBossLevelBuffInfluenceNumbers(bossId, heroId) local influenceNum = 0 local cfg = MonthBossChallenge_Controller.GetLevelCfg(bossId) local buffTable = cfg.BuffID for i, v in ipairs(buffTable) do if CTL.BossChallenge.IsHeroBenefitBuffByBuffId(v, heroId) then influenceNum = influenceNum + 1 end end return influenceNum end local SubjectMonthBossChallengeFormationKey = "SubjectMonthBossChallengeFormationKey" function MonthBossChallenge_Controller.SaveBossFormation(bossId, formationList) local activityId = MDL.SubjectMonth.GetActivityId() local str = table.concat(formationList, ",") local key = SubjectMonthBossChallengeFormationKey..activityId..bossId..BattleDataGetter.GetAcID() PersistentData.DeviceData:Set(key, str, true) end function MonthBossChallenge_Controller.LoadBossFormation(bossId) local activityId = MDL.SubjectMonth.GetActivityId() local key = SubjectMonthBossChallengeFormationKey..activityId..bossId..BattleDataGetter.GetAcID() local str = PersistentData.DeviceData:Get(key) if not string.isNilOrEmpty(str) then local strList = string.split(str, ",") for i, v in ipairs(strList) do strList[i] = tonumber(v) end return strList end return nil end function MonthBossChallenge_Controller.ShowBattleSummary(msgInfo) CTL.HomeMain.CloseOpenView() UIManager.OpenView(Const_UI_Lua.UIEnum.UISubjectMonthChallengeSummaryPanel, {msgInfo}, Const_UI_Lua.UIEnum.UIBossChallengeSummaryPanel) end function MonthBossChallenge_Controller.IsChallengePassed(bossId, score) local cfg = MonthBossChallenge_Controller.GetLevelCfg(bossId) local scoreData = DataSheetManager.VersionsBossChallengeScore:GetDataByID(cfg.Difficulty) local passScore = scoreData.PassScore if score >= passScore then return true else return false end end function MonthBossChallenge_Controller.GetCommandHeroList(bossId) local commandHeroList = {} local GetInfluenceNumFunc = MonthBossChallenge_Controller.GetBossLevelBuffInfluenceNumbers for i, v in DataSheetManager.HeroNum:GetEnumerator() do local influenceNum = GetInfluenceNumFunc(bossId, v.ID) if influenceNum >= 2 then table.insert(commandHeroList, v.ID) end end return commandHeroList end local MonthBossChallengeNewBossTipKey = "MonthBossChallengeNewBossTipKey_%s_%s_%s" function MonthBossChallenge_Controller.IsShowNewBossTip() local bossId = MDL.MonthBossChallenge.GetCurBossId() if not bossId then return false end local activityId = MDL.SubjectMonth.GetActivityId() local key = string.format(MonthBossChallengeNewBossTipKey, BattleDataGetter.GetAcID(), activityId, bossId) if not PersistentData.DeviceData:Get(key) then return true end return false end function MonthBossChallenge_Controller.SaveNewBossTipRecord() local activityId = MDL.SubjectMonth.GetActivityId() local bossId = MDL.MonthBossChallenge.GetCurBossId() if not bossId then return end local key = string.format(MonthBossChallengeNewBossTipKey, BattleDataGetter.GetAcID(), activityId, bossId) if PersistentData.DeviceData:Get(key) then return end PersistentData.DeviceData:Set(key, true, true) end function MonthBossChallenge_Controller.OpenChallengeView() if not CTL.SubjectMonth.IsSubActivityOpen(MDL.SubjectMonth.SubActivityType.BossChallenge) then return end UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISubjectMonthChallenge) end return MonthBossChallenge_Controller