Quantcast

Also return number of ticks from OvaleData:GetDuration().

Johnny C. Lam [03-28-13 - 18:45]
Also return number of ticks from OvaleData:GetDuration().

It already computed the information, so return it as well so the caller
doesn't have to make that same error-prone floating-point computation.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@847 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleCondition.lua
OvaleData.lua
diff --git a/OvaleCondition.lua b/OvaleCondition.lua
index a4f4f87..2f70f4e 100644
--- a/OvaleCondition.lua
+++ b/OvaleCondition.lua
@@ -2544,7 +2544,7 @@ OvaleCondition.conditions.tickvalue = function(condition)
 	return compare(value, condition[2], condition[3])
 end

---- Get the estimated total number of ticks of a periodic aura.
+--- Get the total number of ticks of a periodic aura.
 -- @name Ticks
 -- @paramsig number or boolean
 -- @param id The spell ID of the aura or the name of a spell list.
@@ -2564,10 +2564,7 @@ OvaleCondition.conditions.ticks = function(condition)
 			numTicks = floor(duration / tick + 0.5)
 		end
 	else
-		duration, tick = OvaleData:GetDuration(condition[1], OvaleState.state.combo, OvaleState.state.holy)
-		if duration and tick and tick > 0 then
-			numTicks = floor(duration / tick + 0.5)
-		end
+		duration, tick, numTicks = OvaleData:GetDuration(condition[1], OvaleState.state.combo, OvaleState.state.holy)
 	end
 	if numTicks then
 		return compare(numTicks, condition[2], condition[3])
diff --git a/OvaleData.lua b/OvaleData.lua
index 4e9455a..c9790e4 100644
--- a/OvaleData.lua
+++ b/OvaleData.lua
@@ -15,6 +15,7 @@ Ovale.OvaleData = OvaleData
 local OvalePaperDoll = Ovale.OvalePaperDoll
 local OvaleStance = Ovale.OvaleStance

+local floor = math.floor
 local ipairs = ipairs
 local pairs = pairs
 local tinsert = table.insert
@@ -568,6 +569,7 @@ function OvaleData:GetDamage(spellId, attackpower, spellpower, combo)
 	return damage
 end

+-- Returns the duration, tick length, and number of ticks of an aura.
 function OvaleData:GetDuration(spellId, combo, holy)
 	local si
 	if type(spellId) == "number" then
@@ -596,7 +598,7 @@ function OvaleData:GetDuration(spellId, combo, holy)
 			local tickLength = self:GetTickLength(spellId)
 			local numTicks = floor(duration / tickLength + 0.5)
 			duration = tickLength * numTicks
-			return duration, tickLength
+			return duration, tickLength, numTicks
 		end
 		return duration
 	else
@@ -623,8 +625,6 @@ function OvaleData:GetTickLength(spellId)
 			elseif si.haste == "melee" then
 				hasteMultiplier = OvalePaperDoll:GetMeleeHasteMultiplier()
 			end
-		end
-		if si.haste then
 			return tick / hasteMultiplier
 		else
 			return tick