local HeroFund_Controller = {} local private = {} function HeroFund_Controller.OnStartup() private.sortedList = {} --初始选将\马\宝物列表 private.curType = nil --用的LuaConst.ShowGoldenType,而不是Unlock_Model里的FuncType private.InitSelectLimit() end function HeroFund_Controller.OnShutdown() private.sortedList = {} private.selectLimit = {} private.curType = nil end --region public func function HeroFund_Controller.GetSortedList(type) private.UpdateSortList(type) return private.sortedList[type] end --有可选的将、马、宝物 function HeroFund_Controller.IsHasCanSelectQuality(type) if type == LuaConst.ShowGoldenType.Hero then for i, v in DataSheetManager.HeroNum:GetEnumerator() do if private.CanSelect(type, v.ID, v.HeroQuality) and MDL.HeroSelect.IsHasHero(v.ID) and MDL.HideGolden.IsShowGoldenByID(LuaConst.ShowGoldenType.Hero, v.ID) then return true end end elseif type == LuaConst.ShowGoldenType.Horse then for i, v in DataSheetManager.HorseData:GetEnumerator() do if private.CanSelect(type, v.HorseID, v.HorseQuality) and MDL.WarHorse.IsHasHorse(v.HorseID) and MDL.HideGolden.IsShowGoldenByID(LuaConst.ShowGoldenType.Horse, v.HorseID) then return true end end elseif type == LuaConst.ShowGoldenType.Treasure then for i, v in DataSheetManager.TreasureData:GetEnumerator() do if private.CanSelect(type, v.TreasureID, v.TreasureQuality) and MDL.Treasure.IsHasTreasure(v.TreasureID) and MDL.HideGolden.IsShowGoldenByID(LuaConst.ShowGoldenType.Treasure, v.TreasureID) then return true end end end end function HeroFund_Controller.OpenView(baseView, tabType) local prefabPath = nil if tabType == CTL.PayMall.ShopChildTabType.HeroFund then private.curType = LuaConst.ShowGoldenType.Hero elseif tabType == CTL.PayMall.ShopChildTabType.HorseFund then private.curType = LuaConst.ShowGoldenType.Horse elseif tabType == CTL.PayMall.ShopChildTabType.TreasureFund then private.curType = LuaConst.ShowGoldenType.Treasure elseif tabType == CTL.PayMall.ShopChildTabType.GoldIngotFund then private.curType = LuaConst.ShowGoldenType.GoldIngot prefabPath = Const_UI_Lua.UIEnum.UIGoldIngotFundPanel end return baseView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHeroFundPanel), { type = private.curType }, prefabPath) end function HeroFund_Controller.GetTypeName(type) for name, index in pairs(LuaConst.ShowGoldenType) do if type == index then return name end end end function HeroFund_Controller.GetFuncIdByType(type) if type == LuaConst.ShowGoldenType.Hero then return MDL.Unlock.FunctionType.HeroFund elseif type == LuaConst.ShowGoldenType.Horse then return MDL.Unlock.FunctionType.HorseFund elseif type == LuaConst.ShowGoldenType.Treasure then return MDL.Unlock.FunctionType.TreasureFund elseif type == LuaConst.ShowGoldenType.GoldIngot then return MDL.Unlock.FunctionType.GoldIngotFund end end function HeroFund_Controller.GetTypeByFuncId(funcId) if funcId == MDL.Unlock.FunctionType.HeroFund then return LuaConst.ShowGoldenType.Hero elseif funcId == MDL.Unlock.FunctionType.HorseFund then return LuaConst.ShowGoldenType.Horse elseif funcId == MDL.Unlock.FunctionType.TreasureFund then return LuaConst.ShowGoldenType.Treasure elseif funcId == MDL.Unlock.FunctionType.GoldIngotFund then return LuaConst.ShowGoldenType.GoldIngot end end --各系统的判断函数 function HeroFund_Controller.Get_Has_ReachMax_GetStarLevel_Func(type) if type == LuaConst.ShowGoldenType.Hero then return MDL.HeroSelect.IsHasHero, -- 每个系统分别判断是否拥有 CTL.HeroStar.IsHeroReachMaxStar, -- 是否突破到最大 MDL.HeroStar.GetHeroStarLevel -- 获得突破等级(下面是类似判断) elseif type == LuaConst.ShowGoldenType.Horse then return MDL.WarHorse.IsHasHorse, private.IsHorseReachMaxStar, CTL.WarHorse.GetCurHorousBreak elseif type == LuaConst.ShowGoldenType.Treasure then return MDL.Treasure.IsHasTreasure, private.IsTreasureReachMaxStar, private.GetTreasureLevel end end --endregion public func --region private func function private.IsHorseReachMaxStar(id) return CTL.WarHorse.GetNextBreakItemConfig(id) == nil end function private.IsTreasureReachMaxStar(id) return CTL.Treasure.GetNextBreakItemData(id) == nil end function private.GetTreasureLevel(id) return MDL.Treasure.GetTreasureInfo(id).TreasureInfo.starLevel end function private.InitSelectLimit() private.selectLimit = {} for _, v in pairs(LuaConst.ShowGoldenType) do private.selectLimit[v] = { qualityLimit = {}, banList = {} } end private.selectLimit[LuaConst.ShowGoldenType.Hero].qualityLimit = DataSheetManager.ConstData:GetDataByID("HeroFundHeroQuality").IntListValue private.selectLimit[LuaConst.ShowGoldenType.Hero].banList = DataSheetManager.ConstData:GetDataByID("HeroFundBanHero").IntListValue private.selectLimit[LuaConst.ShowGoldenType.Horse].qualityLimit = DataSheetManager.ConstData:GetDataByID("HorseFundHorseQuality").IntListValue private.selectLimit[LuaConst.ShowGoldenType.Horse].banList = DataSheetManager.ConstData:GetDataByID("HorseFundBanHorse").IntListValue private.selectLimit[LuaConst.ShowGoldenType.Treasure].qualityLimit = DataSheetManager.ConstData:GetDataByID("TreasureFundTreasureQuality").IntListValue private.selectLimit[LuaConst.ShowGoldenType.Treasure].banList = DataSheetManager.ConstData:GetDataByID("TreasureFundBanTreasure").IntListValue end --能否在选择列表里,跟账号是否拥有无关。不拥有就在列表里置灰 function private.CanSelect(type, id, quality) local data = private.selectLimit[type] --检查id是否被ban了 for _, v in ipairs(data.banList) do if id == v then return false end end --检查品质是否符合,没有配置就没有限制 if #data.qualityLimit == 0 then return true end for _, v in ipairs(data.qualityLimit) do if quality == v then return true end end end function private.UpdateSortList(type) private.sortType = type local list = {} private.sortedList[type] = list if type == LuaConst.ShowGoldenType.Hero then for _, v in DataSheetManager.HeroNum:GetEnumerator() do if private.CanSelect(type,v.ID,v.HeroQuality) and MDL.HideGolden.IsShowGoldenByID(LuaConst.ShowGoldenType.Hero, v.ID) then table.insert(list, v) end end elseif type == LuaConst.ShowGoldenType.Horse then for _, v in DataSheetManager.HorseData:GetEnumerator() do if private.CanSelect(type,v.HorseID,v.HorseQuality) and MDL.HideGolden.IsShowGoldenByID(LuaConst.ShowGoldenType.Horse, v.HorseID) then table.insert(list, v) end end elseif type == LuaConst.ShowGoldenType.Treasure then for _, v in DataSheetManager.TreasureData:GetEnumerator() do if private.CanSelect(type,v.TreasureID,v.TreasureQuality) and MDL.HideGolden.IsShowGoldenByID(LuaConst.ShowGoldenType.Treasure, v.TreasureID) then table.insert(list, v) end end end table.sort(list, private.SortOrder) end --新的排序需求,其中武将排序与HeroSelect里的规则不同。以后可能会复用: --玩家已拥有的(除去无法参与此活动的,如金将郭嘉)排在前面,, --优先按突破等级排序,突破等级相同按ID排序,突破满的特殊处理,放在最后。 --其他两个系统排序规则类似 function private.SortOrder(a, b) local idA local idB local type = private.sortType if type == LuaConst.ShowGoldenType.Hero then idA, idB = a.ID, b.ID elseif type == LuaConst.ShowGoldenType.Horse then idA, idB = a.HorseID, b.HorseID elseif type == LuaConst.ShowGoldenType.Treasure then idA, idB = a.TreasureID, b.TreasureID end local hasFunc = HeroFund_Controller.Get_Has_ReachMax_GetStarLevel_Func(type) local hasA = hasFunc(idA) local hasB = hasFunc(idB) if hasA and hasB then return private.SortBasicOrder(idA, idB) elseif hasA then return true elseif hasB then return false else return false -- 都没有就不排了 end end function private.SortBasicOrder(idA, idB) local _, reachMaxFunc = HeroFund_Controller.Get_Has_ReachMax_GetStarLevel_Func(private.sortType) local maxBreakA = reachMaxFunc(idA) local maxBreakB = reachMaxFunc(idB) if maxBreakA and maxBreakB then return idA > idB elseif maxBreakA then return false elseif maxBreakB then return true else --按突破等级排序 local _, _, getStarLevelFunc = HeroFund_Controller.Get_Has_ReachMax_GetStarLevel_Func(private.sortType) local heroBreakA = getStarLevelFunc(idA) local heroBreakB = getStarLevelFunc(idB) if heroBreakA > heroBreakB then return true elseif heroBreakA < heroBreakB then return false else return idA > idB end end end --endregion private func return HeroFund_Controller