17,105
edits
(getSkillName: Fix again following adjustment in GameData module) |
(_getModifierText, getModifierSkills: Amend for new skill specific modifier values) |
||
Line 810: | Line 810: | ||
end | end | ||
local | local valueArray, resultArray = nil, {} | ||
if type(value) ~= 'table' then | |||
valueArray = {value} | |||
else | |||
valueArray = value | |||
end | |||
for i, subVal in ipairs(valueArray) do | |||
if | local resultText = modText | ||
-- | local modMagnitude = nil | ||
if type(subVal) == 'table' and subVal.skillID ~= nil then | |||
-- Modifier value is skill specific | |||
modMagnitude = subVal.value | |||
local skillName = p.getSkillName(subVal.skillID) | |||
if skillName ~= nil then | |||
resultText = string.gsub(resultText, '{SV0}', skillName) | |||
end | end | ||
else | |||
-- Modifier value is the magnitude only | |||
-- | modMagnitude = subVal | ||
end | end | ||
local valSign = (valueUnsigned and '' or sign) | |||
resultText = string.gsub(resultText, '{(V[^}]*)}', function(rule) return valSign .. formatModValue(modMagnitude, rule) end) | |||
resultText = string.gsub(resultText, '{S}', sign) | |||
if doColor then | |||
local colorCode = (isNegative ~= nil and isNegative and 'color:red' or 'color:green') | |||
resultText = '<span style="' .. colorCode .. '">' .. resultText .. '</span>' | |||
end | end | ||
table.insert(resultArray, resultText) | |||
end | end | ||
return | return table.concat(resultArray, '<br/>') | ||
end | end | ||
Line 867: | Line 864: | ||
function p.getModifiersText(modifiers, doColor) | function p.getModifiersText(modifiers, doColor) | ||
if modifiers == nil or Shared. | if modifiers == nil or Shared.tableIsEmpty(modifiers) then | ||
return '' | return '' | ||
end | end | ||
local modArray = {} | local modArray = {} | ||
for bonus, value in | for bonus, value in ipairs(modifiers) do | ||
table.insert(modArray, p._getModifierText(bonus, value, doColor)) | table.insert(modArray, p._getModifierText(bonus, value, doColor)) | ||
end | end | ||
Line 881: | Line 878: | ||
local skillArray = {} | local skillArray = {} | ||
for modifier, value in | for modifier, value in ipairs(modifiers) do | ||
if type(value) == 'table' then | if type(value) == 'table' then | ||
for i, subVal in | for i, subVal in ipairs(value) do | ||
local skillName = p.getSkillName(subVal | if type(subVal) == 'table' and subVal.skillID ~= nil then | ||
local skillName = p.getSkillName(subVal.skillID) | |||
if not Shared.contains(skillArray, skillName) then | |||
table.insert(skillArray, skillName) | |||
end | |||
end | end | ||
end | end |