Quantcast

Player code cleanup and removed some unnecessary LibBabble-Faction uses.

James D. Callahan III [04-03-11 - 01:22]
Player code cleanup and removed some unnecessary LibBabble-Faction uses.
Filename
Core.lua
Interface/FilterMenus.lua
Interface/List.lua
Interface/Panel.lua
Player.lua
Utilities.lua
diff --git a/Core.lua b/Core.lua
index a8dc264..d86fef7 100644
--- a/Core.lua
+++ b/Core.lua
@@ -577,9 +577,8 @@ function addon:OnInitialize()
 			       for spell_id in pairs(unit.item_list) do
 				       local recipe = recipe_list[spell_id]
 				       local recipe_prof = _G.GetSpellInfo(recipe.profession)
-				       local scanned = player.has_scanned[recipe_prof]

-				       if scanned then
+				       if player.scanned_professions[recipe_prof] then
 					       local skill_level = player.professions[recipe_prof]
 					       local has_level = skill_level and (type(skill_level) == "boolean" and true or skill_level >= recipe.skill_level)

@@ -997,7 +996,7 @@ do
 		local is_linked = _G.IsTradeSkillLinked() or _G.IsTradeSkillGuild()

 		if not is_linked then
-			player.has_scanned[current_prof] = true
+			player.scanned_professions[current_prof] = true
 		end

 		-- Get the current profession Specialty
diff --git a/Interface/FilterMenus.lua b/Interface/FilterMenus.lua
index 57bb70b..b43eeb1 100644
--- a/Interface/FilterMenus.lua
+++ b/Interface/FilterMenus.lua
@@ -24,8 +24,6 @@ local QTip	= LibStub("LibQTip-1.0")
 -- Set up the private intra-file namespace.
 local private	= _G.select(2, ...)

-local Player	= private.Player
-
 -------------------------------------------------------------------------------
 -- Upvalues
 -------------------------------------------------------------------------------
@@ -182,7 +180,7 @@ function private.InitializeFilterPanel()
 						       filterdb.classes[class] = false
 					       end
 					       -- Set your own class to true.
-					       filterdb.classes[string.lower(Player["Class"])] = true
+					       filterdb.classes[private.Player.class:lower()] = true

 					       if MainPanel:IsVisible() then
 						       MainPanel:UpdateTitle()
@@ -397,7 +395,7 @@ function private.InitializeFilterPanel()
 				       end

 				       if toggle == false then
-					       local class = string.lower(Player["Class"])
+					       local class = private.Player.class:lower()
 					       classes[class] = true
 					       general_frame[class]:SetChecked(true)
 				       end
@@ -719,7 +717,7 @@ function private.InitializeFilterPanel()
 	-- Check to see if we're Horde or Alliance, and change the displayed
 	-- reputation strings to be faction-correct.
 	-------------------------------------------------------------------------------
-	local isAlliance = (Player.faction == "Alliance")
+	local isAlliance = (private.Player.faction == "Alliance")

 	local HonorHold_Thrallmar_Text = isAlliance and BFAC["Honor Hold"] or BFAC["Thrallmar"]
 	local Kurenai_Maghar_Text = isAlliance and BFAC["Kurenai"] or BFAC["The Mag'har"]
diff --git a/Interface/List.lua b/Interface/List.lua
index 8b8285c..42a8f95 100644
--- a/Interface/List.lua
+++ b/Interface/List.lua
@@ -1021,7 +1021,7 @@ function private.InitializeListFrame()
 		if addon.db.profile.filters.general.faction then
 			return true
 		end
-		return (not faction or faction == BFAC[Player.faction] or faction == FACTION_NEUTRAL)
+		return (not faction or faction == Player.faction or faction == FACTION_NEUTRAL)
 	end

 	-- Padding for list entries/subentries
diff --git a/Interface/Panel.lua b/Interface/Panel.lua
index d27998a..91f0291 100644
--- a/Interface/Panel.lua
+++ b/Interface/Panel.lua
@@ -69,10 +69,6 @@ local A = private.acquire_types
 -------------------------------------------------------------------------------
 local ORDERED_PROFESSIONS	= private.ordered_professions

-local FACTION_HORDE		= BFAC["Horde"]
-local FACTION_ALLIANCE		= BFAC["Alliance"]
-local FACTION_NEUTRAL		= BFAC["Neutral"]
-
 function private.InitializeFrame()
 	-------------------------------------------------------------------------------
 	-- Create the MainPanel and set its values
diff --git a/Player.lua b/Player.lua
index a807cdd..605ae45 100644
--- a/Player.lua
+++ b/Player.lua
@@ -46,8 +46,8 @@ local FOLDER_NAME, private	= ...
 -- @class table
 -- @name Player
 -- @field known_filtered Total number of items known filtered during the scan.
--- @field Faction Player's faction
--- @field Class Player's class
+-- @field faction Player's faction
+-- @field class Player's class
 -- @field ["Reputation"] Listing of players reputation levels
 local Player = {}
 private.Player = Player
@@ -64,17 +64,12 @@ local F = private.filter_flags
 -------------------------------------------------------------------------------
 function Player:Initialize()
 	self.faction = _G.UnitFactionGroup("player")
-	self.Class = _G.select(2, _G.UnitClass("player"))
-	self:SetProfessions()
+	self.class = _G.select(2, _G.UnitClass("player"))

-	-------------------------------------------------------------------------------
-	-- Set the scanned state for all professions to false.
-	-------------------------------------------------------------------------------
-	self.has_scanned = {}
+	self.scanned_professions = {}
+	self.professions = {}

-	for profession in pairs(self.professions) do
-		self.has_scanned[profession] = false
-	end
+	self:SetProfessions()
 end

 do
@@ -127,7 +122,7 @@ function Player:HasProperRepLevel(rep_data)
 	if not rep_data then
 		return true
 	end
-	local is_alliance = Player.faction == BFAC["Alliance"]
+	local is_alliance = Player.faction == "Alliance"
 	local player_rep = Player["Reputation"]
 	local FAC = private.faction_ids
 	local has_faction = true
@@ -156,9 +151,9 @@ function Player:HasRecipeFaction(recipe)
 	local flagged_horde = recipe:HasFilter("common1", "HORDE")
 	local flagged_alliance = recipe:HasFilter("common1", "ALLIANCE")

-	if self.faction == BFAC["Alliance"] and flagged_horde and not flagged_alliance then
+	if self.faction == "Alliance" and flagged_horde and not flagged_alliance then
 		return false
-	elseif self.faction == BFAC["Horde"] and flagged_alliance and not flagged_horde then
+	elseif self.faction == "Horde" and flagged_alliance and not flagged_horde then
 		return false
 	end
 	return true
@@ -176,23 +171,6 @@ do

 	-- Sets the player's professions. Used when the AddOn initializes and when a profession has been learned or unlearned.
 	function Player:SetProfessions()
-		if not self.professions then
-			self.professions = {
-				[_G.GetSpellInfo(51304)]	= false, -- Alchemy
-				[_G.GetSpellInfo(51300)]	= false, -- Blacksmithing
-				[_G.GetSpellInfo(51296)]	= false, -- Cooking
-				[_G.GetSpellInfo(51313)]	= false, -- Enchanting
-				[_G.GetSpellInfo(51306)]	= false, -- Engineering
-				[_G.GetSpellInfo(45542)]	= false, -- First Aid
-				[_G.GetSpellInfo(51302)]	= false, -- Leatherworking
-				[_G.GetSpellInfo(2656)]		= false, -- Smelting
-				[_G.GetSpellInfo(51309)]	= false, -- Tailoring
-				[_G.GetSpellInfo(51311)]	= false, -- Jewelcrafting
-				[_G.GetSpellInfo(45363)]	= false, -- Inscription
-				[private.runeforging_name]	= false, -- Runeforging
-			}
-		end
-
 		for i in pairs(self.professions) do
 			self.professions[i] = nil
 		end
diff --git a/Utilities.lua b/Utilities.lua
index 1e6a703..ccc6434 100644
--- a/Utilities.lua
+++ b/Utilities.lua
@@ -22,9 +22,9 @@ local L = LibStub("AceLocale-3.0"):GetLocale(private.addon_name, true)
 -----------------------------------------------------------------------
 do
 	local FACTION_NAMES = {
-		[1] = BFAC["Neutral"],
-		[2] = BFAC["Alliance"],
-		[3] = BFAC["Horde"]
+		[1] = "Neutral",
+		[2] = "Alliance",
+		[3] = "Horde"
 	}

 	function private:AddListEntry(lookup_list, identifier, name, location, coord_x, coord_y, faction)