Anonymous

Module:GolbinRaid: Difference between revisions

From Melvor Idle
Updated for changes in Constants, getModifierDetails
(Correct various issues)
(Updated for changes in Constants, getModifierDetails)
Line 85: Line 85:
local modList = {}
local modList = {}
for i, modDet in ipairs(GameData.rawData.golbinRaid.possibleModifiers) do
for i, modDet in ipairs(GameData.rawData.golbinRaid.possibleModifiers) do
local baseName, modText, modSign, isNeg, isUnsigned = Constants.getModifierDetails(modDet.key)
local baseName, modText, isNeg, modifyValue = Constants.getModifierDetails(modDet.key)
--TODO: Is this necessary? getModifierDetails has the same code and this function doesn't have params
local prefix = ''
local prefix = ''
if Shared.startsWith(baseName, 'increased') or Shared.startsWith(baseName, 'decreased') then
if Shared.startsWith(baseName, 'increased') or Shared.startsWith(baseName, 'decreased') then
Line 97: Line 98:
end
end
modText = Constants._getModifierText(modDet.key, modVal, false)
modText = Constants._getModifierText(modDet.key, modVal, false)
modList[baseName] = {modText, ["ord"] = i, ["sign"] = {modSign}}
modList[baseName] = {modText, ["ord"] = i, ["mods"] = 1}
else
else
table.insert(modList[baseName]['sign'], modSign)
modList[baseName]["mods"] = modList[baseName]["mods"] + 1
end
end
end
end
Line 113: Line 114:
for baseName, modDet in Shared.spairs(modList, sortFunc) do
for baseName, modDet in Shared.spairs(modList, sortFunc) do
local modText = modDet[1]
local modText = modDet[1]
if #modDet['sign'] > 1 then
if modDet['mods'] > 1 then
local replPat = modDet['sign'][1] .. '(%d)'
local replPat = '[+-]'
local signs = table.concat(modDet['sign'], '/')
modText = string.gsub(modDet[1], replPat, '+/-', 2)
modText = string.gsub(modDet[1], replPat, signs .. '%1', 1)
end
end
resultTable:tag('tr')
resultTable:tag('tr')
:tag('td'):wikitext(modText):done()
:tag('td'):wikitext(modText):done()
end
end
 
return tostring(resultTable)
return tostring(resultTable)
end
end


return p
return p