17,030
edits
(Fix check for empty special attacks table) |
(getItemUpgradeTable: Update for v1.1) |
||
Line 448: | Line 448: | ||
function p.getItemUpgradeTable(frame) | function p.getItemUpgradeTable(frame) | ||
local category = frame.args ~= nil and frame.args[1] or frame | local category = frame.args ~= nil and frame.args[1] or frame | ||
local | local upgradeArray = {} | ||
local isEquipment = false | local isEquipment = false | ||
if string.upper(category) == 'POTION' then | if string.upper(category) == 'POTION' then | ||
upgradeArray = GameData.getEntities('itemUpgrades', | |||
function(upgrade) return Shared.contains(upgrade.upgradedItemID, 'Potion') end | |||
) | |||
elseif string.upper(category) == 'OTHER' then | elseif string.upper(category) == 'OTHER' then | ||
upgradeArray = GameData.getEntities('itemUpgrades', | |||
function(upgrade) | |||
end) | if not Shared.contains(upgrade.upgradedItemID, 'Potion') then | ||
local item = Items.getItemByID(upgrade.upgradedItemID) | |||
if item ~= nil then | |||
return item.validSlots == nil or Shared.tableIsEmpty(item.validSlots) | |||
end | |||
end | |||
return false | |||
end | |||
) | |||
else | else | ||
if Constants.getEquipmentSlotID(category) == nil then | if Constants.getEquipmentSlotID(category) == nil then | ||
Line 462: | Line 472: | ||
end | end | ||
isEquipment = true | isEquipment = true | ||
upgradeArray = GameData.getEntities('itemUpgrades', | |||
return item. | function(upgrade) | ||
end) | local item = Items.getItemByID(upgrade.upgradedItemID) | ||
if item ~= nil then | |||
return item.validSlots ~= nil and Shared.contains(item.validSlots, category) | |||
end | |||
return false | |||
end | |||
) | |||
end | end | ||
Line 473: | Line 489: | ||
if isEquipment then table.insert(resultPart, '!!Stat Change') end | if isEquipment then table.insert(resultPart, '!!Stat Change') end | ||
for i, item | for i, upgrade in ipairs(upgradeArray) do | ||
local item = Items.getItemByID(upgrade.upgradedItemID) | |||
table.insert(resultPart, '\r\n|-') | table.insert(resultPart, '\r\n|-') | ||
table.insert(resultPart, '\r\n|'..Icons.Icon({item.name, type='item', size='50', notext=true})) | table.insert(resultPart, '\r\n|'..Icons.Icon({item.name, type='item', size='50', notext=true})) | ||
Line 480: | Line 497: | ||
local matArray = {} | local matArray = {} | ||
local statChangeString = '' | local statChangeString = '' | ||
for i, | for i, itemCost in ipairs(upgrade.itemCosts) do | ||
local mat = Items.getItemByID( | local mat = Items.getItemByID(itemCost.id) | ||
table.insert(matArray, Icons.Icon({mat.name, type='item', qty= | if mat ~= nil then | ||
table.insert(matArray, Icons.Icon({mat.name, type='item', qty=itemCost.quantity})) | |||
if isEquipment and item.validSlots ~= nil and mat.validSlots ~= nil and statChangeString == '' then | |||
statChangeString = p.getStatChangeString(item, mat) | |||
end | |||
end | end | ||
end | end | ||
if | if upgrade.gpCost ~= nil and upgrade.gpCost > 0 then | ||
table.insert(matArray, Icons.GP( | 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 | end | ||
table.insert(resultPart, '||'..table.concat(matArray, '<br/>')) | table.insert(resultPart, '||'..table.concat(matArray, '<br/>')) |