Johnny C. Lam [04-21-14 - 05:02]
diff --git a/conditions/PowerCost.lua b/conditions/PowerCost.lua
index a9b710d..b7f113a 100644
--- a/conditions/PowerCost.lua
+++ b/conditions/PowerCost.lua
@@ -1,6 +1,6 @@
--[[--------------------------------------------------------------------
Ovale Spell Priority
- Copyright (C) 2013 Johnny C. Lam
+ Copyright (C) 2013, 2014 Johnny C. Lam
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License in the LICENSE
@@ -11,33 +11,74 @@ local _, Ovale = ...
do
local OvaleCondition = Ovale.OvaleCondition
+ local OvaleState = Ovale.OvaleState
- local API_GetSpellInfo = GetSpellInfo
local Compare = OvaleCondition.Compare
+ local state = OvaleState.state
- --- Get the resource cost of the given spell.
+ -- Return the amount of power of the given power type required to cast the given spell.
+ local function PowerCost(powerType, condition)
+ local spellId, comparator, limit = condition[1], condition[2], condition[3]
+ local value = state:PowerCost(spellId, powerType) or 0
+ return Compare(value, comparator, limit)
+ end
+
+ --- Get the amount of energy required to cast the given spell.
-- This returns zero for spells that use either mana or another resource based on stance/specialization, e.g., Monk's Jab.
- -- @name PowerCost
+ -- @name EnergyCost
-- @paramsig number or boolean
-- @param id The spell ID.
-- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more.
-- @param number Optional. The number to compare against.
- -- @return The amount of power (energy, focus, rage, etc.).
+ -- @return The amount of energy.
-- @return A boolean value for the result of the comparison.
- -- @see EnergyCost, FocusCost, ManaCost, RageCost
- -- @usage
- -- if Energy() > PowerCost(rake) Spell(rake)
- local function PowerCost(condition)
- local spellId, comparator, limit = condition[1], condition[2], condition[3]
- local _, _, _, cost = API_GetSpellInfo(spellId)
- local value = cost or 0
- return Compare(value, comparator, limit)
+ local function EnergyCost(condition)
+ return PowerCost("energy", condition)
+ end
+
+ --- Get the amount of focus required to cast the given spell.
+ -- @name FocusCost
+ -- @paramsig number or boolean
+ -- @param id The spell ID.
+ -- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more.
+ -- @param number Optional. The number to compare against.
+ -- @return The amount of focus.
+ -- @return A boolean value for the result of the comparison.
+
+ local function FocusCost(condition)
+ return PowerCost("focus", condition)
+ end
+
+ --- Get the amount of mana required to cast the given spell.
+ -- This returns zero for spells that use either mana or another resource based on stance/specialization, e.g., Monk's Jab.
+ -- @name ManaCost
+ -- @paramsig number or boolean
+ -- @param id The spell ID.
+ -- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more.
+ -- @param number Optional. The number to compare against.
+ -- @return The amount of mana.
+ -- @return A boolean value for the result of the comparison.
+
+ local function ManaCost(condition)
+ return PowerCost("mana", condition)
+ end
+
+ --- Get the amount of rage required to cast the given spell.
+ -- @name RageCost
+ -- @paramsig number or boolean
+ -- @param id The spell ID.
+ -- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more.
+ -- @param number Optional. The number to compare against.
+ -- @return The amount of rage.
+ -- @return A boolean value for the result of the comparison.
+
+ local function RageCost(condition)
+ return PowerCost("rage", condition)
end
- OvaleCondition:RegisterCondition("energycost", true, PowerCost)
- OvaleCondition:RegisterCondition("focuscost", true, PowerCost)
- OvaleCondition:RegisterCondition("manacost", true, PowerCost)
- OvaleCondition:RegisterCondition("powercost", true, PowerCost)
- OvaleCondition:RegisterCondition("ragecost", true, PowerCost)
+ OvaleCondition:RegisterCondition("energycost", true, EnergyCost)
+ OvaleCondition:RegisterCondition("focuscost", true, FocusCost)
+ OvaleCondition:RegisterCondition("manacost", true, ManaCost)
+ OvaleCondition:RegisterCondition("ragecost", true, RageCost)
end
\ No newline at end of file