local Treasure_Model = {} local private = {} local EventSystem = require('Event/EventSystem') local treasure_pb = require('Proto.treasure_pb') local resonance_info = require 'Proto/resonance_info_pb' local treasure_soul_opt_pb = require "Proto/treasure_soul_opt_pb" local hero_pb = require('Proto/hero_pb') function Treasure_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageTreasureActive, private.TreasureActiveResp) NetManager.RegisterMsgCB(MessageEnums.MessageTreasureBreak, private.TreasureBreakResp) NetManager.RegisterMsgCB(MessageEnums.MessageTreasureEquip, private.TreasureEquipResp) NetManager.RegisterMsgCB(MessageEnums.MessageTreasureSoulEquipOpt, private.TreasureSoulEquipOptResp) NetManager.RegisterMsgCB(MessageEnums.MessageTreasureSoulSlotRefresh, private.TreasureSoulSlotRefreshResp) NetManager.RegisterMsgCB(MessageEnums.MessageTreasureSoulSlotAttrChoose, private.TreasureSoulSlotAttrChooseResp) NetManager.RegisterMsgCB(MessageEnums.MessageTreasureSoulQualityUp, private.TreasureSoulQualityUpResp) private.soulCrystalInfoDic = {} -- Key为服务器存储的唯一id private.soulCrystalIDList = {} -- value为服务器存储的唯一id(仅仅作为战力排序使用,对外界不暴露) private.soulCrystalIDListForLevel = {} -- value为服务器存储的唯一id(仅仅作为背包排序使用,对外界不暴露) (等级>战力>ID) private.soulCrystalEquipDic = {} -- Key为TreasureId, value 为{id(服务器存储的唯一id) = {PosIndex, EnoughRecommend}} private.itemToTreasureDict = {} private.activeTreasureInfo = {} --[[ private.activeTreasureInfo[xxx] = { TreasureInfo = xxx, 服务器发来的信息 TreasureData = xxx, 表里的静态数据 TreasureId = xx, 宝物表里的ID EquipHeroId = xx, 装备该宝物的武将ID EnoughRecommendCount = xx, 装备的宝物身上所装备的魂晶满足倾好总数量 } ]]-- end Treasure_Model.RefineType = { Once = hero_pb.Once, -- 精炼1次 Ten = hero_pb.Ten, -- 精炼10次 } function Treasure_Model.GetTreasureIdByItemId(itemId) if not private.itemToTreasureDict[itemId] then for i, v in DataSheetManager.TreasureData:GetEnumerator() do --Item_Table是该宝物的激活道具列表,第一个表示该宝物的碎片 private.itemToTreasureDict[v.Item_Table[1].ItemID] = v.TreasureID end end if not private.itemToTreasureDict[itemId] then logging.error(LTAG.ERROR, "不存在宝物碎片Id为:", itemId, " 的宝物!!!请策划检查!!!") end return private.itemToTreasureDict[itemId] end function Treasure_Model.GetTreasureInfoList() return private.activeTreasureInfo end function Treasure_Model.GetTreasureInfo(treasureId) return private.activeTreasureInfo[treasureId] end function Treasure_Model.GetTreasureEquipHeroId(treasureId) if private.activeTreasureInfo[treasureId] then return private.activeTreasureInfo[treasureId].EquipHeroId end end --玩家是否拥有这个宝物 function Treasure_Model.IsHasTreasure(treasureID) return Treasure_Model.GetTreasureInfo(treasureID) ~= nil end -- 宝物装备的武将ID function Treasure_Model.GetEquippedHeroIDByTreasureID(treasureID) local treasureInfo = Treasure_Model.GetTreasureInfo(treasureID) if treasureInfo ~= nil and treasureInfo.EquipHeroId ~= nil then return treasureInfo.EquipHeroId end return 0 end function Treasure_Model.UpdateActiveTreasureInfo(msgId, treasureInfo, heroInfo) ----- Start 宝物魂晶相关数据处理(重置装备状态) Start ----- for _, treasureEquip in pairs(private.soulCrystalEquipDic) do for k, _ in pairs(treasureEquip) do if private.soulCrystalInfoDic[k] then private.soulCrystalInfoDic[k].equip = false -- 重置装备状态 end end end ----- End 宝物魂晶相关数据处理(重置装备状态) End ----- for i, v in ipairs(treasureInfo) do UTL.Attr.ProcessProtoAttrTable(v.attr.attrs) if private.activeTreasureInfo[v.Id] then private.activeTreasureInfo[v.Id].TreasureInfo = v else private.activeTreasureInfo[v.Id] = { TreasureInfo = v, TreasureData = DataSheetManager.TreasureData:GetDataByTreasureID(v.Id), TreasureID = v.Id } end ----- Start 宝物魂晶相关数据处理 Start ----- local treasureEquip = private.soulCrystalEquipDic[v.Id] if treasureEquip then table.clear(treasureEquip) else treasureEquip = {} private.soulCrystalEquipDic[v.Id] = treasureEquip end -- 先将魂晶装备信息设置好 for i, slotInfo in ipairs(v.soulSlotInfos) do if not string.isNilOrEmpty(slotInfo.soulCrystalId) then -- 0表示未镶嵌 treasureEquip[slotInfo.soulCrystalId] = {PosIndex = i, EnoughRecommend = false} end end -- 在设置魂晶是否符合倾好(依赖装备位置) for _, v in pairs(treasureEquip) do v.EnoughRecommend = CTL.Treasure.SoulCrystalEnoughRecommend(v.Id, v.PosIndex) end ----- End 宝物魂晶相关数据处理 End ----- end ----- Start 宝物魂晶相关数据处理(设置装备状态) Start ----- for _, treasureEquip in pairs(private.soulCrystalEquipDic) do for k, _ in pairs(treasureEquip) do if private.soulCrystalInfoDic[k] then private.soulCrystalInfoDic[k].equip = true -- 设置装备状态 end end end ----- End 宝物魂晶相关数据处理(设置装备状态) End ----- private.UpdateEquipTreasureInfo(heroInfo) if msgId ~= MessageEnums.MessageTreasureSoulSlotRefresh then EventSystem.Dispatch(EventID.UI_UpdateTreasureInfo) --刷新宝物图鉴 EventSystem.Dispatch(EventID.UI_Illustration_TreasureLibrary_RefreshBase) EventSystem.Dispatch(EventID.UI_Illustration_TreasureLibrary_RefreshPopUp) -- 纳灵系统刷新 MDL.Reborn.SyncRFMaterialDic(MDL.Reborn.RFMaterialType.Treasure) end end function private.UpdateEquipTreasureInfo(heroInfo) for i, v in ipairs(heroInfo) do local treasureInfo = Treasure_Model.GetTreasureInfoByHeroId(v.heroId) if IsProtoDataNotNil(v.treasureInfo) then if treasureInfo then treasureInfo.EquipHeroId = nil end local info = private.activeTreasureInfo[v.treasureInfo.Id] if info then info.EquipHeroId = v.heroId end end end end function Treasure_Model.GetTreasureInfoByHeroId(heroId) for i, v in pairs(private.activeTreasureInfo) do if v.EquipHeroId == heroId then return v end end end local TreasureState = { UnActive = 0, --未激活 UnEquip = 1, --激活未装备 Equipped = 2, --已装备 CanActive = 3, --可激活 } function private.GetTreasureState(treasureId) local info = private.activeTreasureInfo[treasureId] if info then return info.EquipHeroId ~= nil and TreasureState.Equipped or TreasureState.UnEquip else return CTL.Treasure.IfTreasureCanActive(treasureId) and TreasureState.CanActive or TreasureState.UnActive end end --排序规则:可激活-已装备-激活但未装备-未激活--品质高低--id从小到大 function private.SortTreasureByState(a,b) local state_a = private.GetTreasureState(a.TreasureID) local state_b = private.GetTreasureState(b.TreasureID) if state_a ~= state_b then return state_a > state_b else if a.TreasureQuality ~= b.TreasureQuality then return a.TreasureQuality > b.TreasureQuality else return a.TreasureID < b.TreasureID end end end --获取排好序的宝物列表 function Treasure_Model.GetSortedTreasureList() -- 加了金将屏蔽逻辑,删掉了判空 private.sortedTreasureList = {} local index = 1 for i, v in DataSheetManager.TreasureData:GetEnumerator() do if MDL.HideGolden.IsShowGoldenByID(LuaConst.ShowGoldenType.Treasure, v.TreasureID) then -- 屏蔽金宝物的判断 private.sortedTreasureList[index] = v index = index + 1 end end table.sort(private.sortedTreasureList, private.SortTreasureByState) return private.sortedTreasureList end function Treasure_Model.TreasureActiveReq(treasureId) local msg = treasure_pb.TreasureActiveReq() msg.treasureId = treasureId NetManager.SendMessage(MessageEnums.MessageTreasureActive, msg) end function private.TreasureActiveResp(msgResp) if msgResp.Resp.Code == 0 then BIManager.DispatchBIClientEvent(BIManager.EventName.TreasureActivation) EventSystem.Dispatch(EventID.UI_ActiveTreasureSuccess) UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UITreasureActiveSuccess, {treasureId = msgResp.treasureId}) --CTL.Sound.PlayGameSound("UI_hores_active") end end function Treasure_Model.TreasureBreakReq(treasureId) local msg = treasure_pb.TreasureBreakReq() msg.treasureId = treasureId NetManager.SendMessage(MessageEnums.MessageTreasureBreak, msg) end function private.TreasureBreakResp(msgResp) if msgResp.Resp.Code == 0 then local curInfo = private.activeTreasureInfo[msgResp.treasureId] if curInfo.TreasureInfo.starStage == 0 then --大突破 MDL.FormationResonance.SetSubResonanceOprType(resonance_info.Treasure_Break) UIManager.OpenView(Const_UI_Lua.UIEnum.UITreasureBreakSuccess, {treasureId = msgResp.treasureId}, "Common/UICommonBreakSuccess") --EventSystem.Dispatch(EventID.UI_PlayHorseAnim) end EventSystem.Dispatch(EventID.UI_TreasureBreakSuccess) end end function Treasure_Model.TreasureEquipReq(heroId, treasureId, resultCode) local msg = treasure_pb.TreasureEquipReq() msg.heroId = heroId msg.treasureId = treasureId -- 缓存更换宝物前后的武将 local belongHeroInfo = Treasure_Model.GetTreasureEquipHeroId(treasureId) local oldTreasureBelongHeroID = belongHeroInfo and belongHeroInfo or 0 private.equipMsgCode = {EquipMsgCode = resultCode, heroID = heroId, oldTreasureBelongHeroID = oldTreasureBelongHeroID} NetManager.SendMessage(MessageEnums.MessageTreasureEquip, msg) end function private.TreasureEquipResp(msgResp) if msgResp.Resp.Code == 0 then CTL.Tips.AddTipsMsg(private.equipMsgCode.EquipMsgCode) CTL.Treasure.ChangeEquipTreasure(private.equipMsgCode.heroID, private.equipMsgCode.oldTreasureBelongHeroID) end end --region-------------------------------------------宝物魂晶-------------------------------------------- -- 排序(战力>等阶>id) local function SortSoulCrystalByGS(a, b) local soulInfoA = private.soulCrystalInfoDic[a] local soulInfoB = private.soulCrystalInfoDic[b] if soulInfoA.attrGS == soulInfoB.attrGS then if soulInfoA.soulData.Color == soulInfoB.soulData.Color then return soulInfoA.cfgId > soulInfoB.cfgId else return soulInfoA.soulData.Color > soulInfoB.soulData.Color end else return soulInfoA.attrGS > soulInfoB.attrGS end end -- 排序(等阶>战力>id) local function SortSoulCrystalByLevel(a, b) local soulInfoA = private.soulCrystalInfoDic[a] local soulInfoB = private.soulCrystalInfoDic[b] if soulInfoA.soulData.Color == soulInfoB.soulData.Color then if soulInfoA.attrGS == soulInfoB.attrGS then return soulInfoA.cfgId > soulInfoB.cfgId else return soulInfoA.attrGS > soulInfoB.attrGS end else return soulInfoA.soulData.Color > soulInfoB.soulData.Color end end -- enter_world 时全量同步, 需要在 UpdateActiveTreasureInfo 之前 function Treasure_Model.SyncBagSoulCrystal(soulCrystals, soulCrystalExtras) -- 同步背包数据 for _, v in ipairs(soulCrystals) do local soulCrystalData = private.soulCrystalInfoDic[v.id] if not soulCrystalData then private.soulCrystalInfoDic[v.id] = { id = v.id, cfgId = v.cfgId, equip = false, soulData = DataSheetManager.TreasureSoulCrystalData:GetDataByCrystalID(v.cfgId), } table.insert(private.soulCrystalIDList, v.id) table.insert(private.soulCrystalIDListForLevel, v.id) end end -- 同步魂晶属性 for _, v in ipairs(soulCrystalExtras) do local soulCrystalData = private.soulCrystalInfoDic[v.id] if soulCrystalData then local baseAttrList = {} for _, attr in ipairs(v.baseAttrs) do table.insert(baseAttrList, {AttrType = attr.AttrType, AttrNum = attr.AttrNum, PercentBlockId = attr.percentBlockId}) end soulCrystalData.baseAttrList = baseAttrList -- 计算战力(基础战力,无倾好加成) soulCrystalData.attrGS = UTL.Attr.CalculateFight(baseAttrList) -- 这个战力没有计算倾好加成 end end -- 排序 table.sort(private.soulCrystalIDList, SortSoulCrystalByGS) table.sort(private.soulCrystalIDListForLevel, SortSoulCrystalByLevel) end -- player_change 时使用增量更新, 需要在 UpdateActiveTreasureInfo 之前 function Treasure_Model.UpdateBagSoulCrystal(addSoulCrystals, addSoulCrystalExtras) -- 记录一下id为发生变化 但是 cfgId发生变化的魂晶,用于升阶事件 local advancedDic = {} -- 更新魂晶背包数据 for _, v in ipairs(addSoulCrystals) do local soulCrystalData = private.soulCrystalInfoDic[v.id] if not soulCrystalData then soulCrystalData = {id = v.id} private.soulCrystalInfoDic[v.id] = soulCrystalData table.insert(private.soulCrystalIDList, v.id) table.insert(private.soulCrystalIDListForLevel, v.id) end if soulCrystalData.cfgId and soulCrystalData.cfgId > 0 and soulCrystalData.cfgId ~= v.cfgId then -- 将升阶之前的 attrType和attrNum记录下来 local beforeBaseAttrList = {} for i, attr in ipairs(soulCrystalData.baseAttrList) do table.insert(beforeBaseAttrList, {AttrType = attr.AttrType, AttrNum = attr.AttrNum, PercentBlockId = attr.PercentBlockId}) end advancedDic[v.id] = {beforeCfgId = soulCrystalData.cfgId, beforeBaseAttrList = beforeBaseAttrList} -- 记录升阶之前的数值 end soulCrystalData.cfgId = v.cfgId soulCrystalData.equip = private.JudgeIsEquip(v.id) soulCrystalData.soulData = DataSheetManager.TreasureSoulCrystalData:GetDataByCrystalID(v.cfgId) end -- 更新魂晶属性数据 for _, v in ipairs(addSoulCrystalExtras) do local soulCrystalData = private.soulCrystalInfoDic[v.id] if soulCrystalData then -- 使用 属性也是个数组 也使用增量更新(减少频繁开辟table带来的消耗) local baseAttrList = soulCrystalData.baseAttrList if not baseAttrList then baseAttrList = {} soulCrystalData.baseAttrList = baseAttrList end for i, attr in ipairs(v.baseAttrs) do local attrData = baseAttrList[i] if not attrData then attrData = {} baseAttrList[i] = attrData end attrData.AttrType = attr.AttrType attrData.AttrNum = attr.AttrNum attrData.PercentBlockId = attr.percentBlockId end -- 倒序移除 for i = #baseAttrList, #v.baseAttrs + 1, -1 do table.remove(baseAttrList) end -- 计算战力(基础战力,无倾好加成) soulCrystalData.attrGS = UTL.Attr.CalculateFight(baseAttrList) -- 这个战力没有计算倾好加成 end end -- 排序 table.sort(private.soulCrystalIDList, SortSoulCrystalByGS) table.sort(private.soulCrystalIDListForLevel, SortSoulCrystalByLevel) EventSystem.Dispatch(EventID.TreasureSoulCrystal_UpdateBag) -- 如果 有cfgId变化的魂晶 需要发送一下升阶事件 if next(advancedDic) then EventSystem.Dispatch(EventID.TreasureSoulCrystal_RefreshAdvancedSucceed, advancedDic) end end -- player_change 时使用增量更新, 需要在 UpdateActiveTreasureInfo 之前 function Treasure_Model.DelBagSoulCrystal(delSoulCrystals) if not IsProtoDataNotNil(delSoulCrystals) then return end -- 移除(排序列表)对应魂晶 for _, id in ipairs(delSoulCrystals) do private.soulCrystalInfoDic[id] = nil local index = 0 for i, v in ipairs(private.soulCrystalIDList) do if v == id then index = i break end end table.remove(private.soulCrystalIDList, index) index = 0 for i, v in ipairs(private.soulCrystalIDListForLevel) do if v == id then index = i break end end table.remove(private.soulCrystalIDListForLevel, index) end -- 排序 table.sort(private.soulCrystalIDList, SortSoulCrystalByGS) table.sort(private.soulCrystalIDListForLevel, SortSoulCrystalByLevel) EventSystem.Dispatch(EventID.TreasureSoulCrystal_UpdateBag) end -- 宝物御魂-装备/卸下魂晶req --[[ bool isPutOn = 2; // 是否是装备操作 bool isAuto = 3; // 是否是一键操作 int32 treasureId = 4; // 宝物Id string crystalIds = 5; // 如果不是一键操作,则需要指定一个魂晶Id,否则需要指定5个 int32 posNum = 6; // 如果不是一键操作,则需要指定操作的位置编号(1-5) --]] function Treasure_Model.TreasureSoulEquipOptReq(isPutOn, isAuto, treasureId, crystalIdList, posIndex) local msg = treasure_soul_opt_pb.TreasureSoulEquipOptReq() msg.isPutOn = isPutOn msg.isAuto = isAuto msg.treasureId = treasureId for _, id in ipairs(crystalIdList) do table.insert(msg.crystalIds, id) end if posIndex then msg.posNum = posIndex end NetManager.SendMessage(MessageEnums.MessageTreasureSoulEquipOpt, msg) end -- 宝物御魂-装备/卸下魂晶resp function private.TreasureSoulEquipOptResp(msgResp) if msgResp.Resp.Code == 0 then if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UITreasureSoulCrystalShow) then UIManager.CloseView(Const_UI_Lua.UIEnum.UITreasureSoulCrystalShow) end if msgResp.isPutOn then EventSystem.Dispatch(EventID.TreasureSoulCrystal_RefreshEquipEffect, msgResp.treasureId, msgResp.posNums) end end end -- 宝物御魂-孔位洗练req --[[ int32 treasureId = 2; // 宝物Id int32 posNum = 3; // 宝物孔位的编号(1-5) int32 lockNum = 4; // 锁定的条目列表 uint32 refineID = 5; // 洗练id RefineType refreshType = 6; // 洗练次数type --]] function Treasure_Model.TreasureSoulSlotRefreshReq(treasureId, posIndex, lockNumDic, refineID, refineType) -- 计算是否满足消耗 local refineItem = DataSheetManager.TreasureSoulRefineItem:GetDataByRefineID_LockNum(refineID, table.getDictCount(lockNumDic)) for _, cost in ipairs(refineItem.Item_Table) do local ownItemCount = UTL.Item.GetItemStockCount(cost.ItemID) local times = refineType == Treasure_Model.RefineType.Once and 1 or 10 if ownItemCount < cost.ItemNum * times then -- 不满足道具 直接跳出 给出提示 CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1011_InfoCode_Item_Not_Enough) return end end local msg = treasure_soul_opt_pb.TreasureSoulSlotRefreshReq() msg.treasureId = treasureId msg.posNum = posIndex for lockIndex, _ in pairs(lockNumDic) do table.insert(msg.lockNum, lockIndex) end msg.refineID = refineID msg.refreshType = refineType NetManager.SendMessage(MessageEnums.MessageTreasureSoulSlotRefresh, msg) end -- 宝物御魂-孔位洗练resp function private.TreasureSoulSlotRefreshResp(msgResp) EventSystem.Dispatch(EventID.TreasureSoulCrystal_UpdateRefined, msgResp.refreshType) if msgResp.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_TreasureSoul_WashSuccess) end end --TODO 10条精炼 -- 宝物御魂-孔位洗练属性选择req --[[ int32 treasureId = 2; // 宝物Id int32 posNum = 3; // 宝物孔位的编号(1-5) bool isUseNew = 4; // 是否使用刷新出来的新属性 int32 chooseIndex = 5; // 选中的精炼数据index(0-9) --]] function Treasure_Model.TreasureSoulSlotAttrChooseReq(treasureId, posIndex, isUseNew, chooseIndex) local msg = treasure_soul_opt_pb.TreasureSoulSlotAttrChooseReq() msg.treasureId = treasureId msg.posNum = posIndex msg.isUseNew = isUseNew msg.chooseIndex = chooseIndex or 0 NetManager.SendMessage(MessageEnums.MessageTreasureSoulSlotAttrChoose, msg) end -- 宝物御魂-孔位洗练属性选择resp function private.TreasureSoulSlotAttrChooseResp(msgResp) EventSystem.Dispatch(EventID.TreasureSoulCrystal_UpdateRefined) if msgResp.Resp.Code == 0 and UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UITreasureSoulCrystalRefinedPanel02) then UIManager.CloseView(Const_UI_Lua.UIEnum.UITreasureSoulCrystalRefinedPanel02) end end -- 宝物御魂-魂晶升阶req --[[ string crystalId = 2; // 主Id string otherIds = 3; // 副材料Id列表 int32 treasureId = 4; // 宝物Id,背包里的填0 int32 posNum = 5; // 需要升阶的魂晶所在的宝物孔位的编号(1-5),背包里的填0 --]] function Treasure_Model.TreasureSoulQualityUpReq(crystalId, otherIdDic, treasureId, posIndex) local msg = treasure_soul_opt_pb.TreasureSoulQualityUpReq() msg.crystalId = crystalId for _, id in pairs(otherIdDic) do table.insert(msg.otherIds, id) end if treasureId then msg.treasureId = treasureId else msg.treasureId = 0 end if posIndex then msg.posNum = posIndex else msg.posNum = 0 end NetManager.SendMessage(MessageEnums.MessageTreasureSoulQualityUp, msg) end -- 宝物御魂-魂晶升阶resp function private.TreasureSoulQualityUpResp(msgResp) if msgResp.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_TreasureSoul_ShengJieChengGong) end end ---------- Start 数据相关 Start ---------- Treasure_Model.SoulSlotAttrState = { NotOpen = 0, NotValue = 1, Effective = 2, } local function PairsValueByType(tab, param) param.index = param.index + 1 local id = tab[param.index] local data = private.soulCrystalInfoDic[id] if data then if param.soulCrystalType == 0 or param.soulCrystalType == data.soulData.CrystalType then return param, data end return PairsValueByType(tab, param) -- 递归遍历下一个 else return nil end end local function PairsValueByCrystalGroup(tab, param) param.index = param.index + param.step local id = tab[param.index] local data = private.soulCrystalInfoDic[id] if data then if param.crystalGroup == data.soulData.CrystalGroup then return param, data end return PairsValueByCrystalGroup(tab, param) -- 递归遍历下一个 else return nil end end local function PairsSoulCrystalValue(tab, param) param.index = param.index + param.step local id = tab[param.index] local data = private.soulCrystalInfoDic[id] if data then return param, data else return nil end end -- 根据等阶 从高到低 function Treasure_Model.GetSoulCrystalIteratorByType(soulCrystalType) return PairsValueByType, private.soulCrystalIDListForLevel, {index = 0, soulCrystalType = soulCrystalType} end -- 根据战力 --[[ isForwardDirection: 为true 表示从高到低返回、为false 表示从低到高返回 --]] function Treasure_Model.GetSoulCrystalIteratorByCrystalGroup(crystalGroup, isForwardDirection) if isForwardDirection then return PairsValueByCrystalGroup, private.soulCrystalIDList, {index = 0, step = 1, crystalGroup = crystalGroup} else return PairsValueByCrystalGroup, private.soulCrystalIDList, {index = #private.soulCrystalIDList + 1, step = -1, crystalGroup = crystalGroup} end end -- 根据战力 --[[ isForwardDirection: 为true 表示从高到低返回、为false 表示从低到高返回 --]] function Treasure_Model.GetSoulCrystalIterator(isForwardDirection) if isForwardDirection then return PairsSoulCrystalValue, private.soulCrystalIDList, {index = 0, step = 1} else return PairsSoulCrystalValue, private.soulCrystalIDList, {index = #private.soulCrystalIDList + 1, step = -1} end end -- 根据服务器存储唯一id获取魂晶数据 function Treasure_Model.GetSoulCrystalById(id) return private.soulCrystalInfoDic[id] end -- 根据宝物id获取该宝物装备的魂晶列表 function Treasure_Model.GetEquipDicByTreasureId(treasureId) return private.soulCrystalEquipDic[treasureId] end -- 根据itemId获取 对应魂晶的数量 function Treasure_Model.GetSoulCrystalCountByItemId(itemId) local count = 0 for _, info in pairs(private.soulCrystalInfoDic) do if info.cfgId == itemId then count = count + 1 end end return count end function private.JudgeIsEquip(soulId) for _, equipDic in pairs(private.soulCrystalEquipDic) do for id, _ in pairs(equipDic) do if id == soulId then return true end end end return false end ---------- End 数据相关 End ---------- --endregion return Treasure_Model