Rudimentary translation of SimulationCraft's rune conditions.
Johnny C. Lam [05-15-14 - 23:18]
Rudimentary translation of SimulationCraft's rune conditions.
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1448 d5049fe3-3747-40f7-a4b5-f36d6801af5f
diff --git a/OvaleSimulationCraft.lua b/OvaleSimulationCraft.lua
index 593fd85..43ceceb 100644
--- a/OvaleSimulationCraft.lua
+++ b/OvaleSimulationCraft.lua
@@ -1085,6 +1085,16 @@ do
["^time_to_bloodlust$"] = "TimeToBloodlust()",
}
+ -- Runes
+ local RUNE_PATTERN = {
+ ["^(blood)$"] = true,
+ ["^(death)$"] = true,
+ ["^(frost)$"] = true,
+ ["^(unholy)$"] = true,
+ ["^rune%.([%w_]+)$"] = true,
+ -- ["^rune%.([%w_]+)%.([%w_]+)$"] = true,
+ }
+
local TRANSLATED_TOKEN = {
["^!$"] = "not",
["^!=$"] = "!=",
@@ -1289,6 +1299,56 @@ do
end
end
if not translated then
+ for pattern in pairs(RUNE_PATTERN) do
+ local rune = strmatch(token, pattern)
+ if rune then
+ -- Look ahead at the next token to see which rune condition is needed.
+ local _, comparatorToken = tokenIterator()
+ if comparatorToken == "=" then
+ local operandTokenType, operandToken = tokenIterator()
+ if operandTokenType == "number" then
+ local number = tonumber(operandToken)
+ local maxRunes = (rune == "death") and 6 or 2
+ if number == 0 then
+ translated = format("Rune(%s) < 1", rune)
+ elseif number == maxRunes then
+ translated = format("Rune(%s) >= %d", rune, number)
+ else -- if 0 < number and number < maxRunes then
+ translated = format("{ Rune(%s) >= %d and Rune(%s) < %d }", rune, number, rune, number + 1)
+ end
+ else
+ translated = format("RuneCount(%s) == %s", rune, operandToken)
+ end
+ elseif comparatorToken == "!=" then
+ local operandTokenType, operandToken = tokenIterator()
+ if operandTokenType == "number" then
+ local number = tonumber(operandToken)
+ local maxRunes = (rune == "death") and 6 or 2
+ if number == 0 then
+ translated = format("Rune(%s) >= 1", rune)
+ elseif number == maxRunes then
+ translated = format("Rune(%s) < %d", rune, maxRunes)
+ else -- if 0 < number and number < maxRunes then
+ translated = format("{ Rune(%s) < %d or Rune(%s) >= %d }", rune, number, rune, number + 1)
+ end
+ else
+ translated = format("not RuneCount(%s) == %s", rune, operandToken)
+ end
+ elseif comparatorToken == "<=" or comparatorToken == ">=" then
+ translated = format("Rune(%s) %s", rune, comparatorToken)
+ elseif comparatorToken == "<" or comparatorToken == ">" then
+ local operandTokenType, operandToken = tokenIterator()
+ if operandTokenType == "number" then
+ translated = format("Rune(%s) %s= %d", rune, comparatorToken, 1 + tonumber(operandToken))
+ else
+ translated = format("Rune(%s) %s= 1 + %s", rune, comparatorToken, operandToken)
+ end
+ end
+ break
+ end
+ end
+ end
+ if not translated then
translated = format("FIXME_%s", token)
end
if isTargetFound then