FANDOM


local maintenance = {}
----------------------------
-- 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
-- Gives the name of the current page. It's expensive, so we only do it once.
-- The _G then makes it global, available to all page functions.
_G.page_title = mw.title.getCurrentTitle().text
_G.pagename = HF.NP(page_title)
_G.t = getArgs(frame, { trim = true, removeBlanks = true })
_G.non_game = (t['type'] and (t['type']:lower() == 'illustration card' or t['type']:lower() == 'strategy card' or t['type']:lower() == 'tip card' or t['type']:lower() == 'faq card' or t['type']:lower() == 'non-game card' or t['type']:lower() == 'character card'))
_G.ocg = (t['jp_sets'] or t['ja_sets'] or t['kr_sets'] or t['ko_sets'] or t['ae_sets'] or t['tc_sets'])
_G.tcg = (t['en_sets'] or t['na_sets'] or t['eu_sets'] or t['au_sets'] or t['fr_sets'] or t['fc_sets'] or t['de_sets'] or t['it_sets'] or  t['pt_sets'] or t['sp_sets'])
--------------------
-- Operation data --
--------------------
 
----------------------------------------------------------
-- Public functions (called from a Template or article) --
----------------------------------------------------------
 
function maintenance.categories (frame)
    local page_title = mw.title.getCurrentTitle().text
    local pagename = HF.NP(page_title)
    local t = getArgs(frame, { trim = true, removeBlanks = true })
    local hash = {}
    local o = {}
    local non_game = (t['type'] and (t['type']:lower() == 'illustration card' or t['type']:lower() == 'strategy card' or t['type']:lower() == 'tip card' or t['type']:lower() == 'faq card' or t['type']:lower() == 'non-game card' or t['type']:lower() == 'character card')) and true
    local ocg = (t['jp_sets'] or t['ja_sets'] or t['kr_sets'] or t['ko_sets'] or t['ae_sets'] or t['tc_sets']) and true
    local tcg = (t['en_sets'] or t['na_sets'] or t['eu_sets'] or t['au_sets'] or t['fr_sets'] or t['fc_sets'] or t['de_sets'] or t['it_sets'] or  t['pt_sets'] or t['sp_sets']) and true
 
 
    --This is a totally unconventional way of doing this, and amazingly it works.
    local cats = { 
        (t['name']) and HF.Category('Card table parameter tracking (name)'),
        (t['name'] and t['name'] == pagename) and HF.Category('Pages with an unnecessary name parameter'),
        (t['name'] and t['name']:match('<sup>')) and HF.Category('Pages with superscript in name parameter'),
        (t['cardgame']) and HF.Category('Card table parameter tracking (cardgame)'),
        (t['cardgame'] and t['cardgame'] == pagename) and HF.Category('Pages with an unnecessary cardgame parameter'),
        (t['image'] and t['image']:match('-VG.')) and HF.Category('((CardTable2)) transclusions using video game images'),
        (t['image'] and t['image']:match('VG-')) and HF.Category('((CardTable2)) transclusions using video game images'),
        (t['image'] and t['image']:match('VG-') and (not t['image']:match('-VG-'))) and HF.Category('((CardTable2)) transclusions needing renamed images'),
        (t['image'] and t['image']:match('-OW.')) and HF.Category('((CardTable2)) transclusions using OW images'),
        (t['image'] and t['image']:match('-Sample')) and HF.Category('((CardTable2)) transclusions using sample images'),
        (t['image'] and t['image']:match('-Back')) and HF.Category('((CardTable2)) transclusions using card backings'),
        (not t['image'] and not t['image2']) and HF.Category('Cards that need an image'),  
        (t['image2']) and HF.Category('CardTable2 parameter tracking (image2)'),
        (not mw.title.new( t['cardgame'] or pagename, 'Card_Gallery' ).exists) and HF.Category('Cards that need a Card Gallery'),
 
        ((t['fr_sets'] or t['fc_sets']) and (not t['fr_name']) and HF.Category('Cards with a French release needing a French name')),
        ((t['fr_sets'] or t['fc_sets']) and (not t['fr_lore']) and HF.Category('Cards with a French release needing a French lore')),
        (t['de_sets'] and (not t['de_name']) and HF.Category('Cards with a German release needing a German name')),
        (t['de_sets'] and (not t['de_lore']) and HF.Category('Cards with a German release needing a German lore')),
        (t['it_sets'] and (not t['it_name']) and HF.Category('Cards with a Italian release needing a Italian name')),
        (t['it_sets'] and (not t['it_lore']) and HF.Category('Cards with a Italian release needing a Italian lore')),
        ((t['jp_sets'] or t['ja_sets']) and (not t['ja_name']) and HF.Category('Cards with a Japanese release needing a Japanese name')),
        ((t['jp_sets'] or t['ja_sets']) and (not t['ja_lore']) and HF.Category('Cards with a Japanese release needing a Japanese lore')),
        ((t['kr_sets'] or t['ko_sets']) and (not t['ko_name']) and HF.Category('Cards with a Korean release needing a Korean name')),
        ((t['kr_sets'] or t['ko_sets']) and (not t['ko_lore']) and HF.Category('Cards with a Korean release needing a Korean lore')),
        (t['pt_sets'] and (not t['pt_name']) and HF.Category('Cards with a Portuguese release needing a Portuguese name')),
        (t['pt_sets'] and (not t['pt_lore']) and HF.Category('Cards with a Portuguese release needing a Portuguese lore')),
        (t['sp_sets'] and (not t['es_name']) and HF.Category('Cards with a Spanish release needing a Spanish name')),
        (t['sp_sets'] and (not t['es_lore']) and HF.Category('Cards with a Spanish release needing a Spanish lore')),
        (t['tc_sets'] and (not t['zh_name']) and HF.Category('Cards with a Chinese release needing a Chinese name')),
        (t['tc_sets'] and (not t['zh_lore']) and HF.Category('Cards with a Chinese release needing a Chinese lore')),
        }
 
    -- WHY DON'T YOU WORK!?!?!
    if (t['type'] and (t['type']:lower() == 'illustration card' or t['type']:lower() == 'strategy card' or t['type']:lower() == 'tip card' or t['type']:lower() == 'faq card' or t['type']:lower() == 'non-game card' or t['type']:lower() == 'character card')) then
        table.insert(o, HF.Category('Unusable cards'))
        if t['type'] == 'Illustration Card' then
            table.insert(o, HF.Category('Illustration Cards'))
        elseif t['type'] == 'Strategy Card' then
            table.insert(o, HF.Category('Strategy Cards'))
        end
    else
        if (t['type2'] == 'Token') then
            table.insert(o, HF.Category('Tokens') )
        elseif (t['type'] == 'Counter') then 
            table.insert(o, HF.Category('Counters') )
        else 
            table.insert(o, HF.Category('Duel Monsters cards') )
        end
        if (t['en_sets'] or t['na_sets'] or t['eu_sets'] or t['au_sets'] or t['fr_sets'] or t['fc_sets'] or t['de_sets'] or t['it_sets'] or  t['pt_sets'] or t['sp_sets']) then table.insert(o, HF.Category('TCG cards')) end
        if (t['jp_sets'] or t['ja_sets'] or t['kr_sets'] or t['ko_sets'] or t['ae_sets'] or t['tc_sets']) then table.insert(o, HF.Category('OCG cards')) end
    end
 
 
    for _,v in ipairs(cats) do
       if v and (not hash[v] and v ~= '') then
           table.insert( o, v )
           hash[v] = true
       end
    end
    return table.concat( o )
end
 
function maintenance.semantic (frame)
    local t = getArgs(frame, { trim = true, removeBlanks = true })
    local non_game = (t['type'] and (t['type']:lower() == 'illustration card' or t['type']:lower() == 'strategy card' or t['type']:lower() == 'tip card' or t['type']:lower() == 'faq card' or t['type']:lower() == 'non-game card' or t['type']:lower() == 'character card')) and true
    local ocg = (t['jp_sets'] or t['ja_sets'] or t['kr_sets'] or t['ko_sets'] or t['ae_sets'] or t['tc_sets']) and true
    local tcg = (t['en_sets'] or t['na_sets'] or t['eu_sets'] or t['au_sets'] or t['fr_sets'] or t['fc_sets'] or t['de_sets'] or t['it_sets'] or  t['pt_sets'] or t['sp_sets']) and true
    local hash = {}
    local o = {}
    local props = {
        (t['sq_name']) and 'Albanian name='..t['sq_name'],
        (t['ar_name']) and 'Arabic name='..t['ar_name'],
        (t['bn_name']) and 'Bengali name='..t['bn_name'],
        (t['bg_name']) and 'Bulgarian name='..t['bg_name'],
        (t['ca_name']) and 'Catalan name='..t['ca_name'],
        (t['hr_name']) and 'Croatian name='..t['hr_name'],
        (t['cs_name']) and 'Czech name='..t['cs_name'],
        (t['da_name']) and 'Danish name='..t['da_name'],
        (t['nl_name']) and 'Dutch name='..t['nl_name'],
        (t['et_name']) and 'Estonian name='..t['et_name'],
        (t['fil_name']) and 'Filipino name='..t['fil_name'],
        (t['fi_name']) and 'Finnish name='..t['fi_name'],
        (t['el_name']) and 'Greek name='..t['el_name'],
        (t['haw_name']) and 'Hawaiian name='..t['haw_name'],
        (t['he_name']) and 'Hebrew name='..t['he_name'],
        (t['hi_name']) and 'Hindi name='..t['hi_name'],
        (t['hu_name']) and 'Hungarian name='..t['hu_name'],
        (t['id_name']) and 'Indonesian name='..t['id_name'],
        (t['ga_name']) and 'Irish name='..t['ga_name'],
        (t['lv_name']) and 'Latvian name='..t['lv_name'],
        (t['lt_name']) and 'Lithuanian name='..t['lt_name'],
        (t['no_name']) and 'Norwegian name='..t['no_name'],
        -- [[wikipedia:Norwegian language]]; the Norwegian macrolanguage
        (t['nb_name']) and 'Norwegian name='..t['nb_name'],
        -- [[wikipedia:Bokmål]]
        (t['nn_name']) and 'Norwegian name='..t['nn_name'],
        -- [[wikipedia:Nynorsk]]
        (t['fa_name']) and 'Persian name='..t['fa_name'],
        (t['pl_name']) and 'Polish name='..t['pl_name'],
        (t['ro_name']) and 'Romanian name='..t['ro_name'],
        (t['ru_name']) and 'Russian name='..t['ru_name'],
        (t['sr_name']) and 'Serbian name='..t['sr_name'],
        (t['sk_name']) and 'Slovak name='..t['sk_name'],
        (t['sl_name']) and 'Slovene name='..t['sl_name'],
        (t['sv_name']) and 'Swedish name='..t['sv_name'],
        (t['tl_name']) and 'Tagalog name='..t['tl_name'],
        (t['th_name']) and 'Thai name='..t['th_name'],
        (t['tr_name']) and 'Turkish name='..t['tr_name'],
        (t['vi_name']) and 'Vietnamese name='..t['vi_name'],
        (t['cy_name']) and 'Welsh name='..t['cy_name'],
        (t['sq_lore']) and 'Albanian lore='..t['sq_lore'],
        (t['ar_lore']) and 'Arabic lore='..t['ar_lore'],
        (t['bn_lore']) and 'Bengali lore='..t['bn_lore'],
        (t['bg_lore']) and 'Bulgarian lore='..t['bg_lore'],
        (t['ca_lore']) and 'Catalan lore='..t['ca_lore'],
        (t['hr_lore']) and 'Croatian lore='..t['hr_lore'],
        (t['cs_lore']) and 'Czech lore='..t['cs_lore'],
        (t['da_lore']) and 'Danish lore='..t['da_lore'],
        (t['nl_lore']) and 'Dutch lore='..t['nl_lore'],
        (t['et_lore']) and 'Estonian lore='..t['et_lore'],
        (t['fil_lore']) and 'Filipino lore='..t['fil_lore'],
        (t['fi_lore']) and 'Finnish lore='..t['fi_lore'],
        (t['el_lore']) and 'Greek lore='..t['el_lore'],
        (t['haw_lore']) and 'Hawaiian lore='..t['haw_lore'],
        (t['he_lore']) and 'Hebrew lore='..t['he_lore'],
        (t['hi_lore']) and 'Hindi lore='..t['hi_lore'],
        (t['hu_lore']) and 'Hungarian lore='..t['hu_lore'],
        (t['id_lore']) and 'Indonesian lore='..t['id_lore'],
        (t['ga_lore']) and 'Irish lore='..t['ga_lore'],
        (t['lv_lore']) and 'Latvian lore='..t['lv_lore'],
        (t['lt_lore']) and 'Lithuanian lore='..t['lt_lore'],
        (t['no_lore']) and 'Norwegian lore='..t['no_lore'],
        (t['nb_lore']) and 'Norwegian lore='..t['nb_lore'],
        (t['nn_lore']) and 'Norwegian lore='..t['nn_lore'],
        (t['fa_lore']) and 'Persian lore='..t['fa_lore'],
        (t['pl_lore']) and 'Polish lore='..t['pl_lore'],
        (t['ro_lore']) and 'Romanian lore='..t['ro_lore'],
        (t['ru_lore']) and 'Russian lore='..t['ru_lore'],
        (t['sr_lore']) and 'Serbian lore='..t['sr_lore'],
        (t['sk_lore']) and 'Slovak lore='..t['sk_lore'],
        (t['sl_lore']) and 'Slovene lore='..t['sl_lore'],
        (t['sv_lore']) and 'Swedish lore='..t['sv_lore'],
        (t['tl_lore']) and 'Tagalog lore='..t['tl_lore'],
        (t['th_lore']) and 'Thai lore='..t['th_lore'],
        (t['tr_lore']) and 'Turkish lore='..t['tr_lore'],
        (t['vi_lore']) and 'Vietnamese lore='..t['vi_lore'],
        (t['cy_lore']) and 'Welsh lore='..t['cy_lore'],
    }
 
    mw.smw.set{ 'Page type=Card page'}
 
    if not non_game then
        if tcg and ocg then
            mw.smw.set{'Medium=TCG', 'Medium=OCG'}
        elseif tcg then
            mw.smw.set{'Medium=TCG', 'Medium=TCG-only'}
        elseif ocg then
            mw.smw.set{'Medium=OCG', 'Medium=OCG-only'}
        end
    end
 
    for _,v in ipairs(props) do
       if v and (not hash[v] and v ~= '') then
           table.insert( o, v )
           hash[v] = true
       end
    end
    --DEBUG
    return table.concat(o,'·')
    --mw.smw.set( o )
    --return
end
 
--------------------------------------------------------
-- Internal functions (used in this and other Modules --
--------------------------------------------------------
 
return maintenance

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.