local GoldHeroReprint_Controller = {} local EventSystem = require('Event/EventSystem') local private = { heroDatas = {}, itemDatas = {} } local GoldHeroReprintActiveView = { Const_UI_Lua.UIEnum.UIGachaSummary, Const_UI_Lua.UIEnum.UIGoldHeroReprint, Const_UI_Lua.UIEnum.UIOACommonStoreBase, Const_UI_Lua.UIEnum.UIGoldHeroReprintRecharge, } function GoldHeroReprint_Controller.OnStartup() EventSystem.Regist(EventID.UI_OperationActivity_InfoChanged, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshInfoByFunction) private.endTimerHandle = {} end --region ------------------ 活动结束 -------------------- --GMS开关变化时刷新 function private.RefreshInfoByFunction(funcId, isUnlock) if funcId == MDL.Unlock.FunctionType.GoldHeroReprint then if not isUnlock then private.ForceCloseActivityView() end end end -- 关闭活动界面 function private.ForceCloseActivityView() logging.log(LTAG.LOG, "GoldHeroReprint Function(include GMS) ActivityEnd ") local activityTypeInfo = MDL.GoldHeroReprint.GetGoldHeroReprintActivityInfo() if activityTypeInfo and activityTypeInfo.activityId then private.EndAndCloseActivityView(activityTypeInfo.activityId) end end function private.CheckFuncOpenIssue() if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GoldHeroReprint) then private.ForceCloseActivityView() return end local activityTypeInfo = MDL.GoldHeroReprint.GetGoldHeroReprintActivityInfo() if activityTypeInfo and activityTypeInfo.activityId then local activityId = activityTypeInfo.activityId if private.endTimerHandle[activityId] then TimerUtil.Remove(private.endTimerHandle[activityId]) end if not CTL.OperationActivity.IsOperationActivityOpen(activityTypeInfo) then private.EndAndCloseActivityView(activityId) else local deltaTime = activityTypeInfo.endTime - UTL.Time.GetServerTimestamp() if deltaTime <= UTL.Time.TotalSecondsOneDay then private.endTimerHandle[activityId] = TimerUtil.Interval(function() private.EndAndCloseActivityView(activityId) end, deltaTime - 1, 1) --时间减1s是为了防止有误差导致玩家点击出现报错 end if not MDL.GoldHeroReprint.IsActivityInFuncTime() then private.ShutDownPartActivityView(activityId) end end end end function private.ShutDownPartActivityView(activityId) for i, v in ipairs(GoldHeroReprintActiveView) do EventSystem.Dispatch(EventID.UI_OperationActivity_CloseView, v, activityId) end end function private.EndAndCloseActivityView(activityId) if activityId == MDL.GoldHeroReprint.GetGoldHeroReprintActivityID() then UIManager.RecoverTopView() CTL.HomeMain.CloseOpenView() end if private.endTimerHandle[activityId] then TimerUtil.Remove(private.endTimerHandle[activityId]) end end --region ------------------ 活动结束 -------------------- function private.SortHeroDatasByQuaility(a, b) if a.HeroIntelligence == b.HeroIntelligence then if a.HeroQuality == b.HeroQuality then return a.ID < b.ID end return a.HeroQuality > b.HeroQuality end return a.HeroIntelligence > b.HeroIntelligence end function private.SortItemDatas(a, b) if a.RewardShowPriority == b.RewardShowPriority then return a.ID < b.ID end return a.RewardShowPriority > b.RewardShowPriority end function GoldHeroReprint_Controller.GetReprintHeroDatas(drawCardPooId, countryId) if private.heroDatas[drawCardPooId] then return private.heroDatas[drawCardPooId][countryId] end local drawCardData = DataSheetManager.DrawCardData:GetDataByID(drawCardPooId) if drawCardData and drawCardData.RewardDropShowHero and #drawCardData.RewardDropShowHero > 0 then private.heroDatas[drawCardPooId] = {} for _, v in ipairs (drawCardData.RewardDropShowHero) do local heroData = DataSheetManager.HeroNum:GetDataByID(v) if not private.heroDatas[drawCardPooId][heroData.Kingdom] then private.heroDatas[drawCardPooId][heroData.Kingdom] = {} end table.insert(private.heroDatas[drawCardPooId][heroData.Kingdom], heroData) end local activityId = MDL.GoldHeroReprint.GetGoldHeroReprintActivityID() for _, v in MDL.OperationActivity.GoldHeroReprintShowHero:GetEnumeratorByActivityID(activityId) do local heroData = DataSheetManager.HeroNum:GetDataByID(v.HeroShowID) if not private.heroDatas[drawCardPooId][heroData.Kingdom] then private.heroDatas[drawCardPooId][heroData.Kingdom] = {} end table.insert(private.heroDatas[drawCardPooId][heroData.Kingdom], heroData) end for _, v in pairs (private.heroDatas[drawCardPooId]) do table.sort(v, private.SortHeroDatasByQuaility) end return private.heroDatas[drawCardPooId][countryId] end return nil end function GoldHeroReprint_Controller.GetReprintItemDatas(drawCardPooId, quality) if private.itemDatas[drawCardPooId] then return private.itemDatas[drawCardPooId][quality] end local drawCardData = DataSheetManager.DrawCardData:GetDataByID(drawCardPooId) if drawCardData and drawCardData.RewardDropShowItem and #drawCardData.RewardDropShowItem > 0 then private.itemDatas[drawCardPooId] = {} for _, v in ipairs (drawCardData.RewardDropShowItem) do local itemData = DataSheetManager.ItemData:GetDataByID(v) local quality = itemData.Color if not private.itemDatas[drawCardPooId][quality] then private.itemDatas[drawCardPooId][quality] = {} end table.insert(private.itemDatas[drawCardPooId][quality], itemData) end local activityId = MDL.GoldHeroReprint.GetGoldHeroReprintActivityID() for _, v in MDL.OperationActivity.GoldHeroReprintShowHero:GetEnumeratorByActivityID(activityId) do local itemData = DataSheetManager.ItemData:GetDataByID(v.RewardID) local quality = itemData.Color if not private.itemDatas[drawCardPooId][quality] then private.itemDatas[drawCardPooId][quality] = {} end table.insert(private.itemDatas[drawCardPooId][quality], itemData) end for _, v in pairs (private.itemDatas[drawCardPooId]) do table.sort(v, private.SortItemDatas) end end return private.itemDatas[drawCardPooId][quality] end function GoldHeroReprint_Controller.GetGachaDetailInfo(drawCardPooId) local drawCardData = DataSheetManager.DrawCardData:GetDataByID(drawCardPooId) if drawCardData then local guildNoteData = DataSheetManager.GuidanceNotes:GetDataByID(drawCardData.GuidanceNotesID) return guildNoteData and UIUtils.GetLocalizedTxt(Const_IDS[guildNoteData.GuideNotesContent]) or "" end return "" end return GoldHeroReprint_Controller