Quantcast

Move identical cast start and end checks from the individual methods

Johnny C. Lam [11-15-13 - 19:58]
Move identical cast start and end checks from the individual methods
into a wrapper around the main method invoked from OvaleState.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1176 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleAura.lua
OvaleComboPoints.lua
OvaleCooldown.lua
OvaleEclipse.lua
OvaleFuture.lua
OvalePower.lua
OvaleRunes.lua
OvaleState.lua
diff --git a/OvaleAura.lua b/OvaleAura.lua
index f93ce24..6574d77 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -644,13 +644,8 @@ end

 -- Apply the effects of the spell on the player's state, assuming the spellcast completes.
 function OvaleAura:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
-	-- If the spellcast has already ended, then the effects on the player have already occurred.
-	if endCast <= OvaleState.now then
-		return
-	end
-
-	-- Apply the auras on the player.
 	local si = OvaleData.spellInfo[spellId]
+	-- Apply the auras on the player.
 	if si and si.aura and si.aura.player then
 		state:ApplySpellAuras(spellId, startCast, endCast, OvaleGUID:GetGUID("player"), si.aura.player, spellcast)
 	end
@@ -659,8 +654,8 @@ end
 -- Apply the effects of the spell on the target's state when it lands on the target.
 function OvaleAura:ApplySpellOnHit(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
 	local si = OvaleData.spellInfo[spellId]
+	-- Apply the auras on the target.
 	if si and si.aura and si.aura.target then
-		-- Apply the auras on the target.
 		state:ApplySpellAuras(spellId, startCast, endCast, targetGUID, si.aura.target, spellcast)
 	end
 end
diff --git a/OvaleComboPoints.lua b/OvaleComboPoints.lua
index 8a2ffe1..05f37fb 100644
--- a/OvaleComboPoints.lua
+++ b/OvaleComboPoints.lua
@@ -122,11 +122,6 @@ end

 -- Apply the effects of the spell on the player's state, assuming the spellcast completes.
 function OvaleComboPoints:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
-	-- If the spellcast has already ended, then the effects on the player have already occurred.
-	if endCast <= OvaleState.now then
-		return
-	end
-
 	local si = OvaleData.spellInfo[spellId]
 	if si and si.combo then
 		local cost = si.combo
diff --git a/OvaleCooldown.lua b/OvaleCooldown.lua
index 09f2487..7dd4d8a 100644
--- a/OvaleCooldown.lua
+++ b/OvaleCooldown.lua
@@ -104,11 +104,6 @@ end

 -- Apply the effects of the spell on the player's state, assuming the spellcast completes.
 function OvaleCooldown:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
-	-- If the spellcast has already ended, then the effects on the player have already occurred.
-	if endCast <= OvaleState.now then
-		return
-	end
-
 	local si = OvaleData.spellInfo[spellId]
 	if si then
 		local cd = state:GetCD(spellId)
diff --git a/OvaleEclipse.lua b/OvaleEclipse.lua
index a63297a..633d23c 100644
--- a/OvaleEclipse.lua
+++ b/OvaleEclipse.lua
@@ -137,11 +137,6 @@ end

 -- Apply the effects of the spell on the player's state, assuming the spellcast completes.
 function OvaleEclipse:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
-	-- If the spellcast has already ended, then the effects on the player have already occurred.
-	if endCast <= OvaleState.now then
-		return
-	end
-
 	local si = OvaleData.spellInfo[spellId]
 	if si and si.eclipse then
 		local eclipse = state.eclipse
diff --git a/OvaleFuture.lua b/OvaleFuture.lua
index d2d69f1..742fa8f 100644
--- a/OvaleFuture.lua
+++ b/OvaleFuture.lua
@@ -523,11 +523,6 @@ end

 -- Apply the effects of the spell at the start of the spellcast.
 function OvaleFuture:ApplySpellStartCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
-	-- If the spellcast has already started, then the effects have already occurred.
-	if startCast < OvaleState.now then
-		return
-	end
-
 	local si = OvaleData.spellInfo[spellId]
 	if si then
 		-- Increment and reset spell counters.
diff --git a/OvalePower.lua b/OvalePower.lua
index dc03bff..7f953e2 100644
--- a/OvalePower.lua
+++ b/OvalePower.lua
@@ -233,11 +233,6 @@ end

 -- Apply the effects of the spell on the player's state, assuming the spellcast completes.
 function OvalePower:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
-	-- If the spellcast has already ended, then the effects on the player have already occurred.
-	if endCast <= OvaleState.now then
-		return
-	end
-
 	local si = OvaleData.spellInfo[spellId]

 	-- Update power using information from GetSpellInfo() if there is no SpellInfo() for the spell's cost.
diff --git a/OvaleRunes.lua b/OvaleRunes.lua
index a188967..cfbacde 100644
--- a/OvaleRunes.lua
+++ b/OvaleRunes.lua
@@ -196,11 +196,6 @@ end

 -- Apply the effects of the spell on the player's state, assuming the spellcast completes.
 function OvaleRunes:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
-	-- If the spellcast has already ended, then the effects on the player have already occurred.
-	if endCast <= OvaleState.now then
-		return
-	end
-
 	local si = OvaleData.spellInfo[spellId]
 	if si then
 		for i, name in ipairs(RUNE_NAME) do
diff --git a/OvaleState.lua b/OvaleState.lua
index 6a6a41a..184409b 100644
--- a/OvaleState.lua
+++ b/OvaleState.lua
@@ -150,8 +150,14 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ
 			2. Effects when the spell has been cast.
 			3. Effects when the spellcast hits the target.
 	--]]
-	self:InvokeMethod("ApplySpellStartCast", spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
-	self:InvokeMethod("ApplySpellAfterCast", spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
+	-- If the spellcast has already started, then the effects have already occurred.
+	if startCast >= OvaleState.now then
+		self:InvokeMethod("ApplySpellStartCast", spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
+	end
+	-- If the spellcast has already ended, then the effects have already occurred.
+	if endCast > OvaleState.now then
+		self:InvokeMethod("ApplySpellAfterCast", spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
+	end
 	self:InvokeMethod("ApplySpellOnHit", spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast)
 end
 --</public-static-methods>