| This module depends on the following other modules: |
| This module uses the following Cargo tables: |
To generate {{Event shop card}}, invoke the main function.
local getArgs = require('Module:Arguments').getArgs
local QueryBuilder = require('Module:QueryBuilder')
local p = {}
function p.main(frame)
local args = getArgs(frame)
local cardId = args['card id']
local cost = args['cost']
local thumbnail = ''
local name = ''
if cardId and tonumber(cardId) > 0 then
local qb = QueryBuilder.new()
qb
:setTables('cards')
:setFields([[
_pageName,
card_name,
thumbnail
]])
:addWhere('card_id', '=', cardId)
local results = qb:query()
if #results > 0 then
local thumb = results[1]['thumbnail']
local cardName = results[1]['card_name']
local page = results[1]['_pageName']
thumbnail = '?'
if thumb ~= nil and thumb ~= '' then
thumbnail = string.format(
'[[File:%s|75px|link=%s]]',
thumb,
page
)
end
name = string.format('[[%s|%s]]', page, cardName)
end
end
return frame:expandTemplate{
title = 'Event shop line',
args = {
thumbnail = thumbnail,
name = name,
quantity = 1,
cost = cost
}
}
end
return p