Anonymous

Module:Items/ComparisonTables: Difference between revisions

From Melvor Idle
getItemUpgradeTable: Refactor
(getItemUpgradeTable: Avoid determining the stat change for upgraded items unless necessary)
(getItemUpgradeTable: Refactor)
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 467: Line 468:
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'))
for i, itemCost in ipairs(upgrade.itemCosts) do
local mat = Items.getItemByID(itemCost.id)
if mat ~= nil then
table.insert(matArray, Icons.Icon({mat.name, type='item', qty=itemCost.quantity}))
end
end
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
if useStatChange then