local HideGolden_Model = {} local private = {} local EventSystem = require('Event/EventSystem') function HideGolden_Model.OnStartup() EventSystem.Regist(EventID.FunctionUpdateNotice_ShowOrHideGolden, private.SetFunctionUpdateGoldenList) private.hideGoldenHeroDict ={} -- 屏蔽的金将字典 private.hideGoldenHorseDict ={} -- 屏蔽的金马字典 private.hideGoldenTreasureDict ={} -- 屏蔽的金宝物字典 private.functionUpdateShowGoldenHeroDict ={} -- 版本更新显示的金将字典 private.functionUpdateShowGoldenHorseDict ={} -- 版本更新显示的金马字典 private.functionUpdateShowGoldenTreasureDict ={} -- 版本更新显示的金宝物字典 private.InitShowGoldenHeroDict() end --版本更新介绍的金色物品不需屏蔽 function private.SetFunctionUpdateGoldenList(isShow, goldenHero, goldenHorse, goldenTreasure) if isShow then for _, v in ipairs(goldenHero) do private.functionUpdateShowGoldenHeroDict[v] = true end for _, v in ipairs(goldenHorse) do private.functionUpdateShowGoldenHorseDict[v] = true end for _, v in ipairs(goldenTreasure) do private.functionUpdateShowGoldenTreasureDict[v] = true end else table.clear(private.functionUpdateShowGoldenHeroDict) table.clear(private.functionUpdateShowGoldenHorseDict) table.clear(private.functionUpdateShowGoldenTreasureDict) end EventSystem.Dispatch(EventID.HideGolden_DataChanged) end function private.InitShowGoldenHeroDict() for _,heroNum in DataSheetManager.HeroNum:GetEnumerator() do if heroNum.HeroQuality >= LuaConst.QualityColor.Gold then private.hideGoldenHeroDict[heroNum.ID] = heroNum.ID end end for i,horse in DataSheetManager.HorseData:GetEnumerator() do if horse.HorseQuality >= LuaConst.QualityColor.Gold then private.hideGoldenHorseDict[horse.HorseID] = horse.HorseID end end for i,treasure in DataSheetManager.TreasureData:GetEnumerator() do if treasure.TreasureQuality >= LuaConst.QualityColor.Gold then private.hideGoldenTreasureDict[treasure.TreasureID] = treasure.TreasureID end end -- 判断是否默认显示 for _,defaultCfg in DataSheetManager.DefaultDisplay:GetEnumerator() do if defaultCfg.Type == LuaConst.ShowGoldenType.Hero then if private.hideGoldenHeroDict[defaultCfg.RelatedID] then -- 表里配了是要默认显示的,不隐藏 private.hideGoldenHeroDict[defaultCfg.RelatedID] = nil end elseif defaultCfg.Type == LuaConst.ShowGoldenType.Horse then if private.hideGoldenHorseDict[defaultCfg.RelatedID] then private.hideGoldenHorseDict[defaultCfg.RelatedID] = nil end elseif defaultCfg.Type == LuaConst.ShowGoldenType.Treasure then if private.hideGoldenTreasureDict[defaultCfg.RelatedID] then private.hideGoldenTreasureDict[defaultCfg.RelatedID] = nil end end end end -- 判断金品质是否显示 -- 如果一键大号了,则获得了该金将,会显示出来 function HideGolden_Model.IsShowGoldenByID(goldenType, goldenID, replayLevelType) if goldenType == LuaConst.ShowGoldenType.Hero then local heroData = DataSheetManager.HeroNum:GetDataByID(goldenID) if heroData.HeroQuality < LuaConst.QualityColor.Gold then return heroData.isOpen -- 金将以下只走HeroNum的配置开关 end --以下是金将及以上的判断 if private.functionUpdateShowGoldenHeroDict[goldenID] then return true end local hideByDefaultDisplay = private.hideGoldenHeroDict[goldenID] if heroData.isOpen then --版本开放的金将 --走DefaultDisplay控制 if not hideByDefaultDisplay then --配置了就默认显示 return true else --没配置就走整卡或碎片 local pieceNum = MDL.Bag.GetItemCount(heroData.PieceItem) local heroItem = MDL.Bag.GetItemCount(heroData.HeroItem) local hasHero = MDL.HeroSelect.IsHasHero(goldenID) return pieceNum > 0 or heroItem > 0 or hasHero end else --版本没开放 if replayLevelType == LuaConst.LevelType.SyncPVP or replayLevelType == LuaConst.LevelType.SyncTeamPVP then --1v1和3v3回放需要走TestHero配置的(比如公平竞技回放筛选),出现过的就显示 for _, testHeroData in MDL.OperationActivity.TVTTestHero:GetEnumerator() do if testHeroData.HeroID == goldenID then local openCfg = replayLevelType == LuaConst.LevelType.SyncPVP and testHeroData.OneOnOne or testHeroData.ThreeToThree if openCfg == 1 then --当前时间在配置开始时间之后,即武将有人用过,就显示 local timeToOpen = UTL.Time.GetServerIntervalTimeByTimeId(testHeroData.OpenTime, true) - UTL.Time.GetDisplayDiffLocalTimeZone() if timeToOpen < 0 then return true end end break end end end return false --除了回放里的特殊规则,版本没开放的就不显示 end elseif goldenType == LuaConst.ShowGoldenType.Horse then if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HideGoldenHeroHorse) or MDL.WarHorse.IsHasHorse(goldenID) then return true end local horseData = DataSheetManager.HorseData:GetDataByHorseID(goldenID) if horseData.HorseQuality >= LuaConst.QualityColor.Gold then if private.functionUpdateShowGoldenHorseDict[goldenID] then return true end if MDL.Bag.GetItemCount(horseData.Item_Table[1].ItemID) > 0 then return true end return not private.hideGoldenHorseDict[goldenID] end elseif goldenType == LuaConst.ShowGoldenType.Treasure then if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HideGoldenHeroTreasure) or MDL.Treasure.IsHasTreasure(goldenID) then return true end local treasureData = DataSheetManager.TreasureData:GetDataByTreasureID(goldenID) if treasureData.TreasureQuality >= LuaConst.QualityColor.Gold then if private.functionUpdateShowGoldenTreasureDict[goldenID] then return true end if MDL.Bag.GetItemCount(treasureData.Item_Table[1].ItemID) > 0 then return true end return not private.hideGoldenTreasureDict[goldenID] end end return true end --region *****协议处理***** --开启的金将列表 function HideGolden_Model.SetOpenGoldenList(msg) if msg.GoldHeroes then for k,v in ipairs(msg.GoldHeroes) do if private.hideGoldenHeroDict[v] then private.hideGoldenHeroDict[v] = nil end end end if msg.GoldHorses then for k,v in ipairs(msg.GoldHorses) do if private.hideGoldenHorseDict[v] then private.hideGoldenHorseDict[v] = nil end end end if msg.GoldTreasures then for k,v in ipairs(msg.GoldTreasures) do if private.hideGoldenTreasureDict[v] then private.hideGoldenTreasureDict[v] = nil end end end end --endregion *****END协议处理***** return HideGolden_Model