Johnny C. Lam [12-31-14 - 20:14]
diff --git a/Runes.lua b/Runes.lua
index e3ee735..d73a0f9 100644
--- a/Runes.lua
+++ b/Runes.lua
@@ -430,8 +430,12 @@ 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, atTime)
+statePrototype.RuneCount = function(state, name, includeDeath, atTime)
OvaleRunes:StartProfiling("OvaleRunes_state_RuneCount")
+ -- Default to matching death runes of the same type.
+ if type(includeDeath) == "number" then
+ includeDeath, atTime = nil, includeDeath
+ end
-- 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
@@ -444,20 +448,26 @@ statePrototype.RuneCount = function(state, name, atTime)
local count = 0
local startCooldown, endCooldown = INFINITY, INFINITY
local runeType = RUNE_TYPE[name]
- if runeType ~= DEATH_RUNE then
+ if runeType ~= DEATH_RUNE and not includeDeath then
-- Match only the runes of the given type.
for _, slot in ipairs(RUNE_SLOTS[runeType]) do
local rune = state.rune[slot]
- if rune:IsActiveRune(atTime) then
- count = count + 1
- elseif rune.endCooldown < endCooldown then
- startCooldown, endCooldown = rune.startCooldown, rune.endCooldown
+ local matched = (rune.type == runeType)
+ if includeDeath == nil then
+ matched = matched or rune.type == "DEATH_RUNE"
+ end
+ if matched then
+ if rune:IsActiveRune(atTime) then
+ count = count + 1
+ elseif rune.endCooldown < endCooldown then
+ startCooldown, endCooldown = rune.startCooldown, rune.endCooldown
+ end
end
end
else
- -- Match any requested death runes.
+ -- Match any runes that can satisfy the rune type.
for slot, rune in ipairs(state.rune) do
- if rune.type == DEATH_RUNE then
+ if rune.type == runeType or rune.type == DEATH_RUNE then
if rune:IsActiveRune(atTime) then
count = count + 1
elseif rune.endCooldown < endCooldown then
diff --git a/conditions.lua b/conditions.lua
index f736b1c..62e8578 100644
--- a/conditions.lua
+++ b/conditions.lua
@@ -4236,6 +4236,9 @@ do
-- Valid values: blood, frost, unholy, death
-- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more.
-- @param number Optional. The number to compare against.
+ -- @param death Optional. Set death=1 to include all active and regenerating death runes in the count. Set death=0 to exclude all death runes.
+ -- Defaults to unset.
+ -- Valid values: unset, 0, 1
-- @return The number of runes.
-- @return A boolean value for the result of the comparison.
-- @see DeathRune, RuneCount
@@ -4244,7 +4247,15 @@ do
local function Rune(condition, state)
local name, comparator, limit = condition[1], condition[2], condition[3]
- local count, startCooldown, endCooldown = state:RuneCount(name)
+ local includeDeath
+ if condition.death == 1 then
+ includeDeath = true
+ elseif condition.death == 0 then
+ includeDeath = false
+ --else
+ -- includeDeath = nil
+ end
+ local count, startCooldown, endCooldown = state:RuneCount(name, includeDeath)
if startCooldown < INFINITY then
local origin = startCooldown
local rate = 1 / (endCooldown - startCooldown)
@@ -4286,6 +4297,9 @@ do
-- Valid values: blood, frost, unholy, death
-- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more.
-- @param number Optional. The number to compare against.
+ -- @param death Optional. Set death=1 to include all active death runes in the count. Set death=0 to exclude all death runes.
+ -- Defaults to unset.
+ -- Valid values: unset, 0, 1
-- @return The number of runes.
-- @return A boolean value for the result of the comparison.
-- @see Rune
@@ -4295,7 +4309,15 @@ do
local function RuneCount(condition, state)
local name, comparator, limit = condition[1], condition[2], condition[3]
- local count, startCooldown, endCooldown = state:RuneCount(name)
+ local includeDeath
+ if condition.death == 1 then
+ includeDeath = true
+ elseif condition.death == 0 then
+ includeDeath = false
+ --else
+ -- includeDeath = nil
+ end
+ local count, startCooldown, endCooldown = state:RuneCount(name, includeDeath)
if startCooldown < INFINITY then
local start, ending = startCooldown, endCooldown
return TestValue(start, ending, count, start, 0, comparator, limit)