Module:Card skill

From Sekaipedia

To generate {{Card skill}}, invoke using the main function.


local getArgs = require('Module:Arguments').getArgs
local VariablesLua = mw.ext.VariablesLua

local p = {}

local skillTypes = {
	['Scorer']  = {
		effect = "%d%% score boost for 5 seconds.",
		category = '[[Category:Scorer cards]]',
		['1'] = { { 20 }, { 25 }, { 30 }, { 40 } },
		['2'] = { { 30 }, { 35 }, { 40 }, { 50 } },
		['3'] = { { 60 }, { 65 }, { 70 }, { 80 } },
		['4'] = { { 100 }, { 105 }, { 110 }, { 120 } }
	},
	['Perfect locker'] = {
		effect = "All %ss and higher will become PERFECTs for %.1f seconds; %d%% score boost for 5 seconds.",
		category = '[[Category:Perfect locker cards]]',
		['2'] = { { 'GREAT', 4.5, 10 }, { 'GREAT', 5, 15 }, { 'GREAT', 5.5, 20 }, { 'GREAT', 6, 30 } },
		['3'] = { { 'GOOD', 5, 40 }, { 'GOOD', 5.5, 45 }, { 'GOOD', 6, 50 }, { 'GOOD', 6.5, 60 } },
		['4'] = { { 'BAD', 5.5, 80 }, { 'BAD', 6, 85 }, { 'BAD', 6.5, 90 }, { 'BAD', 7, 100 } }
	},
	['Healer']  = {
		effect = "Recover %d life; %d%% score boost for 5 seconds.",
		category = '[[Category:Healer cards]]',
		['2'] = { { 150, 10 }, { 200, 15 }, { 250, 20 }, { 300, 30 } },
		['3'] = { { 250, 40 }, { 300, 45 }, { 350, 50 }, { 400, 60 } },
		['4'] = { { 350, 80 }, { 400, 85 }, { 450, 90 }, { 500, 100 } }
	},
	['Perfect scorer'] = {
		effect = "%d%% score boost for 5 seconds for PERFECTs only.",
		category = '[[Category:Perfect scorer cards]]',
		['4'] = { { 110 }, { 115 }, { 120 }, { 130 } }
	},
	['Life scorer'] = {
		effect = "For 5 seconds, %d%% score boost if life is less than 800 or %d%% score boost if life is 800. For every +10 life above 800, score boost increased by +1%% (up to %d%%).",
		category = '[[Category:Life scorer cards]]',
		['4'] = { { 70, 100, 120 }, { 75, 105, 125 }, { 80, 110, 130 }, { 90, 120, 140 } }
	},
	['Combo scorer'] = {
		effect = "%d%% score boost for 5 seconds. If you hit GOOD or lower, score boost will be reduced to %d%%.",
		category = '[[Category:Combo scorer cards]]',
		['4'] = { { 120, 70 }, { 125, 75 }, { 130, 80 }, { 140, 90 } }
	},
	['Birthday scorer'] = {
		effect = "Recover %d life; %d%% score boost for 5 seconds for PERFECTs only.",
		category = '[[Category:Birthday scorer cards]]',
		['birthday'] = { { 700, 60 }, { 750, 65 }, { 800, 70 }, { 850, 80 } },
		['Birthday'] = { { 700, 60 }, { 750, 65 }, { 800, 70 }, { 850, 80 } }
	},
	['Leo/need scorer'] = {
		effect = "%d%% score boost for 5 seconds. Gain additional +10%% boost for every [Leo/need] card (except for themselves), and another +10%% boost if all card are from the same unit (up to %d%%).",
		category = '[[Category:Leo/need scorer cards]]',
		['4'] = { { 80, 130 }, { 85, 135 }, { 90, 140 }, { 100, 150 } }
	},
	['MORE MORE JUMP! scorer'] = {
		effect = "%d%% score boost for 5 seconds. Gain additional +10%% boost for every [MORE MORE JUMP!] card (except for themselves), and another +10%% boost if all cards are from the same unit (up to %d%%).",
		category = '[[Category:MORE MORE JUMP! scorer cards]]',
		['4'] = { { 80, 130 }, { 85, 135 }, { 90, 140 }, { 100, 150 } }
	},
	['Vivid BAD SQUAD scorer'] = {
		effect = "%d%% score boost for 5 seconds. Gain additional +10%% boost for every [Vivid BAD SQUAD] card (except for themselves), and another +10%% boost if all cards are from the same unit (up to %d%%).",
		category = '[[Category:Vivid BAD SQUAD scorer cards]]',
		['4'] = { { 80, 130 }, { 85, 135 }, { 90, 140 }, { 100, 150 } }
	},
	['Wonderlands×Showtime scorer'] = {
		effect = "%d%% score boost for 5 seconds. Gain additional +10%% boost for every [Wonderlands×Showtime] card (except for themselves), and another +10%% boost if all members are from the same unit (up to %d%%).",
		category = '[[Category:Wonderlands×Showtime scorer cards]]',
		['4'] = { { 80, 130 }, { 85, 135 }, { 90, 140 }, { 100, 150 } }
	},
	['25-ji, Nightcord de. scorer'] = {
		effect = "%d%% score boost for 5 seconds. Gain additional +10%% boost for every [25-ji, Nightcord de.] card (except for themselves), and another +10%% boost if all cards are from the same unit (up to %d%%).",
		category = '[[Category:25-ji, Nightcord de. scorer cards]]',
		['4'] = { { 80, 130 }, { 85, 135 }, { 90, 140 }, { 100, 150 } }
	},
}
	
local function getSkillValue(skill, rarity, skillLevel)
	if skill and 
		rarity and 
		skill[rarity] then
		
		return string.format(
			skill['effect'],
			unpack(skill[rarity][skillLevel])
		)
	end

	return string.format("<span class=\"plainlinks\">[%s?action=edit ? (edit)]</span>",
		tostring(mw.uri.fullUrl(mw.title.getCurrentTitle().text))
	)
end

local function getCategory(skill)
	if skill then
		return skill['category']
	end
	
	return ''
end

function p.main(frame)
	local args = getArgs(frame)
	
	local skillType = args['skill type']
	
	local rarity = args['rarity'] or VariablesLua.var( 'rarity' )
	
	local skill = skillTypes[skillType]
	
	local root = mw.html.create('ul')
	
	for i=1,4,1 do
		root:tag('li')
			:wikitext(string.format(
				"'''Level %d:''' %s",
				i,
				getSkillValue(skill, rarity, i)
			))
			:done()
	end
	
	local category = ''
	if mw.title.getCurrentTitle().namespace == 0 then
		category = getCategory(skill)
	end
		
	return tostring(root) .. category
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.