17,101
edits
Falterfire (talk | contribs) (Added p.getPurchases for use in the ModifierTables module I'm working on) |
(getCostString/_getShopTable: Support Golbin Raid shop items) |
||
Line 23: | Line 23: | ||
if cost.slayerCoins ~= nil and cost.slayerCoins > 0 then | if cost.slayerCoins ~= nil and cost.slayerCoins > 0 then | ||
table.insert(costArray, Icons.SC(cost.slayerCoins)) | table.insert(costArray, Icons.SC(cost.slayerCoins)) | ||
end | |||
if cost.raidCoins ~= nil and cost.raidCoins > 0 then | |||
table.insert(costArray, Icons.RC(cost.raidCoins)) | |||
end | end | ||
local itemArray = {} | local itemArray = {} | ||
Line 92: | Line 95: | ||
local result = '{| class="wikitable sortable stickyHeader"' | local result = '{| class="wikitable sortable stickyHeader"' | ||
result = result..'\r\n|- class="headerRow-0"' | result = result..'\r\n|- class="headerRow-0"' | ||
result = result..'\r\n!colspan="2"|Purchase!!Type!!Description!!style="min-width: | result = result..'\r\n!colspan="2"|Purchase!!Type!!Description!!style="min-width:110px"|Cost!!Requirements' | ||
local costCurrencies = {'gp', 'slayerCoins', 'raidCoins'} | |||
for i, purchase in Shared.skpairs(Purchases) do | for i, purchase in Shared.skpairs(Purchases) do | ||
result = result..'\r\n|-\r\n|' | result = result..'\r\n|-\r\n|' | ||
local | local purchType = 'Item' | ||
if purchase.contains.pet ~= nil then | |||
purchType = 'Pet' | |||
elseif purchase.contains.modifiers ~= nil or purchase.contains.items == nil or Shared.tableCount(purchase.contains.items) == 0 then | |||
purchType = 'Upgrade' | |||
elseif purchase.contains.items ~= nil and Shared.tableCount(purchase.contains.items) > 1 then | |||
purchType = 'Item Bundle' | |||
end | end | ||
-- Translate certain media strings to icons, mostly for Golbin Raid shop objects | |||
local iconOverrides = { | |||
["assets/media/main/logo.svg"] = { icon = 'Melvor Logo', type = nil }, | |||
["assets/media/skills/prayer/prayer.svg"] = { icon = 'Prayer', type = 'skill' } | |||
} | |||
local iconName, iconType = purchase.name, (purchType == 'Item Bundle' and 'item' or string.lower(purchType)) | |||
if iconOverrides[purchase.media] ~= nil then | |||
iconName, iconType = iconOverrides[purchase.media].icon, iconOverrides[purchase.media].type | |||
end | |||
result = result..Icons.Icon({iconName, type=iconType, notext=true, size='50'}) | |||
result = result..'||'..purchase.name..'||'..purchType | |||
result = result..'||'..purchase.description..'||style="text-align:right;"' | result = result..'||'..purchase.description..'||style="text-align:right;"' | ||
for j, curr in Shared.skpairs(costCurrencies) do | |||
local costAmt = purchase.cost[curr] | |||
if costAmt ~= nil and costAmt > 0 then | |||
result = result..' data-sort-value="'..costAmt..'"' | |||
break | |||
end | |||
end | end | ||
result = result..'|'..p.getCostString(purchase.cost)..'||'..p.getRequirementString(purchase.unlockRequirements) | result = result..'|'..p.getCostString(purchase.cost)..'||'..p.getRequirementString(purchase.unlockRequirements) |