Module:GolbinRaid: Difference between revisions

Removed prefix code in getRaidModifierList
(Update for v1.1)
(Removed prefix code in getRaidModifierList)
 
(2 intermediate revisions by 2 users not shown)
Line 32: Line 32:
end
end


for i, crateEntry in Shared.spairs(GameData.golbinRaid.crateItems, sortFunc) do
for i, crateEntry in Shared.spairs(GameData.rawData.golbinRaid.crateItems, sortFunc) do
local item = Items.getItemByID(crateEntry.itemID)
local item = Items.getItemByID(crateEntry.itemID)
if item ~= nil then
if item ~= nil then
Line 57: Line 57:
-- If the item has special attacks, use those
-- If the item has special attacks, use those
local spAttText = {}
local spAttText = {}
for j, spAtt in ipairs(item.specialAttacks) do
for j, spAttID in ipairs(item.specialAttacks) do
table.insert(spAttText, '<b>' .. spAtt.name .. ' (' .. Shared.round(spAtt.defaultChance, 2, 0) .. '%)</b> - ' .. spAtt.description)
local spAtt = GameData.getEntityByID('attacks', spAttID)
if spAtt ~= nil then
table.insert(spAttText, '<b>' .. spAtt.name .. ' (' .. Shared.round(spAtt.defaultChance, 2, 0) .. '%)</b> - ' .. spAtt.description)
end
end
end
descText = table.concat(spAttText, '<br/>')
descText = table.concat(spAttText, '<br/>')
Line 81: Line 84:
function p.getRaidModifierList()
function p.getRaidModifierList()
local modList = {}
local modList = {}
for i, modDet in ipairs(GameData.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)
local prefix = ''
if Shared.startsWith(baseName, 'increased') or Shared.startsWith(baseName, 'decreased') then
prefix = string.sub(baseName, 1, 9)
end
if modList[baseName] == nil then
if modList[baseName] == nil then
local modVal = {1, 5}
local modVal = {1, 5}
Line 94: Line 93:
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 110: Line 109:
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
599

edits