17,481
edits
(Update for v1.1) |
(Update for new skill modifier data structure) |
||
Line 30: | Line 30: | ||
--By default, attempt to add the increased and decreased prefixes to the modifier | --By default, attempt to add the increased and decreased prefixes to the modifier | ||
--But if getOpposites is false, only look for an exact match | --But if getOpposites is false, only look for an exact match | ||
local | |||
local mods = {} | |||
if getOpposites == nil or getOpposites then | if getOpposites == nil or getOpposites then | ||
mods.inc = 'increased'..modifier | |||
mods.dec = 'decreased'..modifier | |||
else | else | ||
mods.inc = modifier | |||
end | end | ||
local magnitude = { inc = 0, dec = 0 } | |||
for modType, modName in pairs(mods) do | |||
if modifiers[modName] ~= nil then | |||
local valueArray = nil | |||
if type(modifiers[modName]) ~= 'table' then | |||
valueArray = {modifiers[modName]} | |||
else | |||
valueArray = modifiers[modName] | |||
end | |||
for i, subVal in ipairs(valueArray) do | |||
if type(subVal) == 'table' and subVal.skillID ~= nil then | |||
-- Modifier value is skill specific | |||
if skill == nil or skill == '' or subVal.skillID == skill then | |||
magnitude[modType] = magnitude[modType] + subVal.value | |||
end | |||
else | |||
magnitude[modType] = magnitude[modType] + subVal | |||
end | |||
end | |||
end | end | ||
end | end | ||
return magnitude.inc - magnitude.dec | |||
end | end | ||
Line 225: | Line 220: | ||
local mainModText = {} | local mainModText = {} | ||
for modName, modValue in Shared.skpairs(modifiers) do | for modName, modValue in Shared.skpairs(modifiers) do | ||
local includedMod = Shared.contains(modifierNames, modName) | |||
local valueArray = nil | |||
if type(modValue) ~= 'table' then | |||
valueArray = {modValue} | |||
else | |||
valueArray = modValue | |||
end | |||
for j, subVal in ipairs(valueArray) do | |||
local includeInMainText = includedMod | |||
if type(subVal) == 'table' and subVal.skillID ~= nil then | |||
-- Modifier value is skill specific | |||
if includeInMainText then | |||
-- If the skill doesn't match then don't include in the main text | |||
includeInMainText = skill == nil or skill == '' or subVal.skillID == skill | |||
end | |||
end | |||
if includeInMainText then | |||
table.insert(mainModText, Constants._getModifierText(modName, subVal)) | |||
else | |||
otherModCount = otherModCount + 1 | |||
local key = ((maxOtherMods == nil or otherModCount <= maxOtherMods) and 'visible') or 'overflow' | |||
table.insert(modTextArray[key], Constants._getModifierText(modName, subVal)) | |||
end | |||
end | |||
end | |||
local overflowModCount = Shared.tableCount(modTextArray['overflow']) | local overflowModCount = Shared.tableCount(modTextArray['overflow']) |