Quantcast

Provide cleaner way to reset a spell cooldown in the simulator.

Johnny C. Lam [11-15-13 - 19:55]
Provide cleaner way to reset a spell cooldown in the simulator.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1162 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleCooldown.lua
OvaleEclipse.lua
diff --git a/OvaleCooldown.lua b/OvaleCooldown.lua
index 464ed11..f5b8093 100644
--- a/OvaleCooldown.lua
+++ b/OvaleCooldown.lua
@@ -182,7 +182,7 @@ do
 		return nil
 	end

-	-- Return the cooldown for the given spell in the simulator.
+	-- Return the cooldown for the spell in the simulator.
 	function statePrototype:GetSpellCooldown(spellId)
 		local state = self
 		local start, duration, enable
@@ -196,4 +196,15 @@ do
 		end
 		return start, duration, enable
 	end
+
+	-- Force the cooldown of a spell to reset at the specified time.
+	function statePrototype:ResetSpellCooldown(spellId, atTime)
+		local state = self
+		if atTime >= OvaleState.currentTime then
+			local cd = state:GetCD(spellId)
+			cd.start = OvaleState.currentTime
+			cd.duration = atTime - OvaleState.currentTime
+			cd.enable = 1
+		end
+	end
 end
diff --git a/OvaleEclipse.lua b/OvaleEclipse.lua
index 2459d9d..7615103 100644
--- a/OvaleEclipse.lua
+++ b/OvaleEclipse.lua
@@ -181,12 +181,7 @@ function OvaleEclipse:ApplySpellOnPlayer(state, spellId, startCast, endCast, nex
 				direction = 1
 				state:AddEclipse(endCast, LUNAR_ECLIPSE)
 				-- Reaching Lunar Eclipse resets the cooldown of Starfall.
-				local cd = state:GetCD(STARFALL)
-				if cd then
-					cd.start = 0
-					cd.duration = 0
-					cd.enable = 0
-				end
+				state:ResetSpellCooldown(LUNAR_ECLIPSE, endCast)
 			elseif eclipse >= 100 then
 				eclipse = 100
 				direction = -1