17,370
edits
(Change displayed requirements throughout) |
(Generate & use template data for descriptions) |
||
Line 105: | Line 105: | ||
function p._getPurchaseDescription(purch) | function p._getPurchaseDescription(purch) | ||
if purch.customDescription ~= nil then | if purch.customDescription ~= nil then | ||
return | local templateData = p._getPurchaseTemplateData(purch) | ||
return Shared.applyTemplateData(purch.customDescription, templateData) | |||
elseif purch.contains ~= nil then | elseif purch.contains ~= nil then | ||
local item = nil | local item = nil | ||
Line 157: | Line 158: | ||
return mw.text.listToText(costArray, sep, lastSep) | return mw.text.listToText(costArray, sep, lastSep) | ||
end | end | ||
end | |||
-- Generates description template data. See: shop.js, getDescriptionTemplateData() | |||
function p._getPurchaseTemplateData(purchase) | |||
-- qty is a static value of 1 for Bank slots | |||
local templateData = { qty = 1 } | |||
if purchase.contains ~= nil and purchase.contains.items ~= nil then | |||
for i, itemDef in ipairs(purchase.contains.items) do | |||
templateData['qty' .. i] = itemDef.quantity | |||
end | |||
end | |||
return templateData | |||
end | end | ||