local app = Fusion local Item = Class(function(self,_slot) self.Slot = _slot self.Index = 0 self.Name = "" self.Count = 0 self.Locked = false self.Id = 0 self.Link = "" self.Color = 0 self.Quality = 0 self.TooltipUpdated = false self.Tier = false self.Level = 0 self.Ammo = false self.Attributes = {} if _slot then self:update() end end) function Item:update() local index, icon, name, itemcount, locked if self.Slot > 60 then index, icon, name, itemcount, locked = GetBagItemInfo(self.Slot-60); else index = self.Slot icon, name, itemcount, locked = GetGoodsItemInfo(index); end self.Index = index self.Name = name self.Count = itemcount self.Locked = locked self.Link = GetBagItemLink(self.Index) -- Get Id and color if self.Link and self.Link ~= "" then local id, color = self.Link:match("Hitem:(%x*).*|cff(%x*)") id = tonumber(id, 16); -- Convert to decimal self.Id = id self.Color = color self.Quality = app.ColorToQualityTable[color] end end function Item:updateTooltipInfo() if self.Index == 0 then return end -- No index. Can't get tooltip. if self.TooltipUpdated then return end -- Already updated -- Set GameTooltip to bag slot GameTooltip:SetBagItem(self.Index) GameTooltip:Hide() -- Get GameTooltip info local attributes = {} local left, right for i = 1, 40 do left = _G[GameTooltip:GetName() .. "TextLeft" .. i] right = _G[GameTooltip:GetName() .. "TextRight" .. i] if left:IsVisible() then left = left:GetText() else break -- No More Lines end if left:find(Fusion.TextPattern.Rune) then break -- Ignore socketed runes and further lines. end if right:IsVisible() then right = right:GetText() else right = nil end if i > 1 then if left:find(Fusion.TextPattern.Level) then self.Level = tonumber(left:match(Fusion.TextPattern.Level.." (%d+)")) -- get level elseif left:find(Fusion.TextPattern.Tier) then -- get if tier self.Tier = true end end if right and right:find(Fusion.TextPattern.Ammo) then -- get if ammo self.Ammo = true end if right and right ~= "" and (left:find("^|c%x%x%x%x%x%x%x%x%+") or left:find("^%+")) then -- get stats table.insert(attributes, right) end end self.Attributes = attributes self.TooltipUpdated = true end -- Returns true id is armor or weapon (not ammunition) function Item:isGear() self:updateTooltipInfo() return (self.Tier and not self.Ammo) end -- Returns the tier level of the mana stone made from this item function Item:makesTier(tier) self:updateTooltipInfo() local level = self.Level if self.Quality then if self.Quality > 0 then level = level + 2 end if self.Quality > 1 then level = level + (self.Quality - 1) * 4 end return math.floor(level/20) + 1 == tier end return false end -- If item is on the in game item list function Item:isOnItemlist() local name = string.lower(self.Name) for k,v in pairs(app.Itemlist) do if tonumber(v) == self.Id or string.find(name,string.lower(v),1,true) then return true end end return false end -- If item is on the save list function Item:isSaveItem() local name = string.lower(self.Name) for k,v in pairs(app.SaveItem) do if name == string.lower(v) or tonumber(v) == self.Id then return true end end return false end -- Returns if item is a valid tier item function Item:isValidItem() local debugitems = false local function debug(...) if debugitems ~= true or self.Slot ~= 61 then return end app.Tool:SendMsg(table.concat({...},", "),"yellow") end if self.Locked then debug("Slot 1 is locked") return false end if not self:isGear() then debug("Slot 1 is not gear", "Tier", tostring(self.Tier), "Ammo", tostring(self.Ammo)) return false end if not self:makesTier(Fusion_Settings.ItemTier) then debug("Slot 1 does not make tier",Fusion_Settings.ItemTier, "Level", self.Level, "Quality", self.Quality) return false end local stats = #self.Attributes if stats > Fusion_Settings.MaxStats then debug("Slot 1 has too many stats",stats) return false end if stats == 0 and Fusion_Settings.UseCleanItems == false then debug("Slot 1 item not clean") return false end if not self:isValidColor() then debug("Slot 1 is not valid color") return false end if Fusion_Settings.UseItemlist and not self:isOnItemlist() then debug("Slot 1 is not on white list") return false end return true end -- check if the given item is a fusion stone function Item:isFusionStone() if self.Locked then return false end if Fusion_Settings.UseRandomFusionStones then if( self.Id == app.RandomFusionStone ) then return true; end end if Fusion_Settings.UseFusionStones then for i,v in pairs(app.FusionStone) do if( v == self.Id ) then return true; end end end if Fusion_Settings.UsePurifiedFusionStones then if( self.Id == app.PurifiedFusionStone ) then return true end end return false end -- check if the given item is a mana stone of the given tier function Item:isManaStone(tier) if self.Locked then return false end return app.ManaStone[tier] == self.Id end -- check if valid color(quality) function Item:isValidColor() if( self.Color == app.WHITE ) then return Fusion_Settings.White elseif( self.Color == app.GREEN ) then return Fusion_Settings.Green elseif( self.Color == app.BLUE ) then return Fusion_Settings.Blue elseif( self.Color == app.PURPLE ) then return Fusion_Settings.Purple end return false end -- Move to another slot function Item:moveTo(index) PickupBagItem(self.Index); PickupBagItem(index); end -- If slot is empty function Item:isEmpty() local icon, name, itemcount, locked = GetGoodsItemInfo(self.Index); self.Count = itemcount return itemcount == 0 end -- If the slot is locked function Item:isLocked() local icon, name, itemcount, locked = GetGoodsItemInfo(self.Index); return locked end function Item:pickup() PickupBagItem(self.Index) end -- Make the class available globally function app.Bag:getItem(slot) return Item(slot) end