Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Card stats: Difference between revisions

From Sekaipedia
Content added Content deleted
mNo edit summary
mNo edit summary
Line 1: Line 1:
local util = require('Module:Utilities')
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local util = require('Module:Utilities')
local VariablesLua = mw.ext.VariablesLua


local p = {}
local p = {}



function p.main(frame)
function p.main(frame)
local args = frame:getParent().args
local args = frame:getParent().args
local rarity = args['rarity']
local rarity = args['rarity'] or VariablesLua.var( 'rarity' )
local hasSideStory = yesno(args['side story'], nil)
local min_performance = args['min performance']
local min_performance = args['min performance']

Revision as of 20:21, 30 March 2022

Documentation for this module may be created at Module:Card stats/doc

local getArgs = require('Module:Arguments').getArgs
local yesno   = require('Module:Yesno')
local util    = require('Module:Utilities')
local VariablesLua = mw.ext.VariablesLua

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	
	local rarity = args['rarity'] or VariablesLua.var( 'rarity' )
	
	local hasSideStory = yesno(args['side story'], nil)
	
	local min_performance = args['min performance']
	local min_technique   = args['min technique']
	local min_stamina     = args['min stamina']
	local min_power       = args['min power']

	local max_performance = args['max performance']
	local max_technique   = args['max technique']
	local max_stamina     = args['max stamina']
	local max_power       = args['max power']
	
	local max_level = '?'
	local max_levels = {
		['1'] = '20',
		['2'] = '30',
		['3'] = '50',
		['4'] = '60',
		['birthday'] = '50'
	}
	
	local ss_bonus = {}
	local side_story_bonuses = {
		['1'] = { 300, 600 },
		['2'] = { 450, 900 },
		['3'] = { 600, 1500 },
		['4'] = { 750, 1800 },
		['birthday'] = { 720, 1650 }
	}
	
	local mr_bonus = nil
	local master_rank_bonuses = {
		['1'] = 150,
		['2'] = 300,
		['3'] = 450,
		['4'] = 600,
		['birthday'] = 540
	}
	
	if rarity ~= nil then
		max_level = max_levels[rarity] or '?'
		ss_bonus = side_story_bonuses[rarity]
		mr_bonus = master_rank_bonuses[rarity]
	end

	assert((tonumber(min_power) or 0) == 
		(tonumber(min_performance) or 0) +
		(tonumber(min_technique) or 0) +
		(tonumber(min_stamina) or 0))
		
	assert((tonumber(max_power) or 0) == 
		(tonumber(max_performance) or 0) +
		(tonumber(max_technique) or 0) +
		(tonumber(max_stamina) or 0))

	
	local main = mw.html.create()
		:tag('h3')
			:wikitext('Main stats')
			:done()
		:tag('table'):addClass('wikitable')
			:tag('tr')
				:tag('th')
					:attr('height', '30px')
					:done()
				:tag('th')
					:wikitext('Level 1')
					:done()
				:tag('th')
					:wikitext('Level ' .. max_level)
					:done()
				:done()
			:tag('tr')
				:tag('th')
					:attr('height', '30px')
					:wikitext('[[File:Icon performance.png|25px|link=]] Performance')
					:done()
				:tag('td')
					:wikitext(util.editIfNil(min_performance))
					:done()
				:tag('td')
					:wikitext(util.editIfNil(max_performance))
					:done()
				:done()
			:tag('tr')
				:tag('th')
					:attr('height', '30px')
					:wikitext('[[File:Icon technique.png|25px|link=]] Technique')
					:done()
				:tag('td')
					:wikitext(util.editIfNil(min_technique))
					:done()
				:tag('td')
					:wikitext(util.editIfNil(max_technique))
					:done()
				:done()
			:tag('tr')
				:tag('th')
					:attr('height', '30px')
					:wikitext('[[File:Icon stamina.png|25px|link=]] Stamina')
					:done()
				:tag('td')
					:wikitext(util.editIfNil(min_stamina))
					:done()
				:tag('td')
					:wikitext(util.editIfNil(max_stamina))
					:done()
				:done()
			:tag('tr')
				:tag('th')
					:attr('height', '30px')
					:wikitext('Power')
					:done()
				:tag('td')
					:wikitext(util.editIfNil(min_power))
					:done()
				:tag('td')
					:wikitext(util.editIfNil(max_power))
					:done()
				:done()
			:done()
		:done()
	
	local additional = mw.html.create()
		:tag('h3')
			:wikitext('Additional stats')
			:done()
		:tag('ul')
			:tag('li')
				:wikitext('Side Story 1 Unlocked: +' .. (ss_bonus[1] or '?'))
				:done()
			:tag('li')
				:wikitext('Side Story 2 Unlocked: +' .. (ss_bonus[2] or '?'))
				:done()
			:tag('li')
				:wikitext('Each [[Master Rank]]: +' .. (mr_bonus or '?'))
				:done()
			:done()
		:done()
	
	return tostring(main) .. tostring(additional)
end

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