Module:Card
Usage
{{#invoke:card|cost|Donate}}
{{#invoke:card|cost|Possession}}
{{#invoke:card|cost|Wedding}}
Lua error at line 14: attempt to index global 'cost' (a nil value). $06P Lua error at line 14: attempt to index global 'cost' (a nil value).
{{#invoke:card|amount|Province}}
{{#invoke:card|amount|Province|3}}
{{#invoke:card|amount|Castles}}
{{#invoke:card|amount|Castles|3}}
{{#invoke:card|amount|Augurs}}
{{#invoke:card|amount|Smithy}}
8 12 8 12 16 10
{{#invoke:card|query|Wedding|set}}
{{#invoke:card|query|Wedding|illustrator}}
Empires Joshua Stewart
{{#invoke:card|text|Wedding}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Abundance}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Wedding|de}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Abundance|de}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Capital}}
Script error: The function "text" does not exist.
<span style='text-align:center; display:block; float:left;'>{{#invoke:card|text|Capital|en|vertical}}</span>{{clear|left}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Cemetery}}
Script error: The function "text" does not exist.
<span style='text-align:center; display:block; float:left;'>{{#invoke:card|text|Cemetery|en|vertical}}</span>{{clear|left}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Pooka}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Miserable}}
Script error: The function "text" does not exist.
<span style='text-align:center; display:block; float:left;'>{{#invoke:card|text|Miserable|en|vertical}}</span>{{clear|left}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Province}}
Script error: The function "text" does not exist.
<span style='text-align:center; display:block; float:left;'>{{#invoke:card|text|Province|en|vertical}}</span>{{clear|left}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Gold}}
Script error: The function "text" does not exist.
<span style='text-align:center; display:block; float:left;'>{{#invoke:card|text|Gold|en|vertical}}</span>{{clear|left}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Hunting Grounds|jp}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Tea House}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Tea House|jp}}
Script error: The function "text" does not exist.
{{#invoke:card|text|Apprentice}}
Script error: The function "text" does not exist.
local p = {} --p stands for package
-- usage: {{#invoke:card|cost|Wedding}}
-- returns the cost of the card with a specific format (e.g. $0008D $06P $0403D)
function p.cost(frame)
-- if not cards[frame.args[1]] or not cards[frame.args[1]]["cost"] then
-- return ""
-- end
local card = mw.loadJsonData(frame.args[1].."/json")
local coin = "$" .. string.format("%02d", card["cost"]["coin"])
local debt = ""
local potion = ""
if card["cost"]["debt"] ~= 0 then
debt= string.format("%02d", cost["debt"]) .. "D"
end
if card["cost"]["potion"] ~= 0 then
potion = "P"
end
return coin .. card["cost"]["extra"] .. debt .. potion
end
-- usage: {{#invoke:card|amount|Province}} / {{#invoke:card|amount|Province|3}}
-- has an optional second variable for the number of players (default is 2)
-- returns the number of cards to play with
-- (curses (and possibly other cards) not implemented properly)
-- mostly just meant as an example of what kind of functions can be written
function p.amount(frame)
-- if not cards[frame.args[1]] or not cards[frame.args[1]]["amount"] then
-- return ""
-- end
local card = mw.loadJsonData(frame.args[1].."/json")
local players = 2
if frame.args[2] then
players = frame.args[2]
end
local amounts = card["amount"]
local amount = 0
local victory = false
for _, cardtype in ipairs(card["types"]) do
if cardtype == "Victory" then
victory = true
end
end
if victory then
if players == 2 then
amount = amounts[1]
else
amount = amounts[2]
end
else
for _, num in ipairs(amounts) do
amount = amount + num
end
end
return amount
end
-- usage: {{#invoke:card|query|Wedding|text}} / {{#invoke:card|query|Wedding|illustrator}}
-- generic card data query
function p.query(frame)
-- if not frame.args[1] or not frame.args[2] or not cards[frame.args[1]] or not cards[frame.args[1]][frame.args[2]] then
if not frame.args[1] or not frame.args[2] then
return ""
end
local card = mw.loadJsonData(frame.args[1].."/json")
return card[frame.args[2]]
end
return p