Jump to content

Welcome to King Warz Charts Wiki! Please note that the site is still under construction as I work on creating past chart week pages, as well as templates and pages for artists, songs, and albums. Because of this, you may see a lot of red links throughout the site.

Module:AlbumCertification

From King Warz Charts

Documentation for this module may be created at Module:AlbumCertification/doc

local p = {}

function p.getCertification(frame)
    local certInput = mw.text.trim(frame.args['certification'] or '')
    local output = ''
    local categories = {}
    if certInput == '' then
        -- not certified yet (under 500 units); not an error
        output = 'Uncertified'
        table.insert(categories, '[[Category:Uncertified Albums]]')
    elseif certInput:lower() == 'gold' then
        output = '[[Gold]] ●'
        table.insert(categories, '[[Category:Gold Albums]]')
    elseif certInput:match('^%d+$') then
        local num = tonumber(certInput)
        if num >= 1 and num <= 9 then
            output = num .. 'x [[Platinum]] ▲'
            table.insert(categories, '[[Category:Platinum Albums]]')
        elseif num >= 10 then
            output = num .. 'x [[Diamond]] ⬥'
            table.insert(categories, '[[Category:Diamond Albums]]')
        else
            output = certInput
            table.insert(categories, '[[Category:Albums with Invalid Certifications]]')
        end
    else
        output = certInput
        table.insert(categories, '[[Category:Albums with Invalid Certifications]]')
    end
    return output .. table.concat(categories, '')
end

return p