Module:Sandbox/Constants: Difference between revisions

Re-added nil check in the event a non-existent modifier gets pushed
(Fixed missing -, cleaned up a bit more)
(Re-added nil check in the event a non-existent modifier gets pushed)
Line 908: Line 908:


--Turns a modifier name like 'increasedMeleeAccuracyBonus' into several pieces of data:
--Turns a modifier name like 'increasedMeleeAccuracyBonus' into several pieces of data:
--Base Name, Text, Sign, and IsNegative
--Base Name, Description, IsNegative, and modifierData
--ex. "MeleeAccuracyBonus", "+{V}% Melee Accuracy", "+", false
--ex. "MeleeAccuracyBonus", "+${value}% Melee Accuracy Rating", false, table
function p.getModifierDetails(modifierName)
function p.getModifierDetails(modifierName)
local baseName = modifierName
local baseName = modifierName
Line 919: Line 919:
end
end


--TODO: Is this necessary anymore? This could theoretically match 'increasedRolledReflectDamage' ('+0-${value} Reflect Damage') incorrectly but this isn't used
if modifier == nil then
return nil
end
 
--TODO: Is this still needed?
local sign = "+"
local sign = "+"
if string.match(modifier.description, '-${value}') then
if string.match(modifier.description, '-${value}') then
Line 992: Line 996:
end
end


local valSign = (valueUnsigned and '' or '')
resultText = string.gsub(resultText, '${(value[^}]*)}', function(rule) return (formatModValue(modMagnitude, rule) or '') end)
resultText = string.gsub(resultText, '${(value[^}]*)}', function(rule) return valSign .. (formatModValue(modMagnitude, rule) or '') end)


if doColor then
if doColor then