« Module:Game shortened » : différence entre les versions

De Pikmin FR
m Trig Jegman moved page Module:GameShortened to Module:Game shortened without leaving a redirect
fr>Fxfxfx0
m Fxfxfx0 a déplacé la page Module:GameShortened vers Module:Game shortened sans laisser de redirection
Ligne 22 : Ligne 22 :
['SO'] = SO,
['SO'] = SO,
['SIDE ORDER'] = SO,
['SIDE ORDER'] = SO,
["TOUR DE L'ORDRE"] = SO,
['S'] = S,
['S'] = S,
['S1'] = S,
['S1'] = S,

Version du 18 septembre 2024 à 12:19

La documentation pour ce module peut être créée à Module:Game shortened/doc

local p = {}

-- Note in Lua calling p.getGame(game) is acceptable,
-- and `default` will be set to nil.
function p.getGame(arg, default)
	--Allows input to be case insensitive
	arg = string.upper(arg)

	local OE = "OE"
	local SO = "SO"
	local SR = "SR"
	local S = "S"
	local S2 = "S2"
	local S3 = "S3"
	
	--All names are in uppercase because of string.upper (for case insensitivity)
	local abbrev = {
		['OE'] = OE,
		['OCTO EXPANSION'] = OE,
		['SR'] = SR,
		['SALMON RUN'] = SR,
		['SO'] = SO,
		['SIDE ORDER'] = SO,
		["TOUR DE L'ORDRE"] = SO,
		['S'] = S,
		['S1'] = S,
		['SPLATOON'] = S,
		['SPLATOON 1'] = S,
		['S2'] = S2,
		['SPLATOON 2'] = S2,
		['S3'] = S3,
		['SPLATOON 3'] = S3,
	}

	-- return the abbreviation from the game arg.
	-- If arg is nil then a default will be used.
	return abbrev[arg] or default or "S"
end

-- main to extract arg from frame
function p.main(frame)
	local args = frame:getParent().args
	local arg = args['game'] or args[1]
	local default = args['default'] or args[2] -- or nil
	return p.getGame(arg, default)
end

return p