1,291
edits
mNo edit summary |
(oops) |
||
(18 intermediate revisions by 2 users not shown) | |||
Line 50: | Line 50: | ||
end | end | ||
return out | return out | ||
elseif stat == "gold" then | |||
return card.Gold or "" | |||
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 | ||
function _getOtherLangs(card) | function _getOtherLangs(card) | ||
if all_langs[card.UniqueName] then | |||
return all_langs[card.UniqueName] | |||
end | |||
if all_langs[card.Name] then | if all_langs[card.Name] then | ||
return all_langs[card.Name] | return all_langs[card.Name] | ||
end | end | ||
for _, langs in pairs(all_langs) do | for _, langs in pairs(all_langs) do | ||
Line 97: | Line 104: | ||
returns a table based on the given paramenters. | returns a table based on the given paramenters. | ||
<entry> is either a card name or type. | <entry> is either a card name or type. | ||
Types include: Boss Pet NonPetCompanion Companion Item Shade Clunker EnemyClunker Enemy Miniboss Boss ShopItem | Types include: Boss Pet NonPetCompanion Companion Item Shade Clunker EnemyClunker Enemy Miniboss Boss ShopItem | ||
Append a tribename before the type to filter cards exclusive to that tribe, eg "SnowdwellersCompanion" | |||
<entry_list> is a list of valid <entry> values, input as multiple parameters, ie <entry1>|<entry2>|... etc. | <entry_list> is a list of valid <entry> values, input as multiple parameters, ie <entry1>|<entry2>|... etc. | ||
<header_list> is a list of valid stats, input as multiple parameters, ie <stat1>|<stat2>|... etc. | <header_list> is a list of valid stats, input as multiple parameters, ie <stat1>|<stat2>|... etc. | ||
stats include: name health scrap attack counter other desc summoncon tribes price | stats include: name health scrap attack counter other desc summoncon tribes price | ||
The first usage option is used when only 1 entry is needed, eg the only entry is a type category. otherwise, use the second option. | The first usage option is used when only 1 entry is needed, eg the only entry is a type category. otherwise, use the second option. | ||
Line 129: | Line 138: | ||
function p.testy() | function p.testy() | ||
return _table({"Pet", " | return _table({"Pet", "SnowdwellersNonPetCompanion"}, {"name", "desc", "challenge"}) | ||
end | end | ||
Line 161: | Line 170: | ||
all_cards[entry].UniqueName = entry | all_cards[entry].UniqueName = entry | ||
table.insert(entryList, all_cards[entry]) | table.insert(entryList, all_cards[entry]) | ||
else | else -- entry is a type category | ||
local tribe = nil | |||
for _, tribename in ipairs({"Snowdwellers", "Shademancers", "Clunkmasters"}) do | |||
if entry:sub(1, #tribename) == tribename then | |||
tribe = tribename | |||
entry = entry:sub(1+#tribename) | |||
end | |||
end | |||
for i, card in ipairs(sortedCards()) do | for i, card in ipairs(sortedCards()) do | ||
if card.Types and card.Types[entry] then | if card.Types and card.Types[entry] | ||
and (tribe == nil or (tribe and card.Tribes and tableContains(card.Tribes, tribe))) | |||
then | |||
table.insert(entryList, card) | table.insert(entryList, card) | ||
end | end | ||
Line 187: | 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 214: | Line 237: | ||
end) | end) | ||
return sortedTable | return sortedTable | ||
end | |||
function tableContains(table, value) | |||
for i = 1,#table do | |||
if (table[i] == value) then | |||
return true | |||
end | |||
end | |||
return false | |||
end | end | ||
Line 232: | Line 264: | ||
function _cardInfobox(card, params) | function _cardInfobox(card, params) | ||
local out = "{{infobox|category=Card" | local out = "{{infobox|category=Card" | ||
out = out .. "|name=" .. (params.name or _getName(card) or "") | out = out .. "|name=" .. (params.name or _getName(card) or card.Name or "<br>") | ||
out = out .. "|image=" .. (params.image or "") | out = out .. "|image=" .. (params.image or "") | ||
out = out .. "|width=" .. (params.width or "") | out = out .. "|width=" .. (params.width or "") | ||
Line 240: | Line 272: | ||
out = out .. "|hpType=scrap" | out = out .. "|hpType=scrap" | ||
end | end | ||
out = out .. "|health=" .. (params.health or card.Health or card.Scrap or "") | out = out .. "|health=" .. (params.health or card.Health or card.Scrap or "<br>") | ||
out = out .. "|attack=" .. (params.attack or card.Attack or "") | out = out .. "|attack=" .. (params.attack or card.Attack or "<br>") | ||
out = out .. "|counter=" .. (params.counter or card.Counter or "") | out = out .. "|counter=" .. (params.counter or card.Counter or "<br>") | ||
out = out .. "|other=<div style=\"text-align: center;\">" .. (params.other or card.Other or "") .. "</div>" | out = out .. "|other=<div style=\"text-align: center;\">" .. (params.other or card.Other or "<br>") .. "</div>" | ||
out = out .. "|description=" .. (params.description or _getDesc(card) or "") | out = out .. "|description=" .. (params.description or _getDesc(card) or card.Desc or "<br>") | ||
out = out .. "|desCol=" .. (params.desCol or "") | out = out .. "|desCol=" .. (params.desCol or "") | ||
if params.art then | |||
out = out .. "|art=" .. params.art | |||
else | |||
out = out .. "|art=" .. (card.Image or card.UniqueName or card.Name) .. ".png" | |||
end | |||
out = out .. "}}" | out = out .. "}}" | ||
return out | return out | ||
Line 252: | 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 | |||
--[[ | |||
Usage: {{#invoke:Cards|Itembox|<card>|<template_params>}} | |||
returns the itembox of the card. | |||
<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:Itembox | |||
Parameters without inputs are autofilled with fitting module data, to the best of its ability. | |||
]] | |||
function p.Itembox(frame) | |||
local card = frame.args[1] | |||
card = trim(card) | |||
return frame:preprocess(_itembox(all_cards[card], frame.args)) | |||
end | |||
function _itembox(card, params) | |||
local out = "{{itembox|category=Card" | |||
out = out .. "|name=" .. (params.name or _getName(card) or card.Name or "<br>") | |||
out = out .. "|image=" .. (params.image or "") | |||
out = out .. "|attack=" .. (params.attack or card.Attack or "<br>") | |||
out = out .. "|other=<div style=\"text-align: center;\">" .. (params.other or card.Other or "<br>") .. "</div>" | |||
out = out .. "|description=" .. (params.description or _getDesc(card) or card.Desc or "<br>") | |||
out = out .. "|desCol=" .. (params.desCol or "") | |||
if params.art then | |||
out = out .. "|art=" .. params.art | |||
else | |||
out = out .. "|art=" .. (card.Image or card.UniqueName or card.Name) .. ".png" | |||
end | |||
out = out .. "}}" | |||
return out | |||
end | end | ||
Line 275: | Line 367: | ||
out = out .. " • " | out = out .. " • " | ||
end | end | ||
out = out.. "[[" .. (card.Link or card.UniqueName) .. "|" .. card | out = out.. "<div style=\"display: inline-block;\">[[" .. (card.Link or card.UniqueName) .. "|" .. _getName(card) .. "]]</div>" | ||
end | end | ||
end | end |
edits