1,291
edits
No edit summary |
(tribe-exclusive filter) |
||
Line 102: | Line 102: | ||
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 134: | Line 136: | ||
function p.testy() | function p.testy() | ||
return _table({"Pet", " | return _table({"Pet", "SnowdwellersNonPetCompanion"}, {"name", "desc", "challenge"}) | ||
end | end | ||
Line 166: | Line 168: | ||
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 219: | Line 230: | ||
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 258: | Line 278: | ||
out = out .. "}}" | out = out .. "}}" | ||
return out | return out | ||
end | end | ||
edits