FANDOM


-- <pre>
-- This will likely be expanded when other infoboxes are converted to Lua
-- For now, it will just be a categories handler
 
local p = {}
 
local onmain = require('Module:Mainonly').on_main
local yesno = require('Module:Yesno')
local empty = require('Module:Paramtest').is_empty
 
local composers = {
	['mod ian'] = '[[Category:Music composed by Mod Ian]]',
	['mod grace'] = '[[Category:Music composed by Mod Grace]]',
	['mod bond'] = '[[Category:Music composed by Mod Bond]]',
	['mod lord'] = '[[Category:Music composed by Mod Lord]]',
	['andrew l'] = '[[Category:Music composed by Andrew L]]',
	['mod adam r'] = '[[Category:Music composed by Mod Adam R]]',
	['michael m'] = '[[Category:Music composed by Michael M]]',
	['iain h'] = '[[Category:Music composed by Iain H]]',
	['chris j'] = '[[Category:Music composed by Chris J]]',
	['mod dan a'] = '[[Category:Music composed by Mod Dan A]]',
	['james h'] = '[[Category:Music composed by James H]]',
	['sam j'] = '[[Category:Music composed by Sam J]]',
	['mod ash'] = '[[Category:Music composed by Mod Ash]]',
	['abbie d'] = '[[Category:Music composed by Abbie D]]',
	['mod slippers'] = '[[Category:Music composed by Mod Slippers]]',
	['helen r'] = '[[Category:Music composed by Helen R]]',
	['linda h'] = '[[Category:Music composed by Linda H]]',
	['mod surma'] = '[[Category:Music composed by Mod Surma]]'
}
 
function p.cats(frame)
	if not onmain() then
		return ''
	end
	local args = frame:getParent().args
	return p.categories {
			number = args.number,
			file = args.file,
			release = args.release,
			update = args.update,
			members = args.members,
			location = args.location,
			hint = args.hint,
			vocals = args.vocals,
			instruments = args.instruments,
			duration = args.duration,
			composer = args.composer,
			map = args.map
	}
end
 
function p.categories(...)
	local args = ...
	local ctgy = '[[Category:Music tracks]]'
	if yesno(args.vocals) then
		ctgy = ctgy..'[[Category:Music tracks with vocals]]'
	end
	if empty(args.number) then
		ctgy = ctgy..'[[Category:Missing track number]]'
	end
	if empty(args.file) then
		ctgy = ctgy..'[[Category:Needs audio added]]'
	end
	if empty(args.release) then
		ctgy = ctgy..'[[Category:Needs release date]]'
	end
	if empty(args.update) then
		ctgy = ctgy..'[[Category:Needs update added]]'
	end
	if empty(args.members) then
		ctgy = ctgy..'[[Category:Needs members status]]'
	end
	if string.lower(args.members) == 'yes' then
		ctgy = ctgy..'[[Category:Members-only music tracks]]'
	end
	if string.lower(args.members) == 'no' then
		ctgy = ctgy..'[[Category:Free-to-play music tracks]]'
	end
	if empty(args.location) then
	    ctgy = ctgy..'[[Category:Missing track location]]'
	end
	if empty(args.hint) then
		ctgy = ctgy..'[[Category:Missing unlock hint]]'
	end
	if empty(args.instruments) then
		ctgy = ctgy..'[[Category:Needs instruments]]'
	end
	if empty(args.duration) then
		ctgy = ctgy..'[[Category:Needs track duration added]]'
	end
	if empty(args.composer) then
		ctgy = ctgy..'[[Category:Needs composer added]]'
	else
		local complist = string.lower(args.composer)
		local compcount = 0
		for name, cat in pairs(composers) do
			if complist:find(name) then
				ctgy = ctgy..cat
				compcount = compcount + 1
			end
		end
		if compcount > 1 then
			ctgy = ctgy..'[[Category:Tracks with multiple composers]]'
		end
	end
	return ctgy
end
 
return p