FANDOM


local cardset = {}
----------------------------
-- Libraries of functions --
----------------------------
-- stands for High Frequency
local HF = require('Module:HF')
-- Parses invocation and template parameters, trims whitespace, and removes blanks.
local getArgs = require('Dev:Arguments').getArgs
 
-----------------------
-- Libraries of data --
-----------------------
local data = mw.loadData( 'Module:Card/Set/data' )
 
----------------------------------------------------------
-- Public functions (called from a Template or article) --
----------------------------------------------------------
function cardset.CardTableSet_header (frame)
    -- Parses template parameters, trims whitespace, and removes blanks.
    local t = getArgs(frame, { trim = true, removeBlanks = true, parentOnly = true })
    return _CardTableSet_header(t[1], t['header'])..( t['lang'] and (HF.Category('Card table set header transclusions using lang')) or '' )
end
 
function cardset.CardTableSet (frame)
    -- Parses template parameters, trims whitespace, and removes blanks.
    local t = getArgs(frame, { trim = true, removeBlanks = true, parentOnly = true })
    return _CardTableSet_header(t[1], t[2], t[3])
end
 
---------------------------------------------------------
-- Internal functions (used in this and other Modules) --
---------------------------------------------------------
function _detection (set_value)
    if set_value:match('{{Card table set/header%|[%w-]+}}') then
        local sets_table = _parse_card_table_set(set_value)
    elseif set_value:match(';') then
        --local sets_table = _parse_semicolon_notation(set_value)
    end
    return sets_table
end
 
-- Create an envelope for existing tables
function _cardset_envelope (inv_args)
    local envelope = mw.html.create('div')
    :addClass('mw-collapsible'):addClass('mw-collapsed')
    :attr('data-expandtext','Show'):attr('data-collapsetext','Hide')
    :wikitext(inv_args[1]):allDone()
    return tostring(envelope)
end
 
function _parse_card_table_set (set_value)
    local CT = {}
    local language = assert(set_value:match('{{Card table set/header%|([%w-]+)}}'), 'No language code given in Card table set/header')
 
    for set_number, name, rarity in set_value:match('{{Card table set%s*|%s*([%w-]+)%s*|%s*([^|]+)%s*|*s([%w%s]+)*s}}') do 
        table.insert( CT, { set_number, set_name, rarity, language } ) 
    end
    return CT
end
 
-- If card set content passed is only data, build a table around it 
function _cardset_table ( language, region, header )
    local WT = mw.html.create('table')
        :addClass('wikitable'):addClass('sortable')
        :css('width','100%')
        :tag('caption'):wikitext():done()
        :tag('tr')
        :tag('th'):wikitext()
end
 
-- Build table rows for _cardset_table
function _cardset_row ( release_date, set_number, set_name, native_name, rarity)
end
 
function _CardTableSet ( set_number, set_name, rarity )
    local r = data.r
    local r_full = data.r_full
    -- Template:Card_table_set?action=raw
    local cts_number = set_number:match('%[%[:?(.-)[|%]]') or mw.text.trim(set_number)
    local cts_set_name = set_name:match('%[%[:?(.-)[|%]]') or mw.text.trim(set_name)
    local cts_rarity = r_full[r[rarity:lower()]]
    --if cts_set_ln == 'en' and cts_region ~= 'Asian-English' then cts_region = end
-->{{ #ifeq: {{ #var: $cts-set_ln }} | en | {{ #ifeq: {{ #var: $cts-region }} | Asian-English   || {{ #vardefine: $cts-region | {{ #switch: {{ #sub: {{ #sub: {{ #explode: {{ #var: $cts-number }} | - |  1 }} | 0 | -3 }} || 2 }} | EN = English (EN) | E  = English (E) | A  = English (A) |    = English (NA)  | #default = {{ #var: $cts-region }}  }} }} }} }}<!--
 
end
 
function _CardTableSet_header (value, header)
    local set_ln = data.set_ln
    local set_lang = data.set_lang
    local region = data.region
    local lang = data.lang
    local cts_set_ln = set_ln[value] or value
    local cts_set_lang = set_lang[cts_set_ln] or lang[value]
    local cts_region = region[value] or 'Worldwide English'
    local cts_short_region = (cts_region == 'Worldwide English') and 'English' or cts_region
    return '<table class="wikitable sortable card-list cts">'..
           '<caption class="mobile-show">'..cts_short_region..'</caption>'..
           (header and ('<caption>'..header..'</caption>') or '')..
           '<tr>'..
           '<th style="width: 4.5em;">Release</th>'..
           '<th style="width: 6em;">Number</th>'..
           '<th>Set</th>'..
           ((cts_set_ln ~= 'en') and ('<th>'..cts_set_lang..' name</th>') or '')..
           '<th style="min-width: 7em; max-width: 12em;">Rarity</th>'..
           '</tr>'
end
 
-------------------------------------------------
-- Output (send it back to whatever called it) --
-------------------------------------------------
return cardset

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.