Content added Content deleted
mNo edit summary |
mNo edit summary |
||
(18 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
local getArgs |
local getArgs = require('Module:Arguments').getArgs |
||
local util = require('Module:Utilities') |
|||
local VariablesLua = mw.ext.VariablesLua |
|||
local p = {} |
local p = {} |
||
local function editIfNil(value, func) |
|||
if value and value ~= '' then |
|||
if func then |
|||
return func(value) |
|||
end |
|||
return value |
|||
end |
|||
return string.format( |
|||
"<span class=\"plainlinks\">[%s?action=edit ? (edit)]</span>", |
|||
tostring(mw.uri.fullUrl(mw.title.getCurrentTitle().text)) |
|||
) |
|||
end |
|||
function p.main(frame) |
function p.main(frame) |
||
local args = getArgs(frame) |
local args = getArgs(frame) |
||
local rarity = args['rarity'] |
local rarity = args['rarity'] or VariablesLua.var('rarity') |
||
local |
local minPerformance = args['min performance'] |
||
local |
local minTechnique = args['min technique'] |
||
local |
local minStamina = args['min stamina'] |
||
local |
local minPower = args['min power'] |
||
local |
local maxPerformance = args['max performance'] |
||
local |
local maxTechnique = args['max technique'] |
||
local |
local maxStamina = args['max stamina'] |
||
local |
local maxPower = args['max power'] |
||
local |
local maxLevel = '?' |
||
local |
local maxLevels = { |
||
['1'] = '20', |
['1'] = '20', |
||
['2'] = '30', |
['2'] = '30', |
||
['3'] = '50', |
['3'] = '50', |
||
['4'] = '60', |
['4'] = '60', |
||
['birthday'] = '60' |
['birthday'] = '60', |
||
['Birthday'] = '60' |
|||
} |
} |
||
if rarity ~= nil and rarity ~= '' then |
|||
local ss_bonus = nil |
|||
maxLevel = maxLevels[rarity] or '?' |
|||
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 |
end |
||
assert((tonumber( |
assert((tonumber(minPower) or 0) == |
||
(tonumber( |
(tonumber(minPerformance) or 0) + |
||
(tonumber( |
(tonumber(minTechnique) or 0) + |
||
(tonumber( |
(tonumber(minStamina) or 0)) |
||
assert((tonumber( |
assert((tonumber(maxPower) or 0) == |
||
(tonumber( |
(tonumber(maxPerformance) or 0) + |
||
(tonumber( |
(tonumber(maxTechnique) or 0) + |
||
(tonumber( |
(tonumber(maxStamina) or 0)) |
||
local |
local root = mw.html.create('table') |
||
: |
:addClass('wikitable') |
||
:tag('tr') |
|||
:tag('th') |
|||
:attr('height', '30px') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('Level 1') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('Level ' .. maxLevel) |
|||
:done() |
|||
:done() |
:done() |
||
:tag(' |
:tag('tr') |
||
: |
:tag('th') |
||
:attr('height', '30px') |
|||
:wikitext('[[File:Icon performance.png|25px|link=]] Performance') |
|||
}) |
|||
:tag('tr') |
|||
:tag('th') |
|||
:attr({ |
|||
['width'] = '33%', |
|||
['height'] = '30px' |
|||
}) |
|||
:done() |
|||
:tag('th') |
|||
:attr('width', '33%') |
|||
:wikitext('Level 1') |
|||
:done() |
|||
:tag('th') |
|||
:attr('width', '33%') |
|||
:wikitext('Level ' .. max_level) |
|||
:done() |
|||
:done() |
:done() |
||
:tag(' |
:tag('td') |
||
:wikitext(util.editIfNil(minPerformance)) |
|||
:tag('td') |
|||
:attr('height', '30px') |
|||
:wikitext('[[File:Icon performance.png|25px|link=]] Performance') |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(editIfNil(min_performance)) |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(editIfNil(max_performance)) |
|||
:done() |
|||
:done() |
:done() |
||
:tag(' |
:tag('td') |
||
:wikitext(util.editIfNil(maxPerformance)) |
|||
:tag('td') |
|||
:attr('height', '30px') |
|||
:wikitext('[[File:Icon technique.png|25px|link=]] Technique') |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(editIfNil(min_technique)) |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(editIfNil(max_technique)) |
|||
:done() |
|||
:done() |
:done() |
||
: |
:done() |
||
:tag('tr') |
|||
:tag('th') |
|||
:attr('height', '30px') |
|||
:wikitext('[[File:Icon stamina.png|25px|link=]] Stamina') |
|||
:wikitext('[[File:Icon technique.png|25px|link=]] Technique') |
|||
:done() |
|||
: |
:done() |
||
:tag('td') |
|||
:wikitext(editIfNil(min_stamina)) |
|||
:wikitext(util.editIfNil(minTechnique)) |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(editIfNil(max_stamina)) |
|||
:done() |
|||
:done() |
:done() |
||
:tag(' |
:tag('td') |
||
:wikitext(util.editIfNil(maxTechnique)) |
|||
:tag('td') |
|||
:attr('height', '30px') |
|||
:wikitext('Power') |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(editIfNil(min_power)) |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(editIfNil(max_power)) |
|||
:done() |
|||
:done() |
:done() |
||
:done() |
:done() |
||
:tag(' |
:tag('tr') |
||
:tag('th') |
|||
:wikitext('[[Template:Card Stats|view]] • [[Template talk:Card Stats|talk]]') |
|||
:attr('height', '30px') |
|||
:wikitext('[[File:Icon stamina.png|25px|link=]] Stamina') |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(util.editIfNil(minStamina)) |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(util.editIfNil(maxStamina)) |
|||
:done() |
|||
:done() |
:done() |
||
: |
:tag('tr') |
||
:tag('th') |
|||
:attr('height', '30px') |
|||
if rarity then |
|||
:wikitext('Power') |
|||
local additional = mw.html.create() |
|||
:tag('h3') |
|||
:wikitext('Additional Stats') |
|||
:done() |
:done() |
||
:tag(' |
:tag('td') |
||
:wikitext(util.editIfNil(minPower)) |
|||
:tag('li') |
|||
:done() |
|||
:wikitext('Side Story 1: +' .. ss_bonus[1]) |
|||
:tag('td') |
|||
:wikitext(util.editIfNil(maxPower)) |
|||
:tag('li') |
|||
:wikitext('Side Story 2: +' .. ss_bonus[2]) |
|||
:done() |
|||
:tag('li') |
|||
:wikitext('Master rank: +' .. mr_bonus) |
|||
:done() |
|||
:done() |
:done() |
||
:done() |
:done() |
||
:done() |
|||
return tostring(main) .. tostring(additional) |
|||
end |
|||
return tostring( |
return tostring(root) |
||
end |
end |
||
Latest revision as of 07:04, 4 February 2024
Documentation for this module may be created at Module:Card stats/doc
local getArgs = require('Module:Arguments').getArgs
local util = require('Module:Utilities')
local VariablesLua = mw.ext.VariablesLua
local p = {}
function p.main(frame)
local args = getArgs(frame)
local rarity = args['rarity'] or VariablesLua.var('rarity')
local minPerformance = args['min performance']
local minTechnique = args['min technique']
local minStamina = args['min stamina']
local minPower = args['min power']
local maxPerformance = args['max performance']
local maxTechnique = args['max technique']
local maxStamina = args['max stamina']
local maxPower = args['max power']
local maxLevel = '?'
local maxLevels = {
['1'] = '20',
['2'] = '30',
['3'] = '50',
['4'] = '60',
['birthday'] = '60',
['Birthday'] = '60'
}
if rarity ~= nil and rarity ~= '' then
maxLevel = maxLevels[rarity] or '?'
end
assert((tonumber(minPower) or 0) ==
(tonumber(minPerformance) or 0) +
(tonumber(minTechnique) or 0) +
(tonumber(minStamina) or 0))
assert((tonumber(maxPower) or 0) ==
(tonumber(maxPerformance) or 0) +
(tonumber(maxTechnique) or 0) +
(tonumber(maxStamina) or 0))
local root = mw.html.create('table')
:addClass('wikitable')
:tag('tr')
:tag('th')
:attr('height', '30px')
:done()
:tag('th')
:wikitext('Level 1')
:done()
:tag('th')
:wikitext('Level ' .. maxLevel)
:done()
:done()
:tag('tr')
:tag('th')
:attr('height', '30px')
:wikitext('[[File:Icon performance.png|25px|link=]] Performance')
:done()
:tag('td')
:wikitext(util.editIfNil(minPerformance))
:done()
:tag('td')
:wikitext(util.editIfNil(maxPerformance))
:done()
:done()
:tag('tr')
:tag('th')
:attr('height', '30px')
:wikitext('[[File:Icon technique.png|25px|link=]] Technique')
:done()
:tag('td')
:wikitext(util.editIfNil(minTechnique))
:done()
:tag('td')
:wikitext(util.editIfNil(maxTechnique))
:done()
:done()
:tag('tr')
:tag('th')
:attr('height', '30px')
:wikitext('[[File:Icon stamina.png|25px|link=]] Stamina')
:done()
:tag('td')
:wikitext(util.editIfNil(minStamina))
:done()
:tag('td')
:wikitext(util.editIfNil(maxStamina))
:done()
:done()
:tag('tr')
:tag('th')
:attr('height', '30px')
:wikitext('Power')
:done()
:tag('td')
:wikitext(util.editIfNil(minPower))
:done()
:tag('td')
:wikitext(util.editIfNil(maxPower))
:done()
:done()
:done()
return tostring(root)
end
return p