Module:Items/ComparisonTables: Difference between revisions

m
no edit summary
(Fix Bob's Rake style override)
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 4: Line 4:
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local Common = require('Module:Common')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Items = require('Module:Items')
local Items = require('Module:Items')
Line 218: Line 219:
for i, spAttID in ipairs(item.specialAttacks) do
for i, spAttID in ipairs(item.specialAttacks) do
local spAtt = GameData.getEntityByID('attacks', spAttID)
local spAtt = GameData.getEntityByID('attacks', spAttID)
table.insert(txtLines, spAtt.defaultChance .. '% chance for ' .. spAtt.name .. ':')
local attChance = spAtt.defaultChance
if item.overrideSpecialChances ~= nil then
attChance = item.overrideSpecialChances[i]
end
table.insert(txtLines, attChance .. '% chance for ' .. spAtt.name .. ':')
table.insert(txtLines, spAtt.description)
table.insert(txtLines, spAtt.description)
end
end
Line 258: Line 263:
for i, spAttID in ipairs(item.specialAttacks) do
for i, spAttID in ipairs(item.specialAttacks) do
local spAtt = GameData.getEntityByID('attacks', spAttID)
local spAtt = GameData.getEntityByID('attacks', spAttID)
table.insert(txtLines, spAtt.defaultChance .. '% chance for ' .. spAtt.name .. ':')
local attChance = spAtt.defaultChance
if item.overrideSpecialChances ~= nil then
attChance = item.overrideSpecialChances[i]
end
table.insert(txtLines, attChance .. '% chance for ' .. spAtt.name .. ':')
table.insert(txtLines, spAtt.description)
table.insert(txtLines, spAtt.description)
end
end
Line 383: Line 392:
local modDetail = {}
local modDetail = {}
for i, modName in pairs(modsDL) do
for i, modName in pairs(modsDL) do
local mName, mText, mSign, mIsNeg, mValUnsigned = Constants.getModifierDetails(modName)
local mName, mText, mIsNeg, mModifyValue = Constants.getModifierDetails(modName)
modDetail[modName] = { mult = (mSign == "+" and 1 or -1) }
modDetail[modName] = { mult = (mIsNeg == false and 1 or -1) }
end
end


Line 467: Line 476:
table.insert(resultPart, '||' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true}))
table.insert(resultPart, '||' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true}))


local matArray = {}
table.insert(resultPart, '|| ' .. Common.getCostString({ items = upgrade.itemCosts, gp = upgrade.gpCost, sc = upgrade.scCost}, 'None'))
local statChangeString = ''
 
for i, itemCost in ipairs(upgrade.itemCosts) do
if useStatChange then
local mat = Items.getItemByID(itemCost.id)
-- Generate stat change column
if mat ~= nil then
local statChangeString = ''
table.insert(matArray, Icons.Icon({mat.name, type='item', qty=itemCost.quantity}))
if not Shared.tableIsEmpty(upgrade.rootItemIDs) then
if (isEquipment and item.validSlots ~= nil and mat.validSlots ~= nil) or (not isEquipment and useStatChange) and statChangeString == '' then
-- Some items (e.g. FEZ) may have multiple root items. Simply use the first one
statChangeString = Items.getStatChangeString(item, mat)
local rootItem = Items.getItemByID(upgrade.rootItemIDs[1])
if rootItem ~= nil then
statChangeString = Items.getStatChangeString(item, rootItem)
end
end
end
end
end
table.insert(resultPart, '|| '..statChangeString)
if upgrade.gpCost ~= nil and upgrade.gpCost > 0 then
table.insert(matArray, Icons.GP(upgrade.gpCost))
end
if upgrade.scCost ~= nil and upgrade.scCost > 0 then
table.insert(matArray, Icons.SC(upgrade.scCost))
end
table.insert(resultPart, '||'..table.concat(matArray, '<br/>'))
 
if useStatChange then
table.insert(resultPart, '||'..statChangeString)
end
end
end
end