Move specialization tracking from OvaleStance to OvalePaperDoll.
Johnny C. Lam [03-16-13 - 08:03]
Move specialization tracking from OvaleStance to OvalePaperDoll.
The class specialization/mastery isn't really stance-related, whereas it's
available in the in-game paper doll.
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@773 d5049fe3-3747-40f7-a4b5-f36d6801af5f
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index fa4da50..db8b39b 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -85,7 +85,7 @@ local function TestConditions(paramList)
if paramList.glyph and not OvaleData.glyphs[paramList.glyph] then
return false
end
- if paramList.mastery and not OvaleStance:IsSpecialization(paramList.mastery) then
+ if paramList.mastery and OvalePaperDoll.specialization ~= paramList.mastery then
return false
end
if paramList.if_stance then
diff --git a/OvalePaperDoll.lua b/OvalePaperDoll.lua
index 741ce56..213a03e 100644
--- a/OvalePaperDoll.lua
+++ b/OvalePaperDoll.lua
@@ -19,6 +19,7 @@ local tonumber = tonumber
local GetMasteryEffect = GetMasteryEffect
local GetMeleeHaste = GetMeleeHaste
local GetRangedHaste = GetRangedHaste
+local GetSpecialization = GetSpecialization
local GetSpellBonusDamage = GetSpellBonusDamage
local GetSpellBonusHealing = GetSpellBonusHealing
local UnitAttackPower = UnitAttackPower
@@ -34,6 +35,8 @@ local UnitStat = UnitStat
OvalePaperDoll.class = select(2, UnitClass("player"))
-- player's level
OvalePaperDoll.level = UnitLevel("player")
+-- Player's current specialization.
+OvalePaperDoll.specialization = nil
-- primary stats
OvalePaperDoll.agility = 0
@@ -60,10 +63,12 @@ OvalePaperDoll.spellBonusHealing = 0
--<public-static-methods>
function OvalePaperDoll:OnEnable()
+ self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED", "UpdateStats")
self:RegisterEvent("MASTERY_UPDATE")
- self:RegisterEvent("PLAYER_ALIVE")
- self:RegisterEvent("PLAYER_ENTERING_WORLD", "PLAYER_ALIVE")
+ self:RegisterEvent("PLAYER_ALIVE", "UpdateStats")
+ self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdateStats")
self:RegisterEvent("PLAYER_LEVEL_UP")
+ self:RegisterEvent("PLAYER_TALENT_UPDATE", "UpdateStats")
self:RegisterEvent("UNIT_ATTACK_POWER")
self:RegisterEvent("UNIT_LEVEL")
self:RegisterEvent("UNIT_RANGEDDAMAGE")
@@ -74,10 +79,12 @@ function OvalePaperDoll:OnEnable()
end
function OvalePaperDoll:OnDisable()
+ self:UnregisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
self:UnregisterEvent("MASTERY_UPDATE")
self:UnregisterEvent("PLAYER_ALIVE")
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
self:UnregisterEvent("PLAYER_LEVEL_UP")
+ self:UnregisterEvent("PLAYER_TALENT_UPDATE")
self:UnregisterEvent("UNIT_ATTACK_POWER")
self:UnregisterEvent("UNIT_LEVEL")
self:UnregisterEvent("UNIT_RANGEDDAMAGE")
@@ -95,16 +102,6 @@ function OvalePaperDoll:MASTERY_UPDATE(event)
end
end
-function OvalePaperDoll:PLAYER_ALIVE(event)
- self:MASTERY_UPDATE(event)
- self:UNIT_ATTACK_POWER(event, "player")
- self:UNIT_RANGEDDAMAGE(event, "player")
- self:UNIT_RANGED_ATTACK_POWER(event, "player")
- self:UNIT_SPELL_HASTE(event, "player")
- self:UNIT_SPELL_POWER(event, "player")
- self:UNIT_STATS(event, "player")
-end
-
function OvalePaperDoll:PLAYER_LEVEL_UP(event, level, ...)
self.level = tonumber(level) or UnitLevel("player")
end
@@ -177,6 +174,18 @@ function OvalePaperDoll:UNIT_STATS(event, unitId)
self.spirit = UnitStat(unitId, 5)
end
+function OvalePaperDoll:UpdateStats(event)
+ self.specialization = GetSpecialization()
+ self:MASTERY_UPDATE(event)
+ self:UNIT_ATTACK_POWER(event, "player")
+ self:UNIT_RANGEDDAMAGE(event, "player")
+ self:UNIT_RANGED_ATTACK_POWER(event, "player")
+ self:UNIT_SPELL_HASTE(event, "player")
+ self:UNIT_SPELL_POWER(event, "player")
+ self:UNIT_STATS(event, "player")
+end
+
+
function OvalePaperDoll:GetMasteryMultiplier()
return 1 + self.masteryEffect / 100
end
@@ -194,6 +203,9 @@ function OvalePaperDoll:GetSpellHasteMultiplier()
end
function OvalePaperDoll:Debug()
+ Ovale:Print("Class: " .. self.class)
+ Ovale:Print("Level: " .. self.level)
+ Ovale:Print("Specialization: " .. self.specialization)
Ovale:Print("Agility: " ..self.agility)
Ovale:Print("Intellect: " ..self.intellect)
Ovale:Print("Spirit: " ..self.spirit)
diff --git a/OvaleStance.lua b/OvaleStance.lua
index c305074..8058bb9 100644
--- a/OvaleStance.lua
+++ b/OvaleStance.lua
@@ -20,7 +20,6 @@ local tinsert = table.insert
local tsort = table.sort
local GetNumShapeshiftForms = GetNumShapeshiftForms
local GetShapeshiftForm = GetShapeshiftForm
-local GetSpecialization = GetSpecialization
local GetSpellInfo = GetSpellInfo
local spellIdToStance = {
@@ -68,41 +67,27 @@ local spellIdToStance = {
local stanceList
-- Player's current stance.
local stance
--- Player's current specialization/mastery.
-local specialization
--</private-static-properties>
--<public-static-methods>
function OvaleStance:OnEnable()
- self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
- self:RegisterEvent("PLAYER_ENTERING_WORLD")
- self:RegisterEvent("PLAYER_TALENT_UPDATE")
+ self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED", "UpdateStances")
+ self:RegisterEvent("PLAYER_ALIVE", "UpdateStances")
+ self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdateStances")
+ self:RegisterEvent("PLAYER_TALENT_UPDATE", "UpdateStances")
self:RegisterEvent("UPDATE_SHAPESHIFT_FORM")
self:RegisterEvent("UPDATE_SHAPESHIFT_FORMS")
end
function OvaleStance:OnDisable()
self:UnregisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
+ self:UnregisterEvent("PLAYER_ALIVE")
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
self:UnregisterEvent("PLAYER_TALENT_UPDATE")
self:UnregisterEvent("UPDATE_SHAPESHIFT_FORM")
self:UnregisterEvent("UPDATE_SHAPESHIFT_FORMS")
end
-function OvaleStance:ACTIVE_TALENT_GROUP_CHANGED(event)
- specialization = GetSpecialization()
- self:PLAYER_TALENT_UPDATE(event)
-end
-
-function OvaleStance:PLAYER_ENTERING_WORLD(event)
- self:ACTIVE_TALENT_GROUP_CHANGED(event)
-end
-
-function OvaleStance:PLAYER_TALENT_UPDATE(event)
- self:CreateStanceList()
- self:ShapeshiftEventHandler()
-end
-
function OvaleStance:UPDATE_SHAPESHIFT_FORM(event)
self:ShapeshiftEventHandler()
end
@@ -142,13 +127,6 @@ end
function OvaleStance:Debug()
Ovale:Print("current stance: " .. stance)
- Ovale:Print("current specialization: " .. specialization)
-end
-
--- Return true if the current specialization matches the given name.
-function OvaleStance:IsSpecialization(name)
- if not name then return false end
- return name == specialization
end
-- Return true if the current stance matches the given name.
@@ -168,4 +146,9 @@ function OvaleStance:ShapeshiftEventHandler()
self:SendMessage("Ovale_StanceChanged")
end
end
+
+function OvaleStance:UpdateStances()
+ self:CreateStanceList()
+ self:ShapeshiftEventHandler()
+end
--</public-static-methods>
diff --git a/OvaleState.lua b/OvaleState.lua
index 2a4b44e..79b79ae 100644
--- a/OvaleState.lua
+++ b/OvaleState.lua
@@ -89,7 +89,7 @@ function OvaleState:UpdatePowerRates()
end
-- Vitality (combat rogue)
- if OvaleStance:IsSpecialization(2) then
+ if OvalePaperDoll.specialization == 2 then
self.powerRate.energy = self.powerRate.energy * 1.2
end