local SyncSolo_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local TotalNum = DataSheetManager.ConstData:GetDataByID("SoloFightSeasonRewardNeedMatch").IntValue local OpenBPBattleLevel = DataSheetManager.FairMatchRule1V1:GetDataByID(LuaConst.ActivityType.SyncSolo).LevelScore function SyncSolo_Controller.OnStartup() EventSystem.Regist(EventID.New_Day_Refresh,private.NewDayRefresh) EventSystem.Regist(EventID.UI_FairPlay_SyncSoloSeasonInfoUpdate, private.RefreshRedPoint) EventSystem.Regist(EventID.UI_SyncSolo_RankRefresh, private.RefreshRedPoint) EventSystem.Regist(EventID.UI_SyncSolo_RefreshRedPoint,private.RefreshRedPoint) end --每日五点定时刷新 function private.NewDayRefresh() private.RefreshRedPoint() EventSystem.Dispatch(EventID.UI_FairPlay_RefreshDailyRewardUI) EventSystem.Dispatch(EventID.UI_FairPlay_RefreshWeeklyRewardUI) end function SyncSolo_Controller.IsSeasonOpen() return MDL.SyncSolo.GetSyncSoloSeasonInfo().seasonState == MDL.FairPlay.SeasonState.SeasonOpening end function SyncSolo_Controller.CanNotGetReward() return MDL.SyncSolo.GetSyncSoloCurNum() < TotalNum or MDL.SyncSolo.GetSyncSoloRewardDan() == MDL.SyncSolo.GetSyncSoloHistoryDan() end function SyncSolo_Controller.GetSyncSoloLevelRank() local score = MDL.SyncSolo.GetSyncSoloEloPoint() local rank = MDL.SyncSolo.GetSyncSoloRank() local level = DataSheetManager.SyncSoloData:GetDataByLevelID(1).LevelID for i, v in DataSheetManager.SyncSoloData:GetEnumerator() do if score < v.LevelScore then break end local levelRank = SyncSolo_Controller.GetLevelRankByData(v) if levelRank ~= 0 and rank > levelRank then break end level = v.LevelID end return level end function SyncSolo_Controller.GetSyncSoloLevelRankName(rankLv) local levelRank = rankLv or SyncSolo_Controller.GetSyncSoloLevelRank() local name = DataSheetManager.SyncSoloData:GetDataByLevelID(levelRank).LevelName return UIUtils.GetLocalizedTxt(Const_IDS[name]) end function SyncSolo_Controller.GetEloDesc() local success, data = DataSheetManager.SyncSoloData:TryGetDataByLevelID(SyncSolo_Controller.GetSyncSoloLevelRank() + 1) local nowScore = MDL.SyncSolo.GetSyncSoloEloPoint() if success then return string.format(nowScore.."/"..data.LevelScore) else return nowScore end end function SyncSolo_Controller.GetLevelRankDesc() local rank = MDL.SyncSolo.GetSyncSoloRank() local level = SyncSolo_Controller.GetSyncSoloLevelRank() local nextLevel = level + 1 local succ, data = DataSheetManager.SyncSoloData:TryGetDataByLevelID(nextLevel) --在最高段位时,nextLevel会越出表数据 if succ then local levelRank = SyncSolo_Controller.GetLevelRankByData(data) if levelRank and levelRank > 0 then if rank > levelRank then rank = UTL.Color.FormatRedColor(rank) end return string.FormatByIdsKey("IDS_1v1Sync_PromotionCondition_ScoreAndRank", data.LevelScore, rank, levelRank) else return string.FormatByIdsKey("IDS_RankOptimization_ScoreTips") end else local soloData = DataSheetManager.SyncSoloData:GetDataByLevelID(level) return string.FormatByIdsKey("IDS_RankOptimization_RankTips", rank, SyncSolo_Controller.GetLevelRankByData(soloData)) end end function SyncSolo_Controller.IsMaxNumber(num, numList) for i, v in ipairs(numList) do --因为如果剩余血量太小,都会特殊处理成0.1%,此处判断也做特殊处理 if v > num and (v > 0.001 or v == 0) then return false end end return true end -- 请不要直接使用数据中LevelRank这个字段, 使用一下方法来获取这个值 function SyncSolo_Controller.GetLevelRankByData(soloData) local state = MDL.SyncSolo.GetSyncSoloFairPlayState() -- 这里需要根据战区来判断一下 local levelRank = -1 if state == MDL.FairPlay.FairPlayState.AllSid then levelRank = soloData.LevelRank elseif state == MDL.FairPlay.FairPlayState.Local then levelRank = soloData.LevelRankSingle elseif state == MDL.FairPlay.FairPlayState.WarZone then levelRank = soloData.LevelRankWarZone else logging.error(LTAG.ERROR, "公平竞技状态 : SyncSolo 当前状态不存在 state = ", state, ",请检查下发数据") end return levelRank end function SyncSolo_Controller.IsWarZoneStyle() return MDL.SyncSolo.GetSyncSoloFairPlayState() == MDL.FairPlay.FairPlayState.WarZone end function SyncSolo_Controller.HasSyncSoloWinReward() local winInfo = MDL.SyncSolo.GetSyncSoloWinInfo() for i, v in DataSheetManager.SyncSoloSeasonWin:GetEnumerator() do if winInfo.winNum >= v.ID and winInfo.maxReceivedRewardID < v.ID then return true end end return false end function private.RefreshRedPoint() if not SyncSolo_Controller.CanNotGetReward() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_Reward_DanReward) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_Reward_DanReward) end -- 胜场奖励 if SyncSolo_Controller.HasSyncSoloWinReward() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_Reward_WinCountReward) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_Reward_WinCountReward) end --每日奖励红点 if SyncSolo_Controller.IsHasDailyReward() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_DailyReward) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_DailyReward) end --每周任务可领取 if SyncSolo_Controller.IsHasWeeklyTaskCanGet() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_WeeklyCanGet) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_WeeklyCanGet) end end --获取每日首胜的固定奖励 function SyncSolo_Controller.GetRewardOfEveryDay() local id = 1 --固定读取id为1的 local result = {} local data = DataSheetManager.SyncSoloDailyWin:GetDataByID(id) if data then --固定奖励 local fixedReward = DataSheetManager.SyncSoloDailyWinReward:GetDataByAttrRepeatID(data.StaticRewardID) if fixedReward == nil then return nil end result.FixedReward = fixedReward.Item_Table --随机奖励道具种类 result.RandomNum = data.RandomNum --随机奖励 local randomReward = DataSheetManager.RewardClientShow:GetDataByClientShowID(data.RandomRewardShowID) if randomReward == nil then return nil end result.RandomReward = DataSheetUtil.GetRewardClientShowItemTable(randomReward) return result end return nil end --是否有每日奖励 function SyncSolo_Controller.IsHasDailyReward() local state = MDL.SyncSolo.GetFirstWinOfEveryDayState() return state == MDL.SyncSolo.RewardState.NotGet end --本周已领取任务描述 function SyncSolo_Controller.GetHasGetWeeklyTaskContent() local totalTaskNum = MDL.SyncSolo.GetTotalWeeklyTaskNum() local hasCompleteTaskNum = MDL.SyncSolo.GetHasGetWeeklyTaskNum() local content = string.format("%s%d/%d",UIUtils.GetLocalizedTxt(Const_IDS.IDS_1v1RewardPlus_WeeklyTaskNum),hasCompleteTaskNum,totalTaskNum) return content end --任务是否完成 function SyncSolo_Controller.IsTaskHasComplete(data) return data.state > MDL.SyncSolo.RewardState.NotReach end --任务是否领取 function SyncSolo_Controller.IsTaskHasGet(data) return data.state == MDL.SyncSolo.RewardState.Get end --是否有周任务可领取 function SyncSolo_Controller.IsHasWeeklyTaskCanGet() local data = MDL.SyncSolo.GetWeeklyRewardArray() if data then for i,v in ipairs(data) do if data[i].state == MDL.SyncSolo.RewardState.NotGet then return true end end end return false end --打开1V1BP扔骰子界面 function SyncSolo_Controller.OpenRollDiceUI() if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISyncSoloRoll) == false then UIManager.OpenView(Const_UI_Lua.UIEnum.UISyncSoloRoll, nil, Const_UI_Lua.UIEnum.UIFairSoloTournamentRoll) end end --打开1V1BP选将界面 function SyncSolo_Controller.OpenBPSelectUI() if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISyncSoloBPSelect) == false then UIManager.CloseView(Const_UI_Lua.UIEnum.UISyncSoloRoll) UIManager.OpenView(Const_UI_Lua.UIEnum.UISyncSoloBPSelect,nil, Const_UI_Lua.UIEnum.UIFairSoloTournamentBanSelect) end end function SyncSolo_Controller.IsOpenBPBattle() return MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SyncSoloBP) and MDL.SyncSolo.GetSyncSoloCurDan() >= OpenBPBattleLevel end function SyncSolo_Controller.IsPlayOpenBPBattleMatchAnim(oldLv) return SyncSolo_Controller.IsOpenBPBattle() and oldLv == OpenBPBattleLevel - 1 end function SyncSolo_Controller.IsBPCanSelect(heroId) if MDL.HeroSelect.IsHasHero(heroId) then return true end -- 测试武将 if MDL.SyncSolo.CheckIsTestFreeHero(heroId) then return true end -- 限免武将 if MDL.SyncSolo.CheckIsTemporaryFreeHero(heroId) then return true end return false end return SyncSolo_Controller