1,291
edits
(tribe-exclusive filter) |
(oops) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 54: | Line 54: | ||
elseif stat == "price" then | elseif stat == "price" then | ||
return card.Price or "" | return card.Price or "" | ||
elseif stat == "unlock" then | |||
return card.Unlock or "" | |||
elseif stat == "challenge" then | elseif stat == "challenge" then | ||
return card.Challenge or "" | return card.Challenge or "" | ||
else | else | ||
error("Argument Invalid:" .. stat) | error("Argument Invalid:" .. stat) -- why is this necessary | ||
end | end | ||
end | end | ||
Line 203: | Line 205: | ||
out = out.."|" | out = out.."|" | ||
if header == "image" then | if header == "image" then | ||
out = out.."{{CardArt|".. (card.Image or card.UniqueName) .."}}" | if card.Types and (card.Types["Charm"] or card.Types["CursedCharm"]) then | ||
out = out.."{{CharmArt|" | |||
else | |||
out = out.."{{CardArt|" | |||
end | |||
out = out.. (card.Image or card.UniqueName) .."}}" | |||
elseif header == "name" then | elseif header == "name" then | ||
local link = card.Link or card.UniqueName | local link = card.Link or card.UniqueName | ||
Line 282: | Line 289: | ||
function trim(str) | function trim(str) | ||
return str:match( "^%s*(.-)%s*$" ) | return str:match( "^%s*(.-)%s*$" ) | ||
end | |||
--[[ | |||
Usage: {{#invoke:Cards|CharmInfobox|<card>|<template_params>}} | |||
returns the infobox of the charm. | |||
<template_params> is a list of template parameters input as multiple parameters, ie <p1>=<data1>|<p2>=<data2>|... etc. | |||
These parameters are the same parameters used by Template:Infobox | |||
Parameters without inputs are autofilled with fitting module data, to the best of its ability. | |||
]] | |||
function p.CharmInfobox(frame) | |||
local card = frame.args[1] | |||
card = trim(card) | |||
return frame:preprocess(_charmInfobox(all_cards[card], frame.args)) | |||
end | |||
function _charmInfobox(card, params) | |||
local out = "{{infobox|category=Charm" | |||
out = out .. "|name=" .. (params.name or _getName(card) or card.Name or "<br>") | |||
out = out .. "|image=" .. (params.image or "") | |||
out = out .. "|width=" .. (params.width or "") | |||
out = out .. "|description=" .. (params.description or _getDesc(card) or card.Desc or "<br>") | |||
out = out .. "}}" | |||
return out | |||
end | end | ||
edits