Megami Tensei Wiki
Advertisement

A documentação para este módulo pode ser criada em Módulo:Gamebox/doc

--<pre>
local getArgs = require('Module:Arguments').getArgs
local getGames = require('Module:Gamedata')
 
local p = {}
 
local function makeInvokeFunction(funcName)
	-- makes a function that can be returned from #invoke, using
	-- [[Module:Arguments]].
	return function (frame)
		local args = getArgs(frame, {parentOnly = true})
		return p[funcName](args)
	end
end
 
local stylet = '\n|-\n|style="font-size:100%; text-align:center;background:#222;" colspan=2|'
 
local function cate(catename,sort)
	if not mw.title.getCurrentTitle():inNamespace('') then 
		return ''
	end
	if sort then sort = '|' .. sort else sort = '' end
	return '[[Category:' .. catename  .. sort .. ']]'
end

local t = {
	['image']={'image'},
	['image_width']={'image_width',default='240px'},
	['image_bg']={'image_bg'},
	['japan']={'japan'},
	['romaji']={'romaji'},
	['Desenvolvedor']={'developer'},
	['Publicadora']={'publisher'},
	['Genêro']={'genre'},
	['Plataforma']={'platform(s)','platform'},
	['Japão']={'release-date-japan','releasej'},
	['os Estados Unidos']={'release-date-north-america','releasena'},
	['Europa'] ={'release-date-europe','releaseeu'},
	['Austrália']={'release-date-australasia','releaseau'},
	['cname']={'name',default=mw.title.getCurrentTitle().text}, -- Character's name
	['Também conhecido como']={'aka'},
	['Nome Japonês']={'japan','kana'},
	['Romaji']={'romaji'},
	['rpname']={'RPname','rpname',h='<span style="white-space:nowrap;border-bottom:1px dotted black; cursor:help;" title="The localized English name of Revelations: Persona, the original English release of the game."><i>Revelations</i> Name</span>'},
	['Primeira Aparição']={'first appearance','first'},
	['Afiliação']={'affiliation'},
	['Alinhamento']={'alignment'},
	['Equipe']={'team'}, -- Strange Journey
	['Ocupação']={'job','occupation'},
	['Rank']={'rank'}, -- Strange Journey
	['Embarcação']={'ship'}, -- Strange Journey
	['País']={'country'}, -- Strange Journey
	['Razão']={'reason'}, -- Nocturne
	['Patrocinador Demoníaco']={'demonic sponsor','sponsor'}, -- Nocturne
	['Origem']={'origin'},
	['Arma']={'weapon'},
	['Parceiro Demônio']={'demonpartner'}, -- Devil Child
	['Tribo']={'tribe'}, -- DDSaga
	['Tipo Arma de Fogo']={'gun'},
	['Atma Avatar']={'avatar'}, -- DDSaga Atma Avatar
	['Atma Brand']={'brand'}, -- DDSaga Atma brand
	['Brand Location']={'location'}, -- DDSaga Atma brand location
	['Data de Nascimento']={'birthday','dob'},
	['Idade']={'age'},
	['Zodíaco']={'zodiac'},
	['Altura']={'height'},
	['Perso']={'weight'},
	['Cor COMP']={'comp'}, -- Devil Survivor 1 character's COMP color
	['Cor Celular']={'cell'}, -- Devil Survivor 2 character's cel phone color
	['Residência']={'home'},
	['Demônio Aliado']={'allieddemon'}, -- General-purposed, primarily for Shin Megami Tensei IV Final
	['Fate Demon']={'fatedemon'}, -- Demon fusions unlocked by raising Devil Survivor 2 character's Fate rank
	['Demônio Anime']={'animedemon'}, -- Allied demons summoned in Devil Survivor 2 anime
	['Tipo Sanguíneo']={'blood','blood type'},
	['Arma Corpo a Corpo']={'melee'},
	['Arma à Distância']={'ranged'},
	['Arcana']={'arcana'}, -- Persona series
	['Arcana2']={'arcana2',h='<abbr title="O arcana com o qual geralmente tem uma ' .. "'Ótima'" .. ' afinidade com o personagem, além do Arcana principal.">Arcana Secundário</abbr>'}, -- Persona 1 and 2
	['Persona']={'persona'}, -- Character's signature Persona(s)
	['Classe']={'class'}, -- SMTxFE
	['Parceiro Mirage']={'miragepartner'}, -- SMTxFE
	['Tema']={'theme','song'}, -- Character's theme music 
	['Gosta']={'likes'},
	['Desgosta']={'dislikes'},
	['Nacionalidade']={'nationality','nation'},
	['Etinia']={'ethnicity','ethnic'},
	['VA Japanonês']={'japaneseva','Japanese VA'},
	['VA Inglês']={'englishva','English VA'},
}

local game_stat_order1 = {
	'Desenvolvedor',
	'Publicadora',
	'Genêro',
	'Plataforma',
}

local game_stat_order2 = {
	'Japão',
	'os Estados Unidos',
	'Europa',
	'Austrália',
}

local char_stat_order = {
	'Também conhecido como',
	'Nome Japonês',
	'Romaji',
	'rpname',
	'Primeira Aparição',
	'Nacionalidade',
	'Etinia',
	'Afiliação',
	'Alinhamento',
	'Equipe',
	'Ocupação',
	'Rank',
	'Embarcação',
	'País',
	'Razão',
	'Patrocinador Demoníaco',
	'Origem',
	'Arma',
	'Parceiro Demônio',
	'Tribo',
	'Tipo Arma de Fogo',
	'Atma Avatar',
	'Atma Brand',
	'Brand Location',
	'Data de Nascimento',
	'Idade',
	'Zodíaco',
	'Altura',
	'Peso',
	'Cor COMP',
	'Cor Celular',
	'Residência',
	'Demônio Aliado',
	'Fate Demon',
	'Demônio Anime',
	'Tipo Sanguíneo',
	'Arma Corpo a Corpo',
	'Arma à Distância',
	'Arcana',
	'Arcana2',
	'Persona',
	'Classe',
	'Parceiro Mirage',
	'Tema',
	'Gosta',
	'Desgosta',
	'VA Japanonês',
	'VA Inglês',
}
	
local function get_prop(args)
	local prop = {}
	for k, v in pairs(t) do
		for _, name in ipairs(v) do
			if args[name] then
				prop[k] = args[name]
				break
			end
		end
		prop[k] = prop[k] or v.default
	end
	return prop
end
 
p.game = makeInvokeFunction('_game')
 
function p._game(args)
	local prop = get_prop(args)
	local game = args[1] or args.class or args.game or args.Game or ''
	local gameg -- Game general style
	if getGames.games[game].fallback then
		gameg = getGames.games[game].fallback -- e.g. 'p3f' and 'p3p' will fall back to 'p3' if applicable.
		else gameg = game
	end
	local gamen = getGames.games[game].name -- Full game name
	local gamegn = getGames.games[gameg].name -- e.g. 'Persona 3 FES' will fall back to 'Persona 3' if applicable.
	if not prop.image_bg then prop.image_bg = '#333' end
	local styleg = '\n|-\n!style="background: ' .. getGames.games[gameg].colorbg .. ';color: ' .. getGames.games[gameg].font .. '"'
	local styleh = styleg .. '|'
	local stylec = styleg .. ' colspan=2|'
	local result
	if prop.image then
		prop.image = '\n|-\n| style="border-radius:3.5px; background:' .. prop.image_bg .. '" colspan="2" align="center" | [[File:' .. prop.image .. '|' .. prop.image_width .. ']]'
		else prop.image = ''
	end
	result = '{|class="customtable" style="background: #333; width:250px; font-size:90%; border:3px solid ' .. getGames.games[gameg].colorb .. '; border-radius:7px; float: right; padding: 0px; margin-left:10px" |' .. stylec .. '\'\'' .. mw.title.getCurrentTitle().text .. '\'\'' .. prop.image
	if prop.japan then prop.japan = stylet .. prop.japan else prop.japan = '' end
	if prop.romaji then prop.romaji = stylet .. prop.romaji else prop.romaji = '' end
	result = result .. prop.japan .. prop.romaji .. stylec .. 'Informações do Jogo'
	for i,v in ipairs(game_stat_order1) do
		if prop[v] then
			result = result .. styleh .. v .. '\n|' .. prop[v]
		end
	end
	result = result .. stylec .. 'Datas de Lançamento'
	for i,v in ipairs(game_stat_order2) do
		if prop[v] then
			result = result .. styleh .. '[[File:Flag of ' .. v .. '.png|25px|alt=Flag of '..v..'|'..v..']]\n|' .. prop[v]
		end
	end
	result = result .. '\n|}' .. cate('Games')
	if gameg == 'mt1' or gameg == 'mt2' then
		result = result .. cate('Série Megami Tensei')
	elseif gameg == 'smt1' or gameg == 'smt2' or gameg == 'smtif' or gameg == 'smt3' or gameg == 'smt9' or gameg == 'smtim' or gameg == 'smtsj' or gameg == 'smt4' then
		result = result .. cate('Série Shin Megami Tensei')
	elseif gameg == 'lb1' or gameg == 'lb2' or gameg == 'alb' or gameg == 'lb3' or gameg == 'lbs' or gameg == 'lbnt1' or gameg == 'lbnt2' or gameg == 'lbnt3' then
		result = result .. cate('Série Last Bible')
	elseif gameg == 'majin1' or gameg == 'majin2' then
		result = result .. cate('Série Majin Tensei')
	elseif gameg == 'smtds' or gameg == 'sh' or gameg == 'raidou1' or gameg == 'raidou2' then
		result = result .. cate('Devil Summoner')
	elseif gameg == 'p1' or gameg == 'p2is' or gameg == 'p2ep' or gameg == 'p3' or gameg == 'pts' or gameg == 'p4' or gameg == 'pq' or gameg == 'p5' then
		result = result .. cate('Série Persona')
	elseif gameg == 'childred' or gameg == 'childblack' or gameg == 'childwhite' or gameg == 'childlight' or gameg == 'childfire' or gameg == 'childice' or gameg == 'childmessiah' then
		result = result .. cate('Devil Children')
	elseif gameg == 'ddsaga1' or gameg == 'ddsaga2' then
		result = result .. cate('Digital Devil Saga')
	elseif gameg == 'desu1' or gameg == 'desu2' then
		result = result .. cate('Série Devil Survivor')
	end
	if gameg == 'childred' or gameg == 'childblack'
		then result = result .. cate('Devil Children Red/Black Book','!')
	elseif gameg == 'childmessiah' then
		result = result .. cate('Messiah Riser','!')
	elseif gameg == '' then
	elseif gameg then
		result = result .. cate(gamen,'!')
	end
	return result
end
 
p.char = makeInvokeFunction('_char')
 
function p._char(args)
	local prop = get_prop(args)
	local game = args[1] or args.class or args.game or args.Game or ''
	local gameg
	if getGames.games[game].fallback then
		gameg = getGames.games[game].fallback
		else gameg = game
	end
	local gamen = getGames.games[game].name
	local gamegn = getGames.games[gameg].name
	local styleg = '\n|-\n!style="background: ' .. getGames.games[gameg].colorbg .. ';color: ' .. getGames.games[gameg].font .. '"'
	local styleh = styleg .. '|'
	local stylec = styleg .. ' colspan=2|'
	local result = '{| class="customtable" style="background:#000; border: 3px ' .. getGames.games[gameg].colorb .. ' solid; float: right; border-radius:7px; font-size:90%; padding: 0px; width:309px; margin-left:10px"' .. stylec .. prop.cname
	if not prop.image_bg then prop.image_bg = 'linear-gradient(20deg, #bbb, #222)' end
	if prop.image then result = result .. '\n|-\n!colspan=2 style="background:' .. prop.image_bg .. '"|' .. prop.image end
	for i,v in ipairs(char_stat_order) do
		if prop[v] then
			if t[v].h then t.header = t[v].h else t.header = v end
			result = result .. styleh .. t.header .. '\n|' .. prop[v]
		end
	end
	result = result .. '\n|}'
	if args.Part == 'both' or args.Part == 'Both' then
	    if game == 'p2is' then
		    result = result .. cate(getGames.games['p2is'].name .. ' Characters') .. cate(getGames.games['p2ep'].name .. ' Characters')
    	elseif game == 'smtds' then
	    	result = result .. cate(gamen .. ' Characters') .. cate(getGames.games['sh'].name .. ' Characters')
    	elseif game == 'raidou1' then
	    	result = result .. cate(gamen .. ' Characters') .. cate(getGames.games['raidou2'].name .. ' Characters')
    	elseif game == 'desu2' then
	    	result = result .. cate(gamen .. ' Characters') .. cate(getGames.games['desu2rb'].name .. ' Characters')
		end
    elseif args.Part == 'All' or args.Part == 'all' then
        if game == 'p3' then
    		result = result .. cate(gamen .. ' Characters') .. cate(getGames.games['p3f'].name .. ' Characters') .. cate(getGames.games['p3p'].name .. ' Characters')
	    elseif game == 'p4' then
		    result = result .. cate(gamen .. ' Characters') .. cate(getGames.games['p4g'].name .. ' Characters') .. cate(getGames.games['p4a'].name .. ' Characters') .. cate(getGames.games['p4d'].name .. ' Characters')
	    end
	elseif gamen ~= nil then
		result = result .. cate(gamen .. ' Characters')
	end
	if args.alignment == 'Law' then
	    result = result .. cate('Law-Aligned Characters')
	elseif args.alignment == 'Neutral' then
	    result = result .. cate('Neutral-Aligned Characters')
	elseif args.alignment == 'Chaos' then
	    result = result .. cate('Chaos-Aligned Characters')
	 end
	 return result
end
 
return p
--</pre>
--[[Category:Modules]]
--[[Category:Character Templates|!]]
Advertisement