Module:Card

local p = {} local common = require( 'Module:Common' ) local data = mw.loadData( 'Module:Card/Data' )

function p.Data( frame ) return data[frame.args[1]][frame.args[2]] or "" end

-- Usage: function p.IconRC ( frame ) local codexId = frame.args[1] local charData = data[codexId] return frame:expandTemplate{ title = "Card/Icon/Rabbit Chat", args = { -- For Template:Card/Icon/Rabbit Chat image       = charData["filename"], zoom        = charData["zoom"], left        = charData["left"], top         = charData["top"], }} or "" end

-- Usage: function p.Icon ( frame ) local codexId = frame.args[1] local charData = data[codexId] return frame:expandTemplate{ title = "Card/Icon", args = { -- For Template:Card/Icon attribute   = charData["attribute"], rarity      = charData["rarity"], image       = charData["filename"], zoom        = charData["zoom"], left        = charData["left"], top         = charData["top"], cardname    = charData["cardname"], pagename    = charData["pagename"], }} or "" end

-- Usage: function p.Grid( frame ) local row = local entries = {} for id, charData in common.sortedPairs(data, --desctrue) do       entries[#entries+1] = string.format(row,            FilterDataAttributes(charData),            charData["filename"] or "",            charData["pagename"] or "",            charData["pagename"] or "",            charData["character"] or "",            charData["cardname"] or "",            charData["attribute"] or "",            charData["rarity"] or "",            charData["cardfeature"] or ""        ) end return table.concat(entries, "\n") end

-- Renders the Card list -- Usage: function p.List( frame ) local header = [=[{| class="article-table sortable" style="margin:7px auto auto 0px; border:1px solid #2cd0ff;" !style="white-space:nowrap; border-bottom:1px solid #2cd0ff !important; background-color:#2cd0ff; color:#fff;"| Rarity !style="white-space:nowrap; border-bottom:1px solid #2cd0ff !important; background-color:#2cd0ff; color:#fff;"| ID !style="width:50; border-bottom:1px solid #2cd0ff !important; background-color:#2cd0ff; color:#fff;"| Card !style="white-space:nowrap; border-bottom:1px solid #2cd0ff !important; background-color:#2cd0ff; color:#fff;"| Attribute !style="white-space:nowrap; border-top:1px solid #ff6344; border-bottom:1px solid #ff6344; background-color:#ff6344; color:#fff;"| Max Shout !style="white-space:nowrap; border-top:1px solid #3aba00; border-bottom:1px solid #3aba00; background-color:#3aba00; color:#fff;"| Max Beat !style="white-space:nowrap; border-top:1px solid #00a0ee; border-bottom:1px solid #00a0ee; background-color:#00a0ee; color:#fff;"| Max Melody ]=]   local row = [=[|- %s local entries = {} for id, charData in common.sortedPairs(data, --desctrue) do       entries[#entries+1] = string.format(row,            FilterDataAttributes(charData),            charData["rarity"] or "",			charData["id"] or "",			charData["id"] or "",			charData["pagename"] or "",			charData["attribute"] or "",			charData["max_shout"] or "",			charData["max_beat"] or "",			charData["max_melody"] or ""        ) end return frame:preprocess(header..table.concat(entries, "\n").."\n|}") end
 * data-sort-value="%s"
 * style="border-top: 1px #2cd0ff solid; border-bottom: 1px #2cd0ff solid; background-color:#fff;"| %s
 * style="border-top: 1px #2cd0ff solid; border-bottom: 1px #2cd0ff solid; background-color:#fff;"| %s
 * style="border-top: 1px #2cd0ff solid; border-bottom: 1px #2cd0ff solid; background-color:#fff;"| %s
 * style="border-top: 1px #2cd0ff solid; border-bottom: 1px #2cd0ff solid; background-color:#fff;"| %s
 * style="border-top: 1px #2cd0ff solid; border-bottom: 1px #2cd0ff solid; background-color:#fff;"| %s
 * style="border-top: 1px #2cd0ff solid; border-bottom: 1px #2cd0ff solid; background-color:#fff;"| %s]=]

-- Utility functions function FilterDataAttributes( charData ) return string.format(       'class="card-entry" data-rarity="%s" data-attribute="%s" data-id="%s" data-character="%s" data-cardfeature="%s" data-availability="%s" data-appealskill="%s"',        charData["rarity"] or "",        charData["attribute"] or "",        charData["id"] or "",        charData["character"] or "",        charData["cardfeature"] or "",        charData["availability"] or "",        charData["appealskill"] or ""    ) end

return p