4,687
edits
(Re-added nil check in the event a non-existent modifier gets pushed) |
(Updated Sign check in getModifierDetails) |
||
Line 907: | Line 907: | ||
--- End of slayer functions | --- End of slayer functions | ||
--Turns a modifier name like ' | --Turns a modifier name like 'increasedHPRegenFlat' into several pieces of data: | ||
--Base Name, Description, IsNegative, and | --Base Name, Description, Sign, IsNegative, valueUnsigned and modifyValue | ||
--ex. " | --ex. "HPRegenFlat", "+${value} Flat Hitpoints Regeneration", "+", false, false, "multiplyByNumberMultiplier" | ||
function p.getModifierDetails(modifierName) | function p.getModifierDetails(modifierName) | ||
local baseName = modifierName | local baseName = modifierName | ||
local valueUnsigned = false | local valueUnsigned = false | ||
local modifier = GameData.rawData.modifierData[modifierName] | local modifier = GameData.rawData.modifierData[modifierName] | ||
if modifier == nil then | if modifier == nil then | ||
Line 923: | Line 919: | ||
end | end | ||
--TODO: | if Shared.startsWith(modifierName, "increased") or Shared.startsWith(modifierName, "decreased") then | ||
baseName = string.sub(modifierName, 10) | |||
end | |||
sign = " | --TODO: This won't work for ReflectDamage: "+0-${value} Reflect Damage" and "-0-${value} Reflect Damage" | ||
local i, j = string.find(modifier.description, '${value}') | |||
local sign = string.sub(modifier.description, i-1, i-1) | |||
if sign ~= "-" and sign ~= "+" then | |||
sign = "+" | |||
valueUnsigned = true | |||
end | end | ||
return baseName, modifier.description, sign, modifier.isNegative, valueUnsigned, modifier.modifyValue | |||
return baseName, modifier.description, sign, modifier.isNegative, valueUnsigned, modifier | |||
end | end | ||
function p._getModifierText(modifier, value, doColor) | function p._getModifierText(modifier, value, doColor) | ||
if doColor == nil then doColor = true end | if doColor == nil then doColor = true end | ||
local modName, modText, sign, isNegative, valueUnsigned, | local modName, modText, sign, isNegative, valueUnsigned, modifyValue = p.getModifierDetails(modifier) | ||
if modName == nil then | if modName == nil then | ||
return Shared.printError('Invalid modifier type for "' .. modifier .. '"') | return Shared.printError('Invalid modifier type for "' .. modifier .. '"') | ||
end | end | ||
local formatModValue = function(value, rule) | local formatModValue = function(value, rule) | ||
local ruleFunctions = { | local ruleFunctions = { | ||
Line 964: | Line 963: | ||
end | end | ||
} | } | ||
local ruleFunc = ruleFunctions[ | local ruleFunc = ruleFunctions[modifyValue] or ruleFunctions['value'] | ||
if type(value) == 'table' then | if type(value) == 'table' then |