From 38f6ecd46161ed564ac414d5bfa1747144e07297 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Thu, 15 May 2014 23:17:51 +0000 Subject: [PATCH] Add parameter to state:RuneCount() to get rune count at a given time. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1444 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleRunes.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/OvaleRunes.lua b/OvaleRunes.lua index 6bcf060..6793db7 100644 --- a/OvaleRunes.lua +++ b/OvaleRunes.lua @@ -335,17 +335,25 @@ end -- count The number of currently active runes of the given type. -- startCooldown The time at which the next rune of the given type went on cooldown. -- endCooldown The time at which the next rune of the given type will be active. -statePrototype.RuneCount = function(state, name, deathCondition) +statePrototype.RuneCount = function(state, name, deathCondition, atTime) + -- Default to checking the rune count at the end of the current spellcast in the + -- simulator, or at the current time if no spell is being cast. + if not atTime then + if state.endCast and state.endCast > state.currentTime then + atTime = state.endCast + else + atTime = state.currentTime + end + end local count = 0 local startCooldown, endCooldown = math.huge, math.huge local runeType = RUNE_TYPE[name] - local now = state.currentTime if runeType ~= DEATH_RUNE then if deathCondition == "any" then -- Match runes of the given type or any death runes. for slot, rune in ipairs(state.rune) do if rune.type == runeType or rune.type == DEATH_RUNE then - if rune:IsActiveRune(now) then + if rune:IsActiveRune(atTime) then count = count + 1 elseif rune.endCooldown < endCooldown then startCooldown, endCooldown = rune.startCooldown, rune.endCooldown @@ -357,7 +365,7 @@ statePrototype.RuneCount = function(state, name, deathCondition) for _, slot in ipairs(RUNE_SLOTS[runeType]) do local rune = state.rune[slot] if not deathCondition or (deathCondition == "none" and rune.type ~= DEATH_RUNE) then - if rune:IsActiveRune(now) then + if rune:IsActiveRune(atTime) then count = count + 1 elseif rune.endCooldown < endCooldown then startCooldown, endCooldown = rune.startCooldown, rune.endCooldown @@ -369,7 +377,7 @@ statePrototype.RuneCount = function(state, name, deathCondition) -- Match any requested death runes. for slot, rune in ipairs(state.rune) do if rune.type == DEATH_RUNE then - if rune:IsActiveRune(now) then + if rune:IsActiveRune(atTime) then count = count + 1 elseif rune.endCooldown < endCooldown then startCooldown, endCooldown = rune.startCooldown, rune.endCooldown -- 1.7.9.5