Fandom

Megami Tensei Wiki

Module:Gamebox/sandbox

< Module:Gamebox

4,384pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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 function cate(catename,sort)
	local result
	result = '<span style="display:none"><includeonly>'
	if mw.title.getCurrentTitle():inNamespace('') then 
			result = result .. '[[Category:'
	end
	if sort then sort = '|' .. sort else sort = '' end
	return result .. catename  .. sort .. ']]</includeonly></span>'
end
 
local t = {
	['image']={'image'},
	['image_width']={'image_width',default='240px'},
	['image_bg']={'image_bg'},
	['japan']={'japan'},
	['romaji']={'romaji'},
	['Developer']={'developer'},
	['Publisher']={'publisher'},
	['Genre']={'genre'},
	['Platform']={'platform(s)','platform'},
	['Japan']={'release-date-japan','releasej'},
	['the United States']={'release-date-north-america','releasena'},
	['Europe'] ={'release-date-europe','releaseeu'},
	['Australia']={'release-date-australasia','releaseau'},
	['cname']={'name',default=mw.title.getCurrentTitle().text}, -- Character's name
	['Also known as']={'aka'},
	['Japanese Name']={'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>'},
	['First Appearance']={'first appearance','first'},
	['Affiliation']={'affiliation'},
	['Alignment']={'alignment'},
	['Team']={'team'}, -- Strange Journey
	['Occupation']={'job','occupation'},
	['Rank']={'rank'}, -- Strange Journey
	['Ship']={'ship'}, -- Strange Journey
	['Country']={'country'}, -- Strange Journey
	['Reason']={'reason'}, -- Nocturne
	['Demonic Sponsor']={'demonic sponsor','sponsor'}, -- Nocturne
	['Origin']={'origin'},
	['Weapon']={'weapon'},
	['Demon Partner']={'demonpartner'}, -- Devil Child
	['Tribe']={'tribe'}, -- DDSaga
	['Firearm Type']={'gun'},
	['Atma Avatar']={'avatar'}, -- DDSaga Atma Avatar
	['Atma Brand']={'brand'}, -- DDSaga Atma brand
	['Brand Location']={'location'}, -- DDSaga Atma brand location
	['Date of Birth']={'birthday','dob'},
	['Age']={'age'},
	['Zodiac']={'zodiac'},
	['Height']={'height'},
	['Weight']={'weight'},
	['COMP Color']={'comp'}, -- Devil Survivor 1 character's COMP color
	['Cell Phone Color']={'cell'}, -- Devil Survivor 2 character's cel phone color
	['Residency']={'home'},
	['Fate Demon']={'fatedemon'}, -- Demon fusions unlocked by raising Devil Survivor 2 character's Fate rank
	['Anime Demon']={'animedemon'}, -- Allied demons summoned in Devil Survivor 2 anime
	['Blood Type']={'blood','blood type'},
	['Melee Weapon']={'melee'},
	['Ranged Weapon']={'ranged'},
	['Arcana']={'arcana'}, -- Persona series
	['Arcana2']={'arcana2',h='<abbr title="The arcana which also generally have ' .. "'Great'" .. ' affinity with the character apart from the signature Arcana.">Secondary Arcana</abbr>'}, -- Persona 1 and 2
	['Persona']={'persona'}, -- Character's signature Persona(s)
	['Mirage Partner']={'miragepartner'}, -- Shin Megami Tensei x Fire Emblem
	['Class']={'class'}, -- Shin Megami Tensei x Fire Emblem
	['Likes']={'likes'};
	['Dislikes']={'dislikes'};
	['Theme']={'theme','song'}, -- Character's theme music 
	['Japanese VA']={'japaneseva','Japanese VA'},
	['English VA']={'englishva','English VA'},
}
 
local game_stat_order1 = {
	'Developer',
	'Publisher',
	'Genre',
	'Platform',
}
 
local game_stat_order2 = {
	'Japan',
	'the United States',
	'Europe',
	'Australia',
}
 
local char_stat_order = {
	'Also known as',
	'Japanese Name',
	'Romaji',
	'rpname',
	'First Appearance',
	'Affiliation',
	'Alignment',
	'Team',
	'Occupation',
	'Rank',
	'Ship',
	'Country',
	'Reason',
	'Demonic Sponsor',
	'Origin',
	'Weapon',
	'Demon Partner',
	'Mirage Partner',
	'Class',
	'Tribe',
	'Firearm Type',
	'Atma Avatar',
	'Atma Brand',
	'Brand Location',
	'Date of Birth',
	'Age',
	'Likes',
	'Dislikes',
	'Zodiac',
	'Height',
	'Weight',
	'COMP Color',
	'Cell Phone Color',
	'Residency',
	'Fate Demon',
	'Anime Demon',
	'Blood Type',
	'Melee Weapon',
	'Ranged Weapon',
	'Arcana',
	'Arcana2',
	'Persona',
	'Theme',
	'Japanese VA',
	'English VA',
}
 
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
 
local function get_game(gamec)
	local game = {}
	local gameg
	if getGames.games[gamec].fallback then
		gameg = getGames.games[gamec].fallback -- e.g. 'p3f' and 'p3p' will fall back to 'p3' if applicable.
		else gameg = gamec
	end
	game.g = gameg
	game.n = getGames.games[gamec].name -- Full game name
	game.gn = getGames.games[gameg].name -- e.g. 'Persona 3 FES' will fall back to 'Persona 3' if applicable.
	return game
end
 
local style = {
['g'] = '{|class="customtable" style="background: #333; min-width:250px; max-width:290px; font-size:90%; border-radius:7px; float: right; padding: 0px; margin-left:10px; border:3px solid ',
['t'] = '\n|-\n|style="background:#222; font-size:100%; text-align:center" colspan=2|',
['h'] = '\n|-\n!style="background:#000; color:#fff"|',
}
 
p.game = makeInvokeFunction('_game')
 
function p._game(args)
	local prop = get_prop(args)
	local gamec = args[1] or args.class or args.game or args.Game or ''
	local game = get_game(gamec)
	style.c = '\n|-\n!style="background:' .. getGames.games[game.g].colorbg .. '; color:' .. getGames.games[game.g].font .. '" colspan=2|'
	if not prop.image_bg then prop.image_bg = '#333' end
	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
	local result = style.g .. getGames.games[game.g].colorb .. '" |' .. style.c .. '\'\'' .. mw.title.getCurrentTitle().text .. '\'\'' .. prop.image
	if prop.japan then prop.japan = style.t .. prop.japan else prop.japan = '' end
	if prop.romaji then prop.romaji = style.t .. prop.romaji else prop.romaji = '' end
	result = result .. prop.japan .. prop.romaji .. style.c .. 'Game Information'
	for i,v in ipairs(game_stat_order1) do
		if prop[v] then
			result = result .. style.h .. v .. '\n|' .. prop[v]
		end
	end
	result = result .. style.c .. 'Release Dates'
	for i,v in ipairs(game_stat_order2) do
		if prop[v] then
			result = result .. style.h .. '[[File:Flag of ' .. v .. '.png|25px]]\n|' .. prop[v]
		end
	end
	result = result .. '\n|}' .. cate('Games')
	if game.g == 'mt1' or game.g == 'mt2' then
		result = result .. cate('Megami Tensei Series')
	elseif game.g == 'smt1' or game.g == 'smt2' or game.g == 'smtif' or game.g == 'smt3' or game.g == 'smt9' or game.g == 'smtim' or game.g == 'smtsj' or game.g == 'smt4' then
		result = result .. cate('Shin Megami Tensei Series')
	elseif game.g == 'lb1' or game.g == 'lb2' or game.g == 'alb' or game.g == 'lb3' or game.g == 'lbs' or game.g == 'lbnt1' or game.g == 'lbnt2' or game.g == 'lbnt3' then
		result = result .. cate('Last Bible Series')
	elseif game.g == 'majin1' or game.g == 'majin2' then
		result = result .. cate('Majin Tensei Series')
	elseif game.g == 'smtds' or game.g == 'sh' or game.g == 'raidou1' or game.g == 'raidou2' then
		result = result .. cate('Devil Summoner')
	elseif game.g == 'p1' or game.g == 'p2is' or game.g == 'p2ep' or game.g == 'p3' or game.g == 'pts' or game.g == 'p4' or game.g == 'pq' or game.g == 'p5' then
		result = result .. cate('Persona Series')
	elseif game.g == 'childred' or game.g == 'childblack' or game.g == 'childwhite' or game.g == 'childlight' or game.g == 'childfire' or game.g == 'childice' or game.g == 'childmessiah' then
		result = result .. cate('Devil Children')
	elseif game.g == 'ddsaga1' or game.g == 'ddsaga2' then
		result = result .. cate('Digital Devil Saga')
	elseif game.g == 'desu1' or game.g == 'desu2' then
		result = result .. cate('Devil Survivor Series')
	end
	if game.g == 'childred' or game.g == 'childblack'
		then result = result .. cate('Devil Children Red/Black Book','!')
	elseif game.g == 'childmessiah' then
		result = result .. cate('Messiah Riser','!')
	elseif game.g then
		result = result .. cate(game.n,'!')
	end
	return result
end
 
p.char = makeInvokeFunction('_char')
 
function p._char(args)
	local prop = get_prop(args)
	local gamec = args[1] or args.class or args.game or args.Game or ''
	local game = get_game(gamec)
	style.c = '\n|-\n!style="background:' .. getGames.games[game.g].colorbg .. '; color:' .. getGames.games[game.g].font .. '" colspan=2|'
	local result = style.g .. getGames.games[game.g].colorb .. '"' .. style.c .. 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 .. style.h .. t.header .. '\n|' .. prop[v]
		end
	end
	result = result .. '\n|}'
	if args.Part == 'both' or args.Part == 'Both' then
		result = result .. cate(getGames.games['p2is'].name .. ' Characters') .. cate(getGames.games['p2ep'].name .. ' Characters')
	elseif game == 'desu2' then
		result = result .. cate(game.n .. ' Characters') .. cate(getGames.games['desu2rb'].name .. ' Characters')
	elseif game.n ~= nil then
		result = result .. cate(game.n .. ' 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
 
--[[Category:Modules]]
--[[Category:Character Templates|!]]

Also on Fandom

Random Wiki