Please note that some information on this wiki is still based on the demo version.
If you notice any errors, feel free to correct them.
Module:LevelStats: Difference between revisions
From Super Fantasy Kingdom Official Wiki
wgg>Cadaei round values to 2 decimals |
wgg>Cadaei text-align |
||
| Line 49: | Line 49: | ||
end | end | ||
return '<table class="wikitable"><tr>'..table.concat(headers, '')..'</tr>'.. | return '<table class="wikitable right"><tr>'..table.concat(headers, '')..'</tr>'.. | ||
'<tr>'..table.concat(usedStats, '</tr><tr>')..'</tr>'..'</table>' | '<tr>'..table.concat(usedStats, '</tr><tr>')..'</tr>'..'</table>' | ||
end | end | ||
function p.StatEntryRow(name, val, valLast, levelCount) | function p.StatEntryRow(name, val, valLast, levelCount) | ||
local statColumns = {'[[File:'..name..'.png|16x16px]] [['..name..']]'} | local statColumns = {'<td style="text-align:left;">[[File:'..name..'.png|16x16px]] [['..name..']]</td>'} | ||
-- parsing value | -- parsing value | ||
| Line 64: | Line 64: | ||
for i=0,levelCount-1 do | for i=0,levelCount-1 do | ||
table.insert(statColumns, string.format("%.2f", val + (i*gainPerLevel))..unit) | table.insert(statColumns, '<td>'..string.format("%.2f", val + (i*gainPerLevel))..unit..'</td>') | ||
end | end | ||
return | return table.concat(statColumns, '') | ||
end | end | ||
return p | return p | ||
Revision as of 17:47, 1 November 2023
Displays a stat table for units for multiple levels.
Parameter names are the stat abbreviations, for the first level just the two letters, for the 10th level the stat abbreviation with suffix 10, e.g. dm=5 for damage 5 in level 1 and dm10=20 for damage 20 in level 10. Values are interpreted linerarly for the other levels.
For units use exp=true for exponential stat growth.
To display a gain indicator, use gainIndicator=true.
{{LevelStats
|pw=5|pw10=53
|hp=11|hp10=50
|sh=13|sh10=100
|cr=5%
|pd=0
|md=0
}}
| Stats | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| 11.00 | 15.33 | 19.67 | 24.00 | 28.33 | 32.67 | 37.00 | 41.33 | 45.67 | 50.00 | |
| 13.00 | 22.67 | 32.33 | 42.00 | 51.67 | 61.33 | 71.00 | 80.67 | 90.33 | 100.00 | |
| 5.00% | 5.00% | 5.00% | 5.00% | 5.00% | 5.00% | 5.00% | 5.00% | 5.00% | 5.00% | |
| 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | |
| 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
{{LevelStats
|exp=true
|pw=5|pw10=63
|hp=10|hp10=68
|sh=19|sh10=116
|cr=0%
|pd=0
|md=0
}}
| Stats | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| 10.00 | 16.44 | 22.89 | 29.33 | 35.78 | 42.22 | 48.67 | 55.11 | 61.56 | 68.00 | |
| 19.00 | 29.78 | 40.56 | 51.33 | 62.11 | 72.89 | 83.67 | 94.44 | 105.22 | 116.00 | |
| 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | |
| 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | |
| 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
{{LevelStats
|exp=true
|baseIndicator=true
|gainIndicator=true
|pw=5|pw10=63
|hp=10|hp10=68
|sh=19|sh10=116
|cr=0%
|pd=0
|md=0
}}
| Stats | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| 10.00 | 16.44 | 22.89 | 29.33 | 35.78 | 42.22 | 48.67 | 55.11 | 61.56 | 68.00 | |
| 19.00 | 29.78 | 40.56 | 51.33 | 62.11 | 72.89 | 83.67 | 94.44 | 105.22 | 116.00 | |
| 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | |
| 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | |
| 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
for copy pasting units
{{LevelStats
|exp=true
|baseIndicator=true
|gainIndicator=true
|pw= |pw10=
|hp= |hp10=
|ma= |ma10=
|sh= |sh10=
|rg= |rg10=
|cr=0%
|pd=0
|md=0
}}
Code at Module:LevelStats, doc at Template:LevelStats/doc.
local p = {}
function p.levelStats(f)
return p.create(f:getParent().args)
end
function p.create(args)
-- argument name and full name (also used for icon name)
local possibleStats = {
{"dm", "Damage"},
{"hp", "Health"},
{"sh", "Shield"},
{"cr", "Critical Chance"},
{"pd", "Physical Defense"},
{"md", "Magical Defense"},
{"cd", "Cooldown"},
{"ra", "Range"},
{"ar", "Area"},
{"kb", "Knockback"},
{"sp", "Speed"},
{"du", "Duration"},
{"gr", "Greed"},
{"rr", "Reroll"},
{"ba", "Banish"},
{"cu", "Curse"}
}
local usedStats = {}
local levelCount = 10
for _, statNames in ipairs(possibleStats) do
local statAbbreviation = statNames[1]
local statValue = args[statAbbreviation]
if statValue ~= nil and statValue ~= '' then
local statName = statNames[2]
local statValueLast = args[statAbbreviation..levelCount] or statValue
table.insert(usedStats, p.StatEntryRow(statName, statValue, statValueLast, levelCount))
end
end
if #usedStats == 0 then
return ''
end
local headers = {'<th>Stats</th>'}
for i=1,levelCount do
table.insert(headers, '<th>'..i..'</th>')
end
return '<table class="wikitable right"><tr>'..table.concat(headers, '')..'</tr>'..
'<tr>'..table.concat(usedStats, '</tr><tr>')..'</tr>'..'</table>'
end
function p.StatEntryRow(name, val, valLast, levelCount)
local statColumns = {'<td style="text-align:left;">[[File:'..name..'.png|16x16px]] [['..name..']]</td>'}
-- parsing value
local val, unit = string.match(val, '^(%d*%.?%d*) ?(.*)$')
local valLast, _ = string.match(valLast, '^(%d*%.?%d*) ?(.*)$')
-- stat value increase linearly by level
local gainPerLevel = (valLast - val)/(levelCount-1)
for i=0,levelCount-1 do
table.insert(statColumns, '<td>'..string.format("%.2f", val + (i*gainPerLevel))..unit..'</td>')
end
return table.concat(statColumns, '')
end
return p


