FANDOM


 -- Written by Wildoneshelper
 -- with some meddling (and hopefully not muddling) by catinthedark
 -- added background color support on [[Template:Hexagon Levels]] by DoCheonGong
 -- information updated by a Mulligan thru an external extraction program
 -- Watch out for superhard thunderstorm shards!
 
 -- <nowiki>
local p = {}
 
local _lookupTable = 'Module:Hexagon levels CCSS/List'
 
local hexagonTag = 'Hexagon'
local shardTag = 'Super Hard'
 
local function _lookupHexagonStatus( levelName )
	if levelName and not (levelName == '') then
    	-- Load data corresponding to level number and world
    	local level = levelName:match('^Level (%d+) %(CCSS%)')
    	if level then 
            local data = mw.loadData( _lookupTable )
            -- Get hexagon status for the level ('Hexagon, 'Super Hard', or '')
            return data[tonumber(level)]
        end
    end
    return false
end
 
--Category synchronization
function p.hexagon()
    local hexstatus = _lookupHexagonStatus(mw.title.getCurrentTitle().text)
    local cat = ''
    if hexstatus then
        if hexstatus == hexagonTag then
        	cat = "[[Category:Hexagon levels (CCSS)]]"
        elseif hexstatus == shardTag then
    	    cat = "[[Category:Super hard levels (CCSS)]][[Category:Hexagon levels (CCSS)]]"
        end
    end
    return cat -- hehe, the caller will be happy to have a nice cat :P
end
 
--Function to change the color for level links as a P CCSS template
--Links become pink for hexagons, darkblue for superhards.
function p.hexagoncolor(frame)
	local name = frame.args[1]
	local hcolor = ''
    if _lookupHexagonStatus(name) == hexagonTag then
    	hcolor = "violet"
    elseif _lookupHexagonStatus(name) == shardTag then
    	hcolor = "DarkBlue"
	end
	return hcolor
end
 
--For the hexagon levels template, the corresponding level
--will be colored if it is a hexagon or superhard.
function p.hexagonbgcolor(frame)
	local name = frame.args[1]
	local hbgcolor = '000000'
    if _lookupHexagonStatus(name) == hexagonTag then
    	hbgcolor = 'b000ff'
    elseif _lookupHexagonStatus(name) == shardTag then
    	hbgcolor = '000080'
	end
	return hbgcolor
end
 
--Function to extract whether a level is hexagonal.
--Returns N for normal levels, H for hexagons, S for superhards.
function p.hvalue(frame)
	local name = frame.args[1]
	local hv = 'N'
    if _lookupHexagonStatus(name) == hexagonTag then
    	hv = 'H'
    elseif _lookupHexagonStatus(name) == shardTag then
    	hv = 'S'
	end
	return hv
end
 
-- Infobox notice
function p.hexagoninfobox(frame)
	local name = frame.args[1]
	local icon = ''
    if _lookupHexagonStatus(name) == hexagonTag then
    	icon = "[[File:Hexagon icon.png|30px|link=Category:Hexagon levels (CCSS)]]"
    elseif _lookupHexagonStatus(name) == shardTag then
    	icon = "[[File:Super Hard Level icon.gif|30px|link=Super Hard level]]"
	end
	return icon
end
 
-- Left for compatibility? Are these in use already?
-- if not, use p.hexagon() and p.hexagoncolor() for both hex and superhard
 
function p.shard()
    return p.hexagon()
end
 
function p.shardcolor(frame)
	return p.hexagoncolor(frame)
end
 
return p
-- </nowiki>
Community content is available under CC-BY-SA unless otherwise noted.