Module:Skills/sandbox

local getArgs = require('Module:Arguments').getArgs 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 styles = { ['skill'] = '\n|-\n!style="background:#000;color:#fff"|', ['skillc'] = '\n!style="background:#000;color:#fff;"|', ['cost1'] = '\n|style="background:#222"|', ['cost2'] = '\n|style="background:#282828"|', ['effect1'] = '\n|style="background:#222;text-align:left"|', ['effect2'] = '\n|style="background:#282828;text-align:left"|', ['effect1p'] = '\n|colspan=2 style="background:#222;text-align:left"|', ['effect2p'] = '\n|colspan=2 style="background:#282828;text-align:left"|', ['order'] = '\n|style="background:#000;text-align:left"|', ['smt1table'] = '\n{|class="customtable smt1" width="100%"', ['p3table'] = '\n{|class="customtable p3" width="100%"', ['p4table'] = '\n{|class="customtable p4" width="100%"', ['statlow'] = '\n|style="background:#000;color:#fff"|', }

local cate1 = ' [[Category:' local cate2 = ']] ' local noskillcate = cate1 .. 'Articles with unrecognizable skill name for Module:Skills' .. cate2 local noskill1 = 'Invalid skill name of "' local noskill2 = '". You may correct the skill name or modify module:Skills/' local noskill3 = ' if needed. ' .. noskillcate local noskill4 = 'No empty line or skill name is allowed. You should either remove the empty line or add some proper skill name. ' .. noskillcate

p.row = makeInvokeFunction('_row') function p._row(args) local row = args[1] or args.row local game = args[2] or args.game local code = args[3] or args.code or args.Skill1 or args.Skill2 or args.Skill3 or args.Skill4 or args.Skill5 or args.Skill6 or args.Skill7 or args.Skill8 or args.Skill9 or args.Skill10 or args.Skill11 or args.Skill12 or args.Skill13 or args.Skill14 or args.Skill15 or args.Skill16 or args.Skill17 or args.Skill18 or args.Skill19 or args.Skill20 or args.Skill21 or args.Skill22 or args.Skill23 or args.Skill24 or args.Skill25 or args.Skill26 or args.Skill27 or args.Skill28 or args.Skill29 or args.Skill30 if not code or code ==  then return  end local level = args[4] or args.Level1 or args.Level2 or args.Level3 or args.Level4 or args.Level5 or args.Level6 or args.Level7 or args.Level8 or args.Level9 or args.Level10 or args.Level11 or args.Level12 or args.Level13 or args.Level14 or args.Level15 or args.Level16 or args.Level17 or args.Level18 or args.Level19 or args.Level20 or args.Level21 or args.Level22 or args.Level23 or args.Level24 or args.Level25 or args.Level26 or args.Level27 or args.Level28 or args.Level29 or args.Level30 if level == 'innate' or level == 'default' or level == 'Default' then level = 'Innate' end local data = require('Module:Skills/' .. game) local skill = data.skills[code] if not skill then local alias = data.aliases[code] if alias then code = alias skill = data.skills[code] else return noskill1 .. code .. noskill2 .. game .. noskill3 end end if skill.name then code = skill.name end local skillcell = styles['skill'] .. code local cost = skill.cost if game == 'SMT3' then if cost == 'Convo' then cost = 'Convo ' elseif cost == 'Interrupt' then cost = 'Interrupt ' end end local cost1 = '\n||' .. cost local cost2 = styles['cost2'] .. cost local effect1 = styles['effect1'] .. skill.effect local effect2 = styles['effect2'] .. skill.effect local order = styles['order'] .. skill.cost local element1, element2 if skill.element then element1 = '\n||' .. skill.element or '' element2 = styles['cost2'] .. skill.element or '' end local level1, level2 if level then level1 = '\n||' .. level or '' level2 = styles['cost2'] .. level or '' elseif skill.pre then level1 = '\n||' .. skill.pre level2 = styles['cost2'] .. skill.pre end local result if row == 'r01' then result = skillcell .. effect1 -- Odd number row for enemy whose skill cost is irrelevant. elseif row == 'r02' then result = skillcell .. effect2 -- Even number row for enemy whose skill cost is irrelevant. elseif row == 'r11' then if game == 'SMT3' and skill.phy then result = skillcell .. styles['effect1p'] .. skill.effect -- Odd number row for enemy whose physical skills cost no HP. else result = skillcell .. cost1 .. effect1 -- Odd number row for demon which does not learn new skill on level gain. end elseif row == 'r12' then if game == 'SMT3' and skill.phy then result = skillcell .. styles['effect2p'] .. skill.effect -- Even number row for enemy whose physical skills cost no HP. else result = skillcell .. cost2 .. effect2 -- Even number row for demon which does not learn new skill on level gain. end result = skillcell .. cost2 .. effect2 -- Even number row for demon which does not learn new skill on level gain. elseif row == 'r21' then result = skillcell .. cost1 .. effect1 .. level1 -- Odd number row for demon/persona which learn new skill on level gain. elseif row == 'r22' then result = skillcell .. cost2 .. effect2 .. level2 -- Even number row for demon/persona which learn new skill on level gain. elseif row == 'r31' then result = skillcell .. effect1 .. level1 -- Odd number row for guest who learn new skill on level gain. elseif row == 'r32' then result = skillcell .. effect2 .. level2 -- Even number row for guest who learn new skill on level gain. elseif row == 'p12' then result = styles['skill'] .. level .. styles['skillc'] .. code .. effect1 -- Row for Persona 1 and 2 persona elseif row == 'rf' then result = skillcell .. effect1 .. order -- Row for Persona-specific fusion spell. elseif row == 'dk1' then result = skillcell .. element1 .. cost1 .. effect1 -- Odd number row for DemiKids stats skill list. elseif row == 'dk2' then result = skillcell .. element2 .. cost2 .. effect2 -- Odd number row for DemiKids stats skill list. elseif row == 'dkc1' then result = skillcell .. level1 .. element1 .. cost1 .. effect1 -- Odd number row for DemiKids stats combo skill list. elseif row == 'dkc2' then result = skillcell .. level2 .. element2 .. cost2 .. effect2 -- Odd number row for DemiKids stats combo skill list. else result = 'Invalid parameter 1 of ' .. '"' .. row .. '". ' .. cate1 .. 'Templates with unrecognizable row value for Module:Skills' .. cate2 end return result end p.SMTstats = makeInvokeFunction('_SMTstats') function p._SMTstats(args) local image = args[1] or args.Image or '' local magdrop = args[2] or args['Mag Drop'] or '' local mag = args[3] or args.MAG or '' local cp = args[4] or args.CP or '' local race = args[5] or args.Race or args.Clan or '' local alignment = args[6]or args.Alignment or args.Align or '' local level = args[7] or args.Level or '' local hp = args[8] or args.HP or '' local mp = args[9] or args.MP or '' local noa = args[10] or args.NOA or args.NOH or '' local str = args[11] or args.STR or args.st or '' local int = args[12] or args.INT or args['in'] or '' local mgc = args[13] or args.MGC or args.ma or '' local stm = args[14] or args.STM or args.vi or '' local agl = args[15] or args.AGL or args.ag or '' local lck = args[16] or args.LCK or args.lu or '' local atk = args[17] or args.Atk or '' local hit = args[18] or args.Hit or '' local def = args[19] or args.Def or '' local avd = args[20] or args.Avd or args.Eva or '' local mpw = args[21] or args.Mpw or '' local mef = args[22] or args.Mef or '' local drop = args[23] or args.Drop or '' local resist = args[24] or args.Resist or args.Affinity local skills = args[25] or args.Skills if image then image = styles['skill'] .. image elseif image ==  then image =  end local magt if mag~= or cp~= then magt = 'CP ' elseif magdrop~='' then magt = '| MAG ' end if race == 'Seraph' then race = 'Seraph' .. cate1 .. 'Herald Race' .. cate2 elseif race == 'Ghost' then race = 'Ghost' .. cate1 .. 'Haunt Race' .. cate2 elseif race == 'Gaean' or race == 'Gaian' then race = 'Gaean' .. cate1 .. 'Ring of Gaea' .. cate2		elseif race == 'Messian' then race = '[[Order of Messiah|Messian'.. cate1 .. 'Order of Messiah' .. cate2		else race =  .. race .. 	end	if resist then resist = styles['smt1table'] .. '\n!width=100|Resistances\n|style="background:#000;text-align:left;padding:0 5px"|' .. resist .. '\n|}'		else resist = 	end	local los = 	for k, v in ipairs(mw.text.split(skills, '\n')) do		local data = require('Module:Skills/SMT1')		local skill = data.skills[v]		if not skill then			local alias = data.aliases[v]			if alias then				v = alias				skill = data.skills[v]			else skill = v			end		end		local skillcell = styles['skill'] .. v		local effect, cost		if skill == nil then			cost = 			effect = noskill4			elseif skill.effect then				cost = skill.cost				effect = skill.effect				if skill.name then v = skill.name end			else				cost = 				effect = noskill1 .. skill .. noskill2 .. 'SMT1' .. noskill3		end		if magdrop ~=  then			if (k % 2 == 0) then				los = los .. skillcell .. styles['effect2'] .. effect			else				los = los .. skillcell .. styles['effect1'] .. effect			end		else			if (k % 2 == 0) then				los = los .. skillcell .. styles['cost2'] .. cost .. styles['effect2'] .. effect			else				los = los .. skillcell .. '\n||' .. cost .. styles['effect1'] .. effect			end		end	end	local categoryb, categoryd, categorya	if magdrop then categoryb = cate1 .. 'Shin Megami Tensei Bosses' .. cate2 else categoryb =  end	if mag then categoryd = cate1 .. 'Shin Megami Tensei Demons' .. cate2 else categoryd =  end	if alignment == 'Law' or alignment == 'Light-Law' or alignment == 'Neutral-Law' or alignment == 'Dark-Law' then categorya = cate1 .. 'Law Demons in Shin Megami Tensei' .. cate2		elseif alignment == 'Neutral' or alignment == 'Light-Neutral' or alignment == 'Neutral-Neutral' or alignment == 'Dark-Neutral' then categorya = cate1 .. 'Neutral Demons in Shin Megami Tensei' .. cate2		elseif alignment == 'Chaos' or alignment == 'Light-Chaos' or alignment == 'Neutral-Chaos' or alignment == 'Dark-Chaos' then categorya = cate1 .. 'Chaos Demons in Shin Megami Tensei' .. cate2		elseif not alignment or alignment ==  or '-' then categorya = 	end	local costt	if mag~= or cp~= then		costt = styles['skillc'] .. 'Cost'		elseif magdrop~= then costt = 	end	if cp then cp = ' / ' .. cp elseif cp ==  then cp =  end	if not magdrop or magdrop ==  then magdrop = mag .. cp end	local skillt	if skills ~=  then		skillt = '\n!colspan="3"| List of Skills \n|-\n' .. styles['skillc'] .. 'Skill' .. costt .. styles['skillc'] .. 'Effect'		else skillt = 	end	local result	result = '{|align="center" style="min-width:650px;text-align:center; background: #222222; border:2px solid #608341;border-radius:7px; clear:both; font-size:75%; font-family:verdana;"\n|-\n|\n{|width=100% cellpadding=0 cellspacing=0\n' .. image .. '\n|' .. styles['smt1table'] .. '\n! Race \n! Alignment \n!Level\n!HP\n!MP\n!' .. magt .. '\n|-' .. styles['statlow'] .. race .. styles['statlow'] .. alignment .. styles['statlow'] .. level .. styles['statlow'] .. hp .. styles['statlow'] .. mp .. styles['statlow'] .. magdrop .. '\n|}' .. styles['smt1table'] .. '\n!NOH \n!Strength\n!Intelligence\n!Magic\n!Vitality\n!Agility\n!Luck\n|-' .. styles['statlow'] .. noa .. styles['statlow'] .. str .. styles['statlow'] .. int .. styles['statlow'] .. mgc .. styles['statlow'] .. stm .. styles['statlow'] .. agl .. styles['statlow'] .. lck .. '\n|}' .. styles['smt1table'] .. '\n!Attack\n!Hit\n!Defense\n!Evasion\n!MPower \n!MEffect \n! Drop \n|-' .. styles['statlow'] .. atk .. styles['statlow'] .. hit .. styles['statlow'] .. def .. styles['statlow'] .. avd .. styles['statlow'] .. mpw .. styles['statlow'] .. mef .. styles['statlow'] .. drop .. '\n|}\n|}' .. resist .. styles['smt1table'] .. skillt .. los .. '\n|}\n|}' .. categoryb .. categoryd .. categorya	return result end p.P4stats = makeInvokeFunction('_P4stats') function p._P4stats(args)	local boss = args[1] or args.Boss	local hp = args[2] or args.HP	local sp = args[3] or args.SP	local level = args[4] or args.Level or 	local arcana = args[5] or args.Arcana or 	local strength = args[6]or args.Strength or args.st or 	local magic = args[7] or args.Magic or args.ma or 	local endurance = args[8] or args.Endurance or args.en or 	local agility = args[9] or args.Agility or args.ag or 	local luck = args[10] or args.Luck or args.lu or 	local resist = args[11] or args.Resist or args.Resists	local block = args[12] or args.Block or args.Null or args.Immune	local absorb = args[13] or args.Absorb or args.Absorbs or args.Drain	local reflect = args[14] or args.Reflect or args.Reflects or args.Repel	local weak = args[15] or args.Weak	local phys = args[16] or args.Phys	local fire = args[17] or args.Fire	local ice = args[18] or args.Ice	local elec = args[19] or args.Lit or args.Elec	local wind = args[20] or args.Wind	local light = args[21] or args.Light	local dark = args[22] or args.Dark	local alm = args[23] or args.Alm or args.Almighty	local inherit = args[24] or args.Inherit	local yen = args[25] or args.Yen	local xp = args[26] or args.EXP	local p4g = args[27] or args.P4G	local skills = args[28] or args.Skills	local result = '{|align="center" style="min-width:650px;text-align:center; background: #222; border:2px solid #FFE600; border-radius:7px; clear:both; font-size:75%; font-family:verdana;"\n|-\n|' .. styles['p4table'] .. '\n!Level\n! Arcana \n'	if hp or mp then		result = result .. '!HP\n!SP'	end	result = result .. '\n!title="Strength"|ST\n!title="Magic"|MA\n!title="Endurance"|EN\n!title="Agility"|AG\n!title="Luck"|LU\n|-\n' .. styles['statlow'] .. level .. styles['statlow']	if arcana == '-' or arcana == 'Unclassified' or arcana == 'None'		then result = result .. '-'		else result = result ..  .. arcana .. 	end	if hp or sp then		result = result .. styles['statlow'] .. hp .. styles['statlow'] .. sp	end	result = result .. styles['statlow'] .. strength .. styles['statlow'] .. magic .. styles['statlow'] .. endurance .. styles['statlow'] .. agility .. styles['statlow'] .. luck .. '\n|}' .. styles['p4table']	if phys or fire or ice or elec or wind or light or dark or alm or xp or yen then		if not phys then phys =  end		if not fire then fire =  end		if not ice then ice =  end		if not elec then elec =  end		if not wind then wind =  end		if not light then light =  end		if not dark then dark =  end		if not alm then alm =  end		if not xp then xp =  end		if not yen then yen = '' end		result = result .. '\n!Phys\n!Fire\n!Ice\n!title="Electricity"|Elec\n!Wind\n!Light\n!Dark\n!Almighty\n!EXP\n!Yen\n|-\n' .. styles['statlow'] .. phys .. styles['statlow'] .. fire .. styles['statlow'] .. ice .. styles['statlow'] .. elec .. styles['statlow'] .. wind .. styles['statlow'] .. light .. styles['statlow'] .. dark .. styles['statlow'] .. alm .. styles['statlow'] .. xp .. styles['statlow'] .. yen		elseif inherit or resist or block or absorb or reflect or weak then		if not inherit then inherit = '-' end		if not resist then resist = '-' end		if not block then block = '-' end		if not absorb then absorb = '-' end		if not reflect then reflect = '-' end		if not weak then weak = '-' else weak = ' ' .. weak .. ' ' end		result = result .. '\n!Inherit\n!Resists\n!Block\n!Absorbs\n!Reflects\n!Weak\n|-\n' .. styles['statlow'] .. inherit .. styles['statlow'] .. resist .. styles['statlow'] .. block .. styles['statlow'] .. absorb .. styles['statlow'] .. reflect .. styles['statlow'] .. weak		end	result = result .. '\n|}'	local data = require('Module:Skills/P4')	if skills then		if hp or sp or boss then			result = result .. styles['p4table'] .. '\n!colspan="2"| List of Skills ' .. styles['skill'] .. 'Skill' .. styles['skillc'] .. 'Effect'			for k, v in ipairs(mw.text.split(skills, '\n')) do				local skill = data.skills[v]				if not skill then					local alias = data.aliases[v]					if alias then						v = alias						skill = data.skills[v]					else skill = v					end				end				local skillcell = styles['skill'] .. v				local effect				if skill == nil then effect = noskill4					elseif skill.effect then						effect = skill.effect						if skill.name then v = skill.name end					else effect = noskill1 .. skill .. noskill2 .. 'P4' .. noskill3				end				if (k % 2 == 0) then					result = result .. skillcell .. styles['effect2'] .. effect				else					result = result .. skillcell .. styles['effect1'] .. effect				end			end		else			result = result .. styles['p4table'] .. '\n!colspan="4"| List of Skills ' .. styles['skill'] .. 'Skill' .. styles['skillc'] .. 'Cost' .. styles['skillc'] .. 'Effect' .. styles['skillc'] .. 'Level'			for k1, v1 in ipairs(mw.text.split(skills, '\n')) do -- Any entry on new line within "Skills" parameter is treated as new skill name.				for k2, v2 in ipairs(mw.text.split(v1 .. '\\', '\\')) do -- Entry after backslash after skill name is treated as "level" for learning new skill per level gain. Any entry starting from second backslash on the same line is ignored until a new line.					if k2 > 2 then break						elseif (k2 % 2 == 0) then -- this checks even (true) or odd (false) number row.							if v2 == 'innate' or v2 == 'default' or v2 == 'Default'								then v2 = 'Innate'							end							if (k1 % 2 == 0) then								result = result .. styles['cost2'] .. v2 -- "v2" represents "Level" within "Skills" parameter on each new line after the backslash.							else result = result .. styles['cost1'] .. v2							end						else						local skill = data.skills[v2] -- now v2 represents skill name						if not skill then							local alias = data.aliases[v2]							if alias then								v2 = alias								skill = data.skills[v2]							else skill = v2							end						end						local skillcell = styles['skill'] .. v2						if skill == nil then							cost = 							effect = noskill4						elseif skill.effect then							cost = skill.cost							effect = skill.effect							if skill.name then v2 = skill.name end						else							cost = 							effect = noskill1 .. skill .. noskill2 .. 'P4' .. noskill3						end						if (k1 % 2 == 0) then							result = result .. skillcell .. styles['cost2'] .. cost .. styles['effect2'] .. effect						else							result = result .. skillcell .. styles['cost1'] .. cost .. styles['effect1'] .. effect						end					end				end			end		end	end	result = result .. '\n|}\n|}'	if inherit or resist or block or absorb or reflect or weak then		result = result .. cate1 .. 'Persona 4 Personas' .. cate2 .. cate1 .. 'Persona 4 Golden Personas' .. cate2		elseif p4g then result = result .. cate1 .. 'Persona 4 Golden Personas' .. cate2	end	if boss then result = result .. cate1 .. 'Persona 4 Bosses' .. cate2 end	if phys or fire or ice or elec or wind or light or dark or alm or xp or yen then result = result .. cate1 .. 'Persona 4 Shadows' .. cate2 end	return result end return p --