Anonymous

Module:Shop: Difference between revisions

From Melvor Idle
1,677 bytes added ,  22 October 2022
getSkillcapeTable: Implement, _getPurchaseDescription: Implement
(Update for v1.1)
(getSkillcapeTable: Implement, _getPurchaseDescription: Implement)
Line 93: Line 93:
     end
     end
     return ''
     return ''
end
function p._getPurchaseDescription(purch)
if purch.customDescription ~= nil then
return string.gsub(purch.customDescription, '${qty}', '1')
elseif purch.contains ~= nil and purch.contains.items ~= nil and Shared.tableCount(purch.contains.items) == 1 then
local item = Items.getItemByID(purch.contains.items[1].id)
if item ~= nil then
if item.customDescription ~= nil then
return item.customDescription
elseif item.modifiers ~= nil then
return Constants.getModifiersText(item.modifiers, false)
end
end
end
return ''
end
end


Line 465: Line 481:
table.insert(resultPart, '| ' .. purchType)
table.insert(resultPart, '| ' .. purchType)
elseif column == 'Description' then
elseif column == 'Description' then
table.insert(resultPart, '| ' .. purchase.customDescription)
table.insert(resultPart, '| ' .. p._getPurchaseDescription(purchase))
elseif column == 'Cost' then
elseif column == 'Cost' then
local cellProp = '|style="text-align:right;"'
local cellProp = '|style="text-align:right;"'
Line 616: Line 632:
headerProps = {["Purchase"] = 'colspan="2" style="width:200px;"', ["Cost"] = 'style=width:120px;'}
headerProps = {["Purchase"] = 'colspan="2" style="width:200px;"', ["Cost"] = 'style=width:120px;'}
})
})
end
function p.getSkillcapeTable(frame)
local skillName = frame.args ~= nil and frame.args[1] or frame
local capeList = p.getPurchases(function(purch) return Shared.contains({'melvorD:Skillcapes', 'melvorTotH:SuperiorSkillcapes'}, purch.category) and string.find(p._getPurchaseName(purch), skillName) end)
if Shared.tableIsEmpty(capeList) then
return ''
else
local resultPart = {}
table.insert(resultPart, '{| class="wikitable"\r\n')
table.insert(resultPart, '!Skillcape!!Name!!Requirements!!Effect')
for i, cape in ipairs(capeList) do
local capeItem = Items.getItemByID(cape.contains.items[1].id)
if capeItem ~= nil then
table.insert(resultPart, '\r\n|-\r\n| ' .. Icons.Icon({capeItem.name, type='item', size='60', notext=true}))
table.insert(resultPart, '\r\n| ' .. Icons.Icon({capeItem.name, type='item', noicon=true}))
table.insert(resultPart, '\r\n| ' .. p.getRequirementString(cape.purchaseRequirements))
table.insert(resultPart, '\r\n| ' .. p._getPurchaseDescription(cape))
end
end
table.insert(resultPart, '\r\n|}')
return table.concat(resultPart)
end
end
end


Line 685: Line 725:
table.insert(resultPart, '|-\r\n|style="min-width:25px; text-align:center;" data-sort-value="' .. upgradeName .. '"| ' .. Icons.Icon({upgradeName, type='upgrade', size=50, notext=true}))
table.insert(resultPart, '|-\r\n|style="min-width:25px; text-align:center;" data-sort-value="' .. upgradeName .. '"| ' .. Icons.Icon({upgradeName, type='upgrade', size=50, notext=true}))
table.insert(resultPart, '| ' .. Icons.Icon({upgradeName, type='upgrade', noicon=true}))
table.insert(resultPart, '| ' .. Icons.Icon({upgradeName, type='upgrade', noicon=true}))
table.insert(resultPart, '| ' .. upgrade.customDescription)
table.insert(resultPart, '| ' .. p._getPurchaseDescription(upgrade))
table.insert(resultPart, '| data-sort-value="' .. dung.name .. '"| ' .. Icons.Icon({dung.name, type='dungeon'}))
table.insert(resultPart, '| data-sort-value="' .. dung.name .. '"| ' .. Icons.Icon({dung.name, type='dungeon'}))
table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. costSortValue .. '"| ' .. p.getCostString(upgrade.cost, false))
table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. costSortValue .. '"| ' .. p.getCostString(upgrade.cost, false))