| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- local UIPetRootCtr = class("UIPetRootCtr", require("UICtrBase"))
- local qiyueSlotUnlockCost
- local lockIds = {42,43,44,45,46,47}
- function UIPetRootCtr:Init(view)
- self.view = view
- end
- function UIPetRootCtr:SetData(data)
- if self.filterData == nil then
- self.filterData = {}
- self.filterData.raritySelections = {}
- self.filterData.attrSelections = {}
- self.filterData.typeSelections = {}
- self.isFilter = false
- end
- local val = GlobalConfig.Instance:GetConfigStrValue(350)
- if val ~= "" and val ~= nil then
- qiyueSlotUnlockCost = CommonUtil.DeserializeGlobalStrToTable(val)
- end
- self:RefreshCurPetBattleLock()
-
- self.asyncIdx = 0
- if data == nil then return end
- self.data = data
- end
- function UIPetRootCtr:GetShowDataRealLength()
- return self.showDatas and #self.showDatas or 0
- end
- function UIPetRootCtr:GetShowData(itemIndex)
- return self.showDatas and self.showDatas[itemIndex + 1] or nil
- end
- function UIPetRootCtr:RefreshCurPetBattleLock()
- self.unlockCount = 0
- for i = 1,#lockIds do
- local unLockState, val, content = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(lockIds[i])
- if unLockState then
- self.unlockCount = self.unlockCount + 1
- else
- self.curLockContent = content
- break
- end
- end
- end
- function UIPetRootCtr:GetPetBattleUnlockCount()
- return self.unlockCount
- end
- function UIPetRootCtr:CalcUnlockSlot(slotList)
- local state = false
- local idx = #slotList + 1
- local cost = qiyueSlotUnlockCost[idx]
- if not cost then
- return false
- end
- local costId = tonumber(cost[1])
- local costNum = tonumber(cost[2])
- local count = CommonUtil.GetOwnResCountByItemId(costId)
- return count >= costNum, idx, costId, count, costNum
- end
- function UIPetRootCtr:RefreshQiyueDatas()
- self:HasEnoughPet()
- if self.showDatas then return end
- self.showDatas = {}
- for i = 1, 6 do
- local data = CommonUtil.GetHeroLogicDataByUid(i)
- self.showDatas[#self.showDatas + 1] = data
- end
- CommonUtil.ArraySortSelections(self.showDatas, {Enum.TableSortRule.Up, Enum.TableSortRule.Down, Enum.TableSortRule.Down}, "id", "isBattle", "owned")
- end
- function UIPetRootCtr:RefreshPetDatas()
- local petDatasSource = ManagerContainer.DataMgr.PetDataMgr:GetPetDatas()
- --策划要求战力加入排序
- for _,v in pairs(petDatasSource) do
- v.totalFightPower = ManagerContainer.DataMgr.PetDataMgr:GetTotalFightPower(v.id)
- end
- local petDatas
- petDatas = CommonUtil.ArrayFilterSelections(petDatasSource, Enum.FilterType.AND, {"quality", "Attribute", "natureType"}, {self.filterData.raritySelections, self.filterData.attrSelections, self.filterData.typeSelections})
- if petDatas ~= nil then
- CommonUtil.ArraySortSelections(petDatas, Enum.TableSortRule.Down, "isBattle", "isRelevant", "isSupport", "quality", "level", "totalFightPower", "cfgId", "id")
- end
- if petDatas == nil then
- ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("NoCardTips3")
- end
-
- return petDatas
- end
- function UIPetRootCtr:SetFilterData(data, isFilter)
- self.filterData = data
- self.isFilter = isFilter
- end
- function UIPetRootCtr:GetFilterData()
- return self.filterData
- end
- function UIPetRootCtr:GetIsFilter()
- return self.isFilter
- end
- function UIPetRootCtr:HasEnoughPet()
- self.hasFreePet = false
- local petDatas = ManagerContainer.DataMgr.PetDataMgr:GetPetDatas()
- for i = 1, #petDatas do
- if not petDatas[i].isBattle and petDatas[i].qiyueHeroId == 0 then
- self.hasFreePet = true
- return
- end
- end
- end
- function UIPetRootCtr:HeroRemoveAllQiyueSlot(heroId)
- ManagerContainer.DataMgr.PetDataMgr:SendQiyueSlotOutReq(heroId, 0)
- end
- function UIPetRootCtr:SendQiyueUnlockReq(heroId)
- ManagerContainer.DataMgr.PetDataMgr:SendQiyueUnlockReq(heroId)
- end
- function UIPetRootCtr:CanFreeQiyuePet()
- return self.hasFreePet
- end
- function UIPetRootCtr:SetQueryPetId(id)
- self.queryPetId = id
- end
- function UIPetRootCtr:GetQueryPetId()
- return self.queryPetId
- end
- function UIPetRootCtr:GetAsyncIdx()
- self.asyncIdx = self.asyncIdx + 1
- return self.asyncIdx
- end
- function UIPetRootCtr:GetData()
- return self.data
- end
- function UIPetRootCtr:OnDispose()
- self.filterData = nil
- self.isFilter = nil
- self.showDatas = nil
- self.data = nil
- self.view = nil
- end
- return UIPetRootCtr
|