Advertisement

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

local p = {}
local data = require("Module:Datatable")
local cosData = require("Module:Datatable/Cosmetics")
local utils = require("Module:Utils")
local str = require("Module:Strings")
local killersM = require("Module:Killers")
local survM = require("Module:Survivors")
local frame = mw.getCurrentFrame()

local strings = {
	notFound = "Not Found!",
	cosmetics = "Cosmetics",
	character = "Character",
	gender = "Gender",
	name = "Name",
	nationality = "Nationality",
	actor = "Voice Actor",
}

function p.resolveCosCharBox(args)
	name = utils.resolveParameter(args)
	cosChar = getCosCharByName(name)
	local character, portrait
	if not cosChar then return strings.cosmetics .. space .. strings.notFound .. colon .. space .. name end
	if cosChar.killer then
		character = killersM.getKillerById(cosChar.killer)
	else
		character = survM.getSurvivorById(cosChar.survivor)
	end
	
	if not character then return strings.character .. space .. strings.notFound end
	portrait = (cosChar.killer and resolveKillerPortraitImageFileName(character, cosChar.name)) or resolveSurvPortraitImageFileName(character, cosChar.name)
	
	result = '{| class = "infoboxtable"' .. nl ..
	ntl ..' class = "infoboxTitle" | ' .. nl ..
	'! class = "center bold" colspan = 2 | ' .. cstr.the .. space .. cosChar.name .. nl .. ntl .. nl
	if utils.isValidFileName(portrait) then
		result = result ..'! class = "center" colspan = 2 | ' .. link(cstr.file .. portrait .. '.png|150px') .. nl .. ntl .. nl
	end
	if cosChar.wholeName ~= nil then
		result = result .. '| class = "titleColumn" | ' .. strings.name .. ' || class = "valueColumn" | ' .. cosChar.wholeName .. nl .. ntl .. nl
	end
	result = result .. '| class = "titleColumn" | ' .. strings.gender .. ' || class = "valueColumn" | ' .. utils.resolveGender(cosChar.gender) .. nl
	if cosChar.nationality ~= nil then
		result = result .. ntl .. nl .. '| class = "titleColumn" | ' .. strings.nationality .. ' || class = "valueColumn" | ' .. cosChar.nationality .. nl
	end
	if cosChar.actor ~= nil then
		result = result .. ntl .. nl .. '| class = "titleColumn" | ' .. strings.actor .. ' || class = "valueColumn" | ' .. cosChar.actor .. nl
	end
	result = result .. '|}'
	
	mw.log(result)
	return result
end

function getCosCharByName(name)
	for _, outfit in ipairs(cosData.cosChars) do
		if cstr.the .. space .. outfit.name == name then
			return outfit
		end
	end
	for _, outfit in ipairs(cosData.cosChars) do
		if outfit.name == name then
			return outfit
		end
	end
end

return p