Module:Gamebox/sandbox

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) local result result = ' ' if mw.title.getCurrentTitle:inNamespace('') then result = result .. '[[Category:'	end	if sort then sort = '|' .. sort else sort = '' end	return result .. catename .. sort .. ']] ' end

local t = { ['Also known as']={'aka'}, ['Japanese Name']={'japan','kana'}, ['Romaji']={'romaji'}, ['rpname']={'RPname',h='Revelations Name '}, ['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='Secondary Arcana '}, -- Persona 1 and 2 ['Persona']={'persona'}, -- Character's signature Persona(s) ['Japanese VA']={'japaneseva','Japanese VA'}, ['English VA']={'englishva','English VA'}, ['image']={'image'}, ['image_width']={'image_width'}, ['image_bg']={'image_bg'}, ['japan']={'japan'}, ['romaji']={'romaji'}, ['developer']={'developer'}, ['publisher']={'publisher'}, ['genre']={'genre'}, ['platform']={'platform(s)','platform'}, ['releasej']={'release-date-japan','releasej'}, ['releasena']={'release-date-north-america','releasena'}, ['releaseeu'] ={'release-date-europe','releaseeu'}, ['releaseau']={'release-date-australasia','releaseau'}, ['cname']={'name'}, -- Character's name }

local t2 = { 'Also known as', 'Japanese Name', 'Romaji', 'rpname', 'First Appearance', 'Affiliation', 'Alignment', 'Team', 'Occupation', 'Rank', 'Ship', 'Country', 'Reason', 'Demonic Sponsor', 'Origin', 'Weapon', 'Demon Partner', 'Tribe', 'Firearm Type', 'Atma Avatar', 'Atma Brand', 'Brand Location', 'Date of Birth', 'Age', 'Zodiac', 'Height', 'Weight', 'COMP Color', 'Cell Phone Color', 'Residency', 'Fate Demon', 'Anime Demon', 'Blood Type', 'Melee Weapon', 'Ranged Weapon', 'Arcana', 'Arcana2', 'Persona', '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 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_width then prop.image_width = '240px' end 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" | ' 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 ..  .. tostring(mw.title.getCurrentTitle) ..  .. 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 .. 'Game Information' if prop.developer then prop.developer = styleh .. 'Developer\n|' .. prop.developer else prop.developer = '' end if prop.publisher then prop.publisher = styleh .. 'Publisher\n|' .. prop.publisher else prop.publisher = '' end if prop.genre then prop.genre = styleh .. 'Genre\n|' .. prop.genre else prop.genre = '' end if prop.platform then prop.platform = styleh .. 'Platform\n|' .. prop.platform else prop.platform = '' end result = result .. prop.developer .. prop.publisher .. prop.genre .. prop.platform .. stylec .. 'Release Dates' if prop.releasej then prop.releasej = styleh .. '\n|' .. prop.releasej else prop.releasej = '' end if prop.releasena then prop.releasena = styleh .. '\n|' .. prop.releasena else prop.releasena = '' end if prop.releaseeu then prop.releaseeu = styleh .. '\n|' .. prop.releaseeu else prop.releaseeu = '' end if prop.releaseau then prop.releaseau = styleh .. '\n|' .. prop.releaseau else prop.releaseau = '' end result = result .. prop.releasej .. prop.releasena .. prop.releaseeu .. prop.releaseau .. '\n|}' .. cate('Games') if gameg == 'mt1' or gameg == 'mt2' then result = result .. cate('Megami Tensei Series') 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('Shin Megami Tensei Series') 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('Last Bible Series') elseif gameg == 'majin1' or gameg == 'majin2' then result = result .. cate('Majin Tensei Series') 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('Persona Series') 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('Devil Survivor Series') 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 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 if not prop.cname then prop.cname = tostring(mw.title.getCurrentTitle) 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 = '{| class="customtable" style="background:#000; border: 3px ' .. getGames.games[gameg].colorb .. ' solid; float: right; border-radius:7px; font-size:90%; padding: 0px; width:290px; 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(t2) do result = result .. styleh .. v .. '\n|' .. prop.tostring(v) 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(gamen .. ' Characters') .. cate(getGames.games['desu2rb'].name .. ' Characters') elseif gamen ~= nil then result = result .. cate(gamen .. ' Characters') end return result end return p -- --