Johnny C. Lam [04-06-14 - 18:45]
diff --git a/conditions/TimeToMaxEnergy.lua b/conditions/TimeToMaxEnergy.lua
deleted file mode 100644
index 7c2acad..0000000
--- a/conditions/TimeToMaxEnergy.lua
+++ /dev/null
@@ -1,45 +0,0 @@
---[[--------------------------------------------------------------------
- Ovale Spell Priority
- Copyright (C) 2013 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
- file accompanying this program.
---]]--------------------------------------------------------------------
-
-local _, Ovale = ...
-
-do
- local OvaleCondition = Ovale.OvaleCondition
- local OvalePower = Ovale.OvalePower
- local OvaleState = Ovale.OvaleState
-
- local Compare = OvaleCondition.Compare
- local TestValue = OvaleCondition.TestValue
- local state = OvaleState.state
-
- --- Get the number of seconds before the player reaches maximum energy for feral druids, non-mistweaver monks and rogues.
- -- @name TimeToMaxEnergy
- -- @paramsig number or boolean
- -- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more.
- -- @param number Optional. The number to compare against.
- -- @return The number of seconds.
- -- @see TimeToEnergyFor
- -- @return A boolean value for the result of the comparison.
- -- @usage
- -- if TimeToMaxEnergy() < 1.2 Spell(sinister_strike)
-
- local function TimeToMaxEnergy(condition)
- local comparator, limit = condition[1], condition[2]
- local maxEnergy = OvalePower.maxPower.energy or 0
- local energy = state.energy or 0
- local energyRegen = state.powerRate.energy or 10
- local t = (maxEnergy - energy) / energyRegen
- if t > 0 then
- return TestValue(0, state.currentTime + t, t, state.currentTime, -1, comparator, limit)
- end
- return Compare(0, comparator, limit)
- end
-
- OvaleCondition:RegisterCondition("timetomaxenergy", false, TimeToMaxEnergy)
-end
\ No newline at end of file
diff --git a/conditions/TimeToMaxPower.lua b/conditions/TimeToMaxPower.lua
new file mode 100644
index 0000000..97847e7
--- /dev/null
+++ b/conditions/TimeToMaxPower.lua
@@ -0,0 +1,64 @@
+--[[--------------------------------------------------------------------
+ Ovale Spell Priority
+ Copyright (C) 2013 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
+ file accompanying this program.
+--]]--------------------------------------------------------------------
+
+local _, Ovale = ...
+
+do
+ local OvaleCondition = Ovale.OvaleCondition
+ local OvalePower = Ovale.OvalePower
+ local OvaleState = Ovale.OvaleState
+
+ local Compare = OvaleCondition.Compare
+ local TestValue = OvaleCondition.TestValue
+ local state = OvaleState.state
+
+ --- Get the number of seconds before the player reaches maximum power.
+ local function TimeToMax(powerType, condition)
+ local comparator, limit = condition[1], condition[2]
+ local maxPower = OvalePower.maxPower[powerType] or 0
+ local power = state[powerType] or 0
+ local powerRegen = state.powerRate[powerType] or 1
+ local t = (maxPower - power) / powerRegen
+ if t > 0 then
+ return TestValue(0, state.currentTime + t, t, state.currentTime, -1, comparator, limit)
+ end
+ return Compare(0, comparator, limit)
+ end
+
+ --- Get the number of seconds before the player reaches maximum energy for feral druids, non-mistweaver monks and rogues.
+ -- @name TimeToMaxEnergy
+ -- @paramsig number or boolean
+ -- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more.
+ -- @param number Optional. The number to compare against.
+ -- @return The number of seconds.
+ -- @see TimeToEnergyFor
+ -- @return A boolean value for the result of the comparison.
+ -- @usage
+ -- if TimeToMaxEnergy() < 1.2 Spell(sinister_strike)
+
+ local function TimeToMaxEnergy(condition)
+ return TimeToMax("energy", condition)
+ end
+
+ --- Get the number of seconds before the player reaches maximum focus for hunters.
+ -- @name TimeToMaxFocus
+ -- @paramsig number or boolean
+ -- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more.
+ -- @param number Optional. The number to compare against.
+ -- @return The number of seconds.
+ -- @see TimeToEnergyFor
+ -- @return A boolean value for the result of the comparison.
+
+ local function TimeToMaxFocus(condition)
+ return TimeToMax("focus", condition)
+ end
+
+ OvaleCondition:RegisterCondition("timetomaxenergy", false, TimeToMaxEnergy)
+ OvaleCondition:RegisterCondition("timetomaxfocus", false, TimeToMaxFocus)
+end
\ No newline at end of file
diff --git a/conditions/conditions.xml b/conditions/conditions.xml
index 7bf9f3b..5e0d8bb 100644
--- a/conditions/conditions.xml
+++ b/conditions/conditions.xml
@@ -96,7 +96,7 @@
<Script file="TicksRemain.lua" />
<Script file="TimeInCombat.lua" />
<Script file="TimeToBloodlust.lua" />
- <Script file="TimeToMaxEnergy.lua" />
+ <Script file="TimeToMaxPower.lua" />
<Script file="TimeToPowerFor.lua" />
<Script file="TimeWithHaste.lua" />
<Script file="TotemExpires.lua" />