autoImport("BagTabData") BagMainTab = class("BagMainTab",BagTabData) function BagMainTab:ctor() self.holdPlaceData = ItemData.new("PlaceHolder",0) BagMainTab.super.ctor(self) end function BagMainTab:ResetPlaceHolder(item) if(self.holdPlaceData.index ~= item.index) then -- print("重設佔位 old:"..self.holdPlaceData.index.." new:"..item.index) self.dirty = true self.holdPlaceData.index = item.index end end function BagMainTab:ClearPlaceHolder() -- print("清除佔位") self.dirty = true self.holdPlaceData.index = 0 end function BagMainTab:ReArrange(serverSortedItems) self.dirty = true self:ClearPlaceHolder() -- self.items = {} if(serverSortedItems~=nil) then for i=1,#serverSortedItems do local sItem = serverSortedItems[i] local item = self.itemsMap[sItem.guid] if(item ~=nil) then item.index = sItem.index item.isNew = false; end end end end function BagMainTab:GetItems() if(self.dirty==true) then self.parsedItems = {unpack(self.items)} table.sort(self.parsedItems,function(l,r) return self:sortFunc(l,r) end) self.dirty = false if(self.holdPlaceData.index > 0) then table.insert(self.parsedItems,1,self.holdPlaceData) end end return self.parsedItems end function BagMainTab:sortFunc(left,right) if(left == nil) then return false elseif(right ==nil) then return true end if(left.index >right.index) then return true else return false end end --時裝切頁 BagFashionTab = class("BagFashionTab",BagTabData) function BagFashionTab:GetItems() if(self.dirty==true) then self.parsedItems = {unpack(self.items)} table.sort(self.parsedItems,function(l,r) return self:sortFunc(l,r) end) self.dirty = false end return self.parsedItems end function BagFashionTab:sortFunc(left,right) if(left.num == right.num) then if(left.staticData.Type ==right.staticData.Type)then if(left.staticData.Quality ==right.staticData.Quality)then return left.staticData.id >right.staticData.id else return left.staticData.Quality >right.staticData.Quality end else return left.staticData.Type right.num end return false end --裝備切頁 BagEquipTab = class("BagEquipTab",BagTabData) function BagEquipTab:SetProfess( pro ) -- print("BagEquipTab set pro "..pro) self.profess = pro end function BagEquipTab:sortFunc(left,right) if(left.equipInfo and right.equipInfo)then local leftCanEquip = left.equipInfo:CanUseByProfess(self.profess) local rightCanEquip = right.equipInfo:CanUseByProfess(self.profess) if(left.equipInfo.equipData.EquipType == right.equipInfo.equipData.EquipType)then if(leftCanEquip == rightCanEquip) then if(left.staticData.Type ==right.staticData.Type) then if(left.staticData.Quality ==right.staticData.Quality) then return left.staticData.id >right.staticData.id else return left.staticData.Quality >right.staticData.Quality end else -- if(left.equipInfo:IsWeapon() and right.equipInfo:IsWeapon()) then -- return leftCanEquip -- else return left.staticData.Type rstrLv else return l.staticData.id > r.staticData.id end end) return fitItems end function BagEquipTab:GetRefineItems() local fitItems = self:FilterRefineItems() table.sort(fitItems,function(l,r) if(l.staticData.id == r.staticData.id) then if(l.equipInfo and r.equipInfo)then return l.equipInfo.refinelv > r.equipInfo.refinelv else return true end else return l.staticData.id > r.staticData.id end end) return fitItems end function BagEquipTab:GetFitItems(staticID,refinelv,strengthlv) local res = {} refinelv = refinelv or 0 strengthlv = strengthlv or 0 local item for i=1,#self.items do item = self.items[i] if(item.staticData.id == staticID and item.equipInfo.refinelv==refinelv and item.equipInfo.strengthlv == strengthlv) then res[#res+1] = item end end return res end