Quantcast

Add support for tracking which expansion the recipe came from (Ticket 295) and also add support for skill level information (Ticket 434). Information is not in the database so we make some assumption about both of these until the database gets populated. If a recipes is 300 or below, it's from original wow, if it is 375 or below, it's from BC, 450 or below it's from wrath. If a recipe does not have skill up information, we assume that orange is 10 points, yellow is 15, green is 20.

ackis [05-13-09 - 16:45]
Add support for tracking which expansion the recipe came from (Ticket 295) and also add support for skill level information (Ticket 434).  Information is not in the database so we make some assumption about both of these until the database gets populated.  If a recipes is 300 or below, it's from original wow, if it is 375 or below, it's from BC, 450 or below it's from wrath.  If a recipe does not have skill up information, we assume that orange is 10 points, yellow is 15, green is 20.
Filename
ARLFrame.lua
AckisRecipeList.lua
Docs/Documentation.txt
RecipeDB/ARL-Alchemy.lua
diff --git a/ARLFrame.lua b/ARLFrame.lua
index fd96683..c6555fa 100644
--- a/ARLFrame.lua
+++ b/ARLFrame.lua
@@ -219,22 +219,30 @@ function addon:CloseWindow()

 end

--- Description: Colours a skill level based on if the player can learn it
--- Expected result: The recipe string is coloured based on if the player has a high enough skill level or faction to learn it
--- Input: The skill, player skill level, if they have the faction, and the string
--- Output: An appropiatly coloured string
+-- Description: Colours a skill level based on if the player can learn it.  The recipe string is coloured based on if the player has a high enough skill level or faction to learn it

-local function ColourSkillLevel(recipeSkill, playerSkill, hasFaction, recStr)
+local function ColourSkillLevel(recipeSkill, playerSkill, hasFaction, recStr, recipeOrange, recipeYellow, recipeGreen, recipeGrey)

+	-- Players skill level is not high enough or they do not have hte needed faction.
 	if ((recipeSkill > playerSkill) or (not hasFaction)) then
 		return addon:Red(recStr)
-	elseif ((playerSkill - recipeSkill) < 20) then
-		return addon:Orange(recStr)
-	elseif ((playerSkill - recipeSkill) < 30) then
-		return addon:Yellow(recStr)
-	elseif ((playerSkill - recipeSkill) < 40) then
+	-- Players skill level is above the threshold in which the recipe is grey
+	elseif (playerSkill >= recipeGrey) then
+		return addon:MidGrey(recStr)
+	-- Players skills is at the threshold when the recipe turns green.
+	elseif (playerSkill >= recipeGreen) then
 		return addon:Green(recStr)
+	-- Players skills is at the threshold when the recipe turns yellow.
+	elseif (playerSkill >= recipeYellow) then
+		return addon:Yellow(recStr)
+	-- Players skills is at the threshold when the recipe turns orange.
+	elseif (playerSkill >= recipeOrange) then
+		return addon:Orange(recStr)
+	-- Fallback
 	else
+		--@debug@
+		addon:Print("DEBUG: ColourSkillLevel fallback: " .. recStr)
+		--@end-debug@
 		return addon:MidGrey(recStr)
 	end

@@ -528,8 +536,9 @@ local function initDisplayStrings()
 	for i = 1, #sortedRecipeIndex do

 		local recipeIndex = sortedRecipeIndex[i]
+		local recipeEntry = recipeDB[recipeIndex]

-		if ((recipeDB[recipeIndex]["Display"] == true) and (recipeDB[recipeIndex]["Search"] == true)) then
+		if ((recipeEntry["Display"] == true) and (recipeEntry["Search"] == true)) then

 			local t = {}

@@ -537,19 +546,23 @@ local function initDisplayStrings()
 			local recStr = ""

 			if (exclude[recipeIndex] == true) then
-				recStr = "** " .. recipeDB[recipeIndex]["Name"] .. " **"
+				recStr = "** " .. recipeEntry["Name"] .. " **"
 			else
-				recStr = recipeDB[recipeIndex]["Name"]
+				recStr = recipeEntry["Name"]
 			end

-			local recipeSkill = recipeDB[recipeIndex]["Level"]
+			local recipeSkill = recipeEntry["Level"]
+			local recipeOrange = recipeEntry["Orange"]
+			local recipeYellow = recipeEntry["Yellow"]
+			local recipeGreen = recipeEntry["Green"]
+			local recipeGrey = recipeEntry["Grey"]
 			local playerSkill = playerData.playerProfessionLevel

 			recStr = SetSortString(recipeSkill, recStr)

 			local hasFaction = checkFactions(recipeDB, recipeIndex, playerData.playerFaction, playerData["Reputation"])

-			t.String = ColourSkillLevel(recipeSkill, playerSkill, hasFaction, recStr)
+			t.String = ColourSkillLevel(recipeSkill, playerSkill, hasFaction, recStr, recipeOrange, recipeYellow, recipeGreen, recipeGrey)

 			t.sID = recipeIndex
 			t.IsRecipe = true
@@ -2977,8 +2990,9 @@ local function expandallDisplayStrings()
 	for i = 1, #sortedRecipeIndex do

 		local recipeIndex = sortedRecipeIndex[i]
+		local recipeEntry = recipeDB[recipeIndex]

-		if ((recipeDB[recipeIndex]["Display"] == true) and (recipeDB[recipeIndex]["Search"] == true)) then
+		if ((recipeEntry["Display"] == true) and (recipeEntry["Search"] == true)) then

 			local t = {}

@@ -2986,24 +3000,28 @@ local function expandallDisplayStrings()
 			local recStr = ""

 			if (exclude[recipeIndex] == true) then
-				recStr = "** " .. recipeDB[recipeIndex]["Name"] .. " **"
+				recStr = "** " .. recipeEntry["Name"] .. " **"
 			else
-				recStr = recipeDB[recipeIndex]["Name"]
+				recStr = recipeEntry["Name"]
 			end

-			local recipeSkill = recipeDB[recipeIndex]["Level"]
+			local recipeSkill = recipeEntry["Level"]
 			local playerSkill = playerData.playerProfessionLevel
+			local recipeOrange = recipeEntry["Orange"]
+			local recipeYellow = recipeEntry["Yellow"]
+			local recipeGreen = recipeEntry["Green"]
+			local recipeGrey = recipeEntry["Grey"]

 			recStr = SetSortString(recipeSkill, recStr)

 			local hasFaction = checkFactions(recipeDB, recipeIndex, playerData.playerFaction, playerData["Reputation"])

-			t.String = ColourSkillLevel(recipeSkill, playerSkill, hasFaction, recStr)
+			t.String = ColourSkillLevel(recipeSkill, playerSkill, hasFaction, recStr, recipeOrange, recipeYellow, recipeGreen, recipeGrey)

 			t.sID = sortedRecipeIndex[i]
 			t.IsRecipe = true

-			if (recipeDB[recipeIndex]["Acquire"]) then
+			if (recipeEntry["Acquire"]) then
 				-- we have acquire information for this. push the title entry into the strings
 				-- and start processing the acquires
 				t.IsExpanded = true
diff --git a/AckisRecipeList.lua b/AckisRecipeList.lua
index ca0dd9c..fdd25c2 100644
--- a/AckisRecipeList.lua
+++ b/AckisRecipeList.lua
@@ -581,7 +581,7 @@ end

 --- Adds a tradeskill recipe into the specified recipe database.
 -- @name AckisRecipeList:addTradeSkill
--- @usage AckisRecipeList:addTradeSkill(RecipeDB,2329,1,2454,1,2259)
+-- @usage AckisRecipeList:addTradeSkill(RecipeDB,2329,1,2454,1,2259,0,1,55,75,95)
 -- @param RecipeDB The database (array) which you wish to add data too.
 -- @param SpellID The [http://www.wowwiki.com/SpellLink Spell ID] of the recipe being added to the database.
 -- @param SkillLevel The skill level at which the recipe may be learned.
@@ -589,8 +589,13 @@ end
 -- @param Rarity The rarity of the recipe.
 -- @param Profession The profession ID that uses the recipe.  See [[database-documentation]] for a listing of profession IDs.
 -- @param Specialty The specialty that uses the recipe (ie: goblin engineering) or nil or blank
+-- @param Game Game version recipe was found in, for example, Original, BC, or Wrath.
+-- @param Orange Level at which recipe is considered orange.
+-- @param Yellow Level at which recipe is considered yellow.
+-- @param Green Level at which recipe is considered green.
+-- @param Grey Level at which recipe is considered greay.
 -- @return None, array is passed as a reference.
-function addon:addTradeSkill(RecipeDB, SpellID, SkillLevel, ItemID, Rarity, Profession, Specialty)
+function addon:addTradeSkill(RecipeDB, SpellID, SkillLevel, ItemID, Rarity, Profession, Specialty, Game, Orange, Yellow, Green, Grey)

 	--[[
 		Recipe DB Structures are defined in Documentation.lua
@@ -598,52 +603,100 @@ function addon:addTradeSkill(RecipeDB, SpellID, SkillLevel, ItemID, Rarity, Prof

 	-- Creates a table in the RecipeListing table storing all information about a recipe
 	RecipeDB[SpellID] = {}
+
+	local recipeentry = RecipeDB[SpellID]
+
 	-- Set the information passed
-	RecipeDB[SpellID]["Level"] = SkillLevel
-	RecipeDB[SpellID]["ItemID"] = ItemID or nil
-	RecipeDB[SpellID]["Rarity"] = Rarity
-	RecipeDB[SpellID]["Profession"] = GetSpellInfo(Profession)
-	RecipeDB[SpellID]["Locations"] = nil
+	recipeentry["Level"] = SkillLevel
+	recipeentry["ItemID"] = ItemID or nil
+	recipeentry["Rarity"] = Rarity
+	recipeentry["Profession"] = GetSpellInfo(Profession)
+	recipeentry["Locations"] = nil

 	-- Get the recipe link from the spell ID
 	local spellLink = GetSpellLink(SpellID)

 	if (spellLink ~= nil) then
-		--RecipeDB[SpellID]["RecipeLink"] = string.gsub(spellLink, "spell", "enchant")
-		RecipeDB[SpellID]["RecipeLink"] = spellLink
+		--recipeentry["RecipeLink"] = string.gsub(spellLink, "spell", "enchant")
+		recipeentry["RecipeLink"] = spellLink
 	else
-		RecipeDB[SpellID]["RecipeLink"] = nil
+		recipeentry["RecipeLink"] = nil
 	end

 	-- Get the recipe name now
-	RecipeDB[SpellID]["Name"] = GetSpellInfo(SpellID) or nil
+	recipeentry["Name"] = GetSpellInfo(SpellID) or nil

-	if (RecipeDB[SpellID]["Name"] == nil) then
+	if (recipeentry["Name"] == nil) then
 		self:Print(format(L["SpellIDCache"],SpellID))
 	end

 	-- All recipes are unknown until scan occurs
-	RecipeDB[SpellID]["Known"] = false
+	recipeentry["Known"] = false

 	-- All recipes are set to be displayed until the filtering occurs
-	RecipeDB[SpellID]["Display"] = true
+	recipeentry["Display"] = true

 	-- All recipes are set to be showing in the search results
-	RecipeDB[SpellID]["Search"] = true
+	recipeentry["Search"] = true

 	-- Create the flag space in the RecipeDB
-	RecipeDB[SpellID]["Flags"] = {}
+	recipeentry["Flags"] = {}

 	-- Set all the flags to be false, will also set the padding spaces to false as well.
 	for i=1,127,1 do
-		RecipeDB[SpellID]["Flags"][i] = false
+		recipeentry["Flags"][i] = false
 	end

 	-- Create the Acquire space in the RecipeDB
-	RecipeDB[SpellID]["Acquire"] = {}
+	recipeentry["Acquire"] = {}

 	-- Assumption that there will only be 1 speciality for a trade skill
-	RecipeDB[SpellID]["Specialty"] = Specialty or nil
+	recipeentry["Specialty"] = Specialty or nil
+
+	-- Get the expansion that the recipe was added
+	if (Game) then
+		recipeentry["Game"] = Game
+	-- We don't have a game flag set, so we'll just make an assumption based on skill levels
+	-- Eventually once all these are added we won't need this code
+	elseif (SkillLevel <= 300) then
+		recipeentry["Game"] = 0
+	elseif (SkillLevel <= 375) then
+		recipeentry["Game"] = 1
+	elseif (SkillLevel <= 450) then
+		recipeentry["Game"] = 2
+	end
+
+	-- Assign an orange value for the recipe
+	if (Orange) then
+		recipeentry["Orange"] = Orange
+	-- If we don't have one in the db, just assume it's the skill level
+	else
+		recipeentry["Orange"] = SkillLevel
+	end
+
+	-- Assign a yellow value for the recipe
+	if (Yellow) then
+		recipeentry["Yellow"] = Yellow
+	-- If we don't have one in the db, just assume it's the skill level + 10
+	else
+		recipeentry["Yellow"] = SkillLevel + 10
+	end
+
+	-- Assign a green value for the recipe
+	if (Green) then
+		recipeentry["Green"] = Green
+	-- If we don't have one in the db, just assume it's the skill level + 15
+	else
+		recipeentry["Green"] = SkillLevel + 15
+	end
+
+	-- Assign a grey value for the recipe
+	if (Grey) then
+		recipeentry["Grey"] = Grey
+	-- If we don't have one in the db, just assume it's the skill level + 20
+	else
+		recipeentry["Grey"] = SkillLevel + 20
+	end

 end

@@ -665,12 +718,9 @@ function addon:addTradeFlags(RecipeDB, SpellID, ...)

 	-- Find out how many flags we're adding
 	for i=1,numvars,1 do
-
 		-- Get the value of the current flag
 		local flag = select(i, ...)
-
 		flags[flag] = true
-
 	end


diff --git a/Docs/Documentation.txt b/Docs/Documentation.txt
index e4bf880..12054ca 100644
--- a/Docs/Documentation.txt
+++ b/Docs/Documentation.txt
@@ -28,7 +28,7 @@ In the RecipeDB is a single file for each profession. Each recipe is inserted in

  -- Elixir of Lion's Strength -- 2329
  recipecount = recipecount + 1
- self:addTradeSkill(RecipeDB,2329,1,2454,1,2259)
+ self:addTradeSkill(RecipeDB,2329,1,2454,1,2259,0,1,55,75,95)
  self:addTradeFlags(RecipeDB,2329,1,2,3,21,22,23,24,25,26,27,28,29,30,36,41,51,52)
  self:addTradeAcquire(RecipeDB,2329,8,8)

@@ -296,6 +296,9 @@ Finally, return retval.
 I believe this will get through the flags in the shortest possible route, short circuiting the looping when any condition warrants it

 ===List of Exclusive filters===
+
+This filters will prevent the recipe from showing up regardless of any other filters.  For example, if one of them is false, the recipe is hidden.
+
 :specialty
 :known
 :unknown
@@ -306,6 +309,9 @@ I believe this will get through the flags in the shortest possible route, short
 ::itembop
 ::recipebop
 ::recipeboe
+:item
+::weapon
+::armor

 ===List of Non-exclusive filters===

@@ -514,6 +520,11 @@ Defined below is the specification for the arguments passed back into addTradeAc
 ::Search			- Boolean determining if it's in the search results (true = yes, false = no)
 ::Profession		- Flag for identifying which profession it is.
 ::Speciality		- Profession speciality (if it exists)
+::Game				- Which expansion this recipe is from.
+::Orange			- Skill level when recipe is orange.
+::Yellow			- Skill level when recipe is yellow.
+::Green				- Skill level when recipe is green.
+::Grey				- Skill level when recipe is grey.

 ===Mob DB===
  self:addLookupList(MobDB, 590, L["Defias Looter"], BZONE["Westfall"], 38.52, 55.94)
diff --git a/RecipeDB/ARL-Alchemy.lua b/RecipeDB/ARL-Alchemy.lua
index afc395a..e51f811 100644
--- a/RecipeDB/ARL-Alchemy.lua
+++ b/RecipeDB/ARL-Alchemy.lua
@@ -1396,7 +1396,7 @@ function addon:InitAlchemy(RecipeDB)

 	-- Elixir of Accuracy -- 60354
 	recipecount = recipecount + 1
-	self:addTradeSkill(RecipeDB,60354,400,44325,1, 51304)
+	self:addTradeSkill(RecipeDB,60354,400,44325,1, 51304,2,400,415,422,430)
 	self:addTradeFlags(RecipeDB,60354,1,2,12,21,22,23,24,25,26,27,28,29,30,36,41)
 	self:addTradeAcquire(RecipeDB,60354,8,18)