Quantcast

Item value bug fixed, various small things added. Default list settings added

ckaotik [03-12-10 - 21:00]
Item value bug fixed, various small things added. Default list settings added
Filename
core.lua
deDE.lua
enUS.lua
lootmanager.lua
options.lua
diff --git a/core.lua b/core.lua
index abea259..2fa7555 100644
--- a/core.lua
+++ b/core.lua
@@ -82,7 +82,7 @@ BrokerGarbage.defaultLocalSettings = {
 }

 -- internal locals
-local debug = false
+local debug = true
 local locked = false
 local loaded = false
 local sellValue = 0		-- represents the actual value that we sold stuff for, opposed to BrokerGarbage.toSellValue which shows the maximum we could sell - imagine someone closing the merchant window. sellValue will then hold the real value we're interested in
@@ -285,12 +285,73 @@ function BrokerGarbage:CheckSettings()
 	end
 end

-function BrokerGarbage:CreateDefaultLists()
+BrokerGarbage.tradeSkills = {
+	[2] = "Leatherworking",
+	[3] = "Tailoring",
+	[4] = "Engineering",
+	[5] = "Blacksmithing",
+	[6] = "Cooking",
+	[7] = "Alchemy",
+	[8] = "First Aid",
+	[9] = "Enchanting",
+	[10] = "Fishing",
+	[11] = "Jewelcrafting",
+	[12] = "Inscription",
+}
+-- returns original English names for non-English locales
+function BrokerGarbage:UnLocalize(skillName)
+	if not skillName then return nil end
+	if string.find(GetLocale(), "en") then return skillName end
+
+	-- crafting skills
+	local searchString = ""
+	for i=2,12 do
+		searchString = select(i, GetAuctionItemSubClasses(9))
+		if string.find(skillName, searchString) then
+			return BrokerGarbage.tradeSkills[i]
+		end
+	end
+
+	-- gathering skills
+	local skill
+	if skillName == GetSpellInfo(8613) then
+		skill = "Skinning"
+	elseif skillName == GetSpellInfo(2575) then
+		skill = "Mining"
+	elseif skillName == GetSpellInfo(2366) then
+		-- herbalism sucks
+		source = GetAuctionItemSubClasses(6)
+		if string.find(skillName, source[6]) then
+			skill = "Herbalism"
+		end
+	end
+
+	return skill
+end
+
+-- inserts some basic list settings
+function BrokerGarbage:CreateDefaultLists()
 	BG_GlobalDB.include[46106] = true		-- argentum lance
 	BG_GlobalDB.include[6265] = 20			-- soulshards
 	BG_GlobalDB.include["Consumable.Water.Conjured"] = true
+	BG_GlobalDB.forceVendorPrice["Consumable.Food.Edible"] = true
+	BG_GlobalDB.forceVendorPrice["Consumable.Water.Basic"] = true

-	BG_LocalDB.exclude["Tradeskill.Mat"] = true
+	-- tradeskills
+	local tradeSkills = BrokerGarbage:CheckSkills()
+	local numSkills = #tradeSkills or 0
+	for i = 1, numSkills do
+		local englishSkill = BrokerGarbage:UnLocalize(tradeSkills[i][1])
+		if englishSkill then
+			if tradeSkills[i][2] then
+				BG_LocalDB.exclude["Tradeskill.Gather."..englishSkill] = true
+			else
+				BG_LocalDB.exclude["Tradeskill.Mat.ByProfession."..englishSkill] = true
+			end
+		end
+	end
+
+	-- class specific
 	if BrokerGarbage.playerClass == "HUNTER" then
 		BG_LocalDB.exclude["Misc.Reagent.Ammo"] = true
 	elseif BrokerGarbage.playerClass == "WARRIOR" or BrokerGarbage.playerClass == "ROGUE" or BrokerGarbage.playerClass == "DEATHKNIGHT" then
@@ -300,9 +361,6 @@ function BrokerGarbage:CreateDefaultLists()
 		BG_LocalDB.include[17057] = 20		-- scales
 	end
 	BG_LocalDB.exclude["Misc.Reagent.Class."..string.gsub(string.lower(BrokerGarbage.playerClass), "^.", string.upper)] = true
-
-	BG_GlobalDB.forceVendorPrice["Consumable.Food.Edible"] = true
-	BG_GlobalDB.forceVendorPrice["Consumable.Water.Basic"] = true
 end

 function BrokerGarbage:FormatMoney(amount)
@@ -434,6 +492,7 @@ function BrokerGarbage:ResetList(which)
 	end
 end

+-- resets statistics. global = true -> global, otherwise local
 function BrokerGarbage:ResetAll(global)
 	if global then
 		BG_GlobalDB.moneyEarned = 0
@@ -446,11 +505,14 @@ function BrokerGarbage:ResetAll(global)
 	end
 end

+-- returns an item's itemID
 function BrokerGarbage:GetItemID(itemLink)
+	if not itemLink then return end
 	local itemID = string.gsub(itemLink, ".*|Hitem:([0-9]*):.*", "%1")
 	return tonumber(itemID)
 end

+-- returns the skill rank of a given tradeskill, or nil
 function BrokerGarbage:GetTradeSkill(skillName)
 	for i=1, GetNumSkillLines() do
 		local name, _, _, skillRank, _, _, _, _, _, _, _, _, _ = GetSkillLineInfo(i)
@@ -461,6 +523,23 @@ function BrokerGarbage:GetTradeSkill(skillName)
 	return nil
 end

+-- returns all tradeskills found
+function BrokerGarbage:CheckSkills()
+	local result = {}
+	for i=1, GetNumSkillLines() do
+		local name, _, _, skillRank, _, _, _, tradeSkill = GetSkillLineInfo(i)
+		if tradeSkill then
+			local isGather = true
+			if name == GetSpellInfo(2259) or name == GetSpellInfo(2018) or name == GetSpellInfo(7411) or name == GetSpellInfo(4036) or name == GetSpellInfo(45357) or name == GetSpellInfo(25229) or name == GetSpellInfo(2108) or name == GetSpellInfo(3908) then
+				-- crafting skill
+				isGather = false
+			end
+			tinsert(result, {name, isGather, skillRank})
+		end
+	end
+	if result == {} then return nil else return result end
+end
+
 function BrokerGarbage:CanDisenchant(itemLink)
 	if (itemLink) then
 		local _, _, quality, level, _, _, _, count, slot = GetItemInfo(itemLink)
@@ -695,10 +774,10 @@ function BrokerGarbage:GetItemValue(itemLink, count)

 	local maximum = math.max((disenchantPrice or 0), (auctionPrice or 0), (vendorPrice or 0))
 	if vendorPrice and maximum == vendorPrice then
-		return vendorPrice, BrokerGarbage.tagVendor
+		return vendorPrice*count, BrokerGarbage.tagVendor

 	elseif auctionPrice and maximum == auctionPrice then
-		return auctionPrice, BrokerGarbage.tagAuction
+		return auctionPrice*count, BrokerGarbage.tagAuction

 	elseif disenchantPrice and maximum == disenchantPrice then
 		return disenchantPrice, BrokerGarbage.tagDisenchant
@@ -934,7 +1013,7 @@ function BrokerGarbage:ScanInventory()

 	if cheapestItem ~= {} then
 		LDB.text = format(BG_GlobalDB.LDBformat,
-			select(2,GetItemInfo(cheapestItem[1].itemID)),
+			(cheapestItem ~= {} and select(2,GetItemInfo(cheapestItem[1].itemID)) or BrokerGarbage.locale.label),
 			cheapestItem[1].count,
 			BrokerGarbage:FormatMoney(cheapestItem[1].value),
 			BrokerGarbage.totalFreeSlots,
diff --git a/deDE.lua b/deDE.lua
index a096b04..f1d1b1e 100644
--- a/deDE.lua
+++ b/deDE.lua
@@ -15,6 +15,7 @@ BrokerGarbage.locale = {
 	addedToPriceList = "Für %s wird nun nur der Händlerpreis genutzt.",
 	addedToIncludeList = "%s zur Einschlussliste hinzugefügt.",
 	addedToSellList = "%s wird bei Händlern automatisch verkauft.",
+	limitSet = "Für %s wurde das Limit auf %d gesetzt.",
 	itemDeleted = "%s wurde gelöscht.",

 	openPlease = "Bitte öffne %s - es nimmt unnötig Platz weg.",
diff --git a/enUS.lua b/enUS.lua
index 91a60d8..ba69718 100644
--- a/enUS.lua
+++ b/enUS.lua
@@ -15,6 +15,7 @@ BrokerGarbage.locale = {
 	addedToPriceList = "%s will only have its vendor price considered.",
 	addedToIncludeList = "%s has been added to the Include List.",
 	addedToSellList = "%s will be automatically sold when at a merchant.",
+	limitSet = "%s has been assigned a limit of %d.",
 	itemDeleted = "%s has been deleted.",

 	openPlease = "Please open your %s. It's in your bags, stealing your space!",
diff --git a/lootmanager.lua b/lootmanager.lua
index e1d505a..4057302 100644
--- a/lootmanager.lua
+++ b/lootmanager.lua
@@ -354,6 +354,7 @@ function BrokerGarbage:SelectiveLooting(autoloot)
 	local mobType = UnitCreatureType("target") == BrokerGarbage.locale.CreatureTypeBeast

 	if autoloot ~= 0 or BG_GlobalDB.autoLoot or (BG_GlobalDB.autoLootPickpocket and BrokerGarbage.playerClass == "ROGUE" and IsStealthed()) or (BG_GlobalDB.autoLootFishing and IsFishingLoot()) then
+		BrokerGarbage:Debug("Autoloot (selectiveLooting)")
 		for slot = 1,numItems do
 			if LootSlotIsItem(slot) then
 				_, _, quantity,  quality, locked = GetLootSlotInfo(slot)
@@ -361,8 +362,10 @@ function BrokerGarbage:SelectiveLooting(autoloot)

 				-- check if we even want this!
 				if BrokerGarbage:IsInteresting(itemLink) then
+					BrokerGarbage:Debug("Interesting Item", itemLink)
 					if not locked then
 						if BrokerGarbage.totalFreeSlots <= BG_GlobalDB.tooFewSlots then
+							BrokerGarbage:Debug("We're out of space!")
 							-- try to compress and make room
 							local itemID = BrokerGarbage:GetItemID(itemLink)
 							local maxStack = select(8, GetItemInfo(itemID))
@@ -377,8 +380,9 @@ function BrokerGarbage:SelectiveLooting(autoloot)
 									BrokerGarbage:Debug("Item can be made to fit.", itemLink)
 									looted = true
 								end
-							elseif inBags > 0 then
+							elseif inBags > 0 and maxStack <= (inBags + quantity) then
 								-- this item fits without us doing anything
+								BrokerGarbage:Debug("Item stacks.", itemLink)
 								looted = true
 							end

@@ -387,18 +391,29 @@ function BrokerGarbage:SelectiveLooting(autoloot)
 								and ((BrokerGarbage:GetItemValue(itemLink, quantity) or 0) > compareTo[1].value
 									or select(6,GetItemInfo(itemLink)) == BrokerGarbage.locale.Quest) then

+								BrokerGarbage:Debug("Delete item to make room.", itemLink)
 								BrokerGarbage:Delete(select(2,GetItemInfo(compareTo[1].itemID)), compareTo[1].bag, compareTo[1].slot)
 								LootSlot(slot)
 							elseif looted then
 								-- regular looting
 								LootSlot(slot)
 							else
-								-- something is in there, but not valuable enough for us to take it
-								BrokerGarbage:Print(format(BrokerGarbage.locale.couldNotLoot, itemLink))
+								BrokerGarbage:Debug("What do we have here?", itemLink)
+								if mobType and BrokerGarbage:CanSkin(mobLevel) then
+									-- hrmpf, it's skinnable
+									BrokerGarbage:Debug("Still looting, for skinning", itemLink)
+									BrokerGarbage:Debug()
+									BrokerGarbage:Delete(select(2,GetItemInfo(compareTo[1].itemID)), compareTo[1].bag, compareTo[1].slot)
+									LootSlot(slot)
+								else
+									-- something is in there, but not valuable enough for us to take it
+									BrokerGarbage:Print(format(BrokerGarbage.locale.couldNotLoot, itemLink))
+								end
 							end
 						else
 							-- just loot normally
 							LootSlot(slot)
+							BrokerGarbage:Debug("Item taken.", itemLink)
 						end
 					else
 						-- we should be able to loot this, but we are not. somebody set up us the bomb!
diff --git a/options.lua b/options.lua
index 88c64fe..267a530 100644
--- a/options.lua
+++ b/options.lua
@@ -1005,7 +1005,6 @@ local function ShowListOptions(frame)

 	local function ItemDrop(self, item)
 		local cursorType, itemID, link = GetCursorInfo()
-		BrokerGarbage:Print("ItemDrop - "..(item or "").." ("..(link or "").."/"..(itemID or "")..")"..(cursorType or ""))

 		if (not itemID and (item == "RightButton" or item == "LeftButton" or item == "MiddleButton")) then
 			return
@@ -1357,7 +1356,7 @@ function SlashCmdList.BROKERGARBAGE(msg, editbox)
 			BG_LocalDB.include[itemID] = count
 		end
 		local itemLink = select(2,GetItemInfo(itemID))
-		BrokerGarbage:Print(format("%s has been assigned a limit of %d.", itemLink, count))
+		BrokerGarbage:Print(format(BrokerGarbage.locale.limitSet, itemLink, count))
 		BrokerGarbage:ListOptionsUpdate("include")

 	else