Anonymous

Module:Shop: Difference between revisions

From Melvor Idle
1,217 bytes added ,  8 November 2022
Adding in more expansion icons
(Add support for Pet descriptions)
Tag: Manual revert
(Adding in more expansion icons)
Line 54: Line 54:
elseif stat == 'description' then
elseif stat == 'description' then
return p._getPurchaseDescription(purchase)
return p._getPurchaseDescription(purchase)
elseif stat =='expansionicon' then
return p._getPurchaseExpansionIcon(purchase)
else
else
return purchase[stat]
return purchase[stat]
Line 101: Line 103:
                 return pet.name
                 return pet.name
             end
             end
        end
    end
    return ''
end
function p._getPurchaseExpansionIcon(purch)
    if purch.id ~= nil then
        return Icons.getExpansionIcon(purch.id)
    elseif purch.contains ~= nil then
    local item = nil
        if purch.contains.items ~= nil and not Shared.tableIsEmpty(purch.contains.items) then
            return Icons.getExpansionIcon(purch.contains.items[1].id)
        elseif purch.contains.itemCharges ~= nil and not Shared.tableIsEmpty(purch.contains.itemCharges) then
        return Icons.getExpansionIcon(purch.contains.itemCharges.id)
        end
       
        if purch.contains.petID ~= nil then
return Icons.getExpansionIcon(purch.contains.petID)
         end
         end
     end
     end
Line 310: Line 330:
GPTotal = GPTotal + GPVal
GPTotal = GPTotal + GPVal
table.insert(containArray, '|-\r\n| style="min-width:25px"| ' .. Icons.Icon({item.name, type='item', notext=true, size='25'}))
table.insert(containArray, '|-\r\n| style="min-width:25px"| ' .. Icons.Icon({item.name, type='item', notext=true, size='25'}))
table.insert(containArray, '| ' .. Icons.Icon({item.name, type='item', noicon=true}) .. '\r\n| data-sort-value="' .. itemQty .. '" style="text-align:right" | ' .. Shared.formatnum(itemQty))
table.insert(containArray, '|data-sort-value="'..item.name..'"|'.. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true}) .. '\r\n| data-sort-value="' .. itemQty .. '" style="text-align:right" | ' .. Shared.formatnum(itemQty))
table.insert(containArray, '| data-sort-value="' .. GPVal .. '"| ' .. Icons.GP(GPVal))
table.insert(containArray, '| data-sort-value="' .. GPVal .. '"| ' .. Icons.GP(GPVal))
end
end
Line 502: Line 522:
for i, purchase in ipairs(Purchases) do
for i, purchase in ipairs(Purchases) do
         local purchName = p._getPurchaseName(purchase)
         local purchName = p._getPurchaseName(purchase)
        local purchExpIcon = p._getPurchaseExpansionIcon(purchase)
local purchOverride = nil
local purchOverride = nil
if purchOverrides ~= nil then
if purchOverrides ~= nil then
Line 519: Line 540:
end
end


        local purchSortName = purchName
if iconNoLink == nil or iconNoLink ~= true then purchName = '[[' .. purchLink .. purchName .. ']]' end
if iconNoLink == nil or iconNoLink ~= true then purchName = '[[' .. purchLink .. purchName .. ']]' end


Line 526: Line 548:
table.insert(resultPart, '|style="min-width:25px"|' .. p._getPurchaseIcon({purchase, notext=true, size='50'}))
table.insert(resultPart, '|style="min-width:25px"|' .. p._getPurchaseIcon({purchase, notext=true, size='50'}))
--table.insert(resultPart, '|style="min-width:25px"|' .. Icons.Icon({iconName, type=iconType, notext=true, nolink=iconNoLink, size='50'}))
--table.insert(resultPart, '|style="min-width:25px"|' .. Icons.Icon({iconName, type=iconType, notext=true, nolink=iconNoLink, size='50'}))
table.insert(resultPart, '| ' .. purchName)
table.insert(resultPart, '| data-sort-value="'..purchSortName..'"|'..purchExpIcon .. purchName)
elseif column == 'Type' then
elseif column == 'Type' then
table.insert(resultPart, '| ' .. purchType)
table.insert(resultPart, '| ' .. purchType)
Line 630: Line 652:
result = result..'\r\n!colspan="2"|'..Icons.Icon({'Shop'})..' Purchase'
result = result..'\r\n!colspan="2"|'..Icons.Icon({'Shop'})..' Purchase'
if purchase.contains.items ~= nil and Shared.tableCount(purchase.contains.items) > 1 then
if purchase.contains.items ~= nil and Shared.tableCount(purchase.contains.items) > 1 then
result = result..' - '..Icons.Icon({p._getPurchaseName(purchase), type='item'})
result = result..' - '..p._getPurchaseExpansionIcon(purchase)..Icons.Icon({p._getPurchaseName(purchase), type='item'})
end
end


Line 714: Line 736:
if capeItem ~= nil then
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|-\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| data-sort-value="'..capeItem.name..'"|'..Icons.getExpansionIcon(capeItem.id) .. Icons.Icon({capeItem.name, type='item', noicon=true}))
table.insert(resultPart, '\r\n| ' .. p.getRequirementString(cape.purchaseRequirements))
table.insert(resultPart, '\r\n| ' .. p.getRequirementString(cape.purchaseRequirements))
table.insert(resultPart, '\r\n| ' .. p._getPurchaseDescription(cape))
table.insert(resultPart, '\r\n| ' .. p._getPurchaseDescription(cape))
Line 790: Line 812:
local dung = getGodDungeon(upgrade.purchaseRequirements)
local dung = getGodDungeon(upgrade.purchaseRequirements)
local costSortValue = p._getPurchaseSortValue(upgrade)
local costSortValue = p._getPurchaseSortValue(upgrade)
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 .. '"| ' ..p._getPurchaseExpansionIcon(upgrade).. 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, '| ' .. p._getPurchaseDescription(upgrade))
table.insert(resultPart, '| ' .. p._getPurchaseDescription(upgrade))
Line 857: Line 879:
table.insert(resultPart, '|-')
table.insert(resultPart, '|-')
table.insert(resultPart, '|style="min-width:25px"|' .. Icons.Icon({utilityName, type='upgrade', size='50', notext=true}))
table.insert(resultPart, '|style="min-width:25px"|' .. Icons.Icon({utilityName, type='upgrade', size='50', notext=true}))
table.insert(resultPart, '|' .. utilityName)
table.insert(resultPart, '|data-sort-value="'..utilityName..'|'..p._getPurchaseExpansionIcon(utility) .. utilityName)
table.insert(resultPart, '|style="text-align:right"|' .. p.getRequirementString(utility.purchaseRequirements))
table.insert(resultPart, '|style="text-align:right"|' .. p.getRequirementString(utility.purchaseRequirements))
table.insert(resultPart, '|style="text-align:right"|' .. p.getCostString(utility.cost, false))
table.insert(resultPart, '|style="text-align:right"|' .. p.getCostString(utility.cost, false))