Module:CharacterStat: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
LeTrashman (talk | contribs) No edit summary |
LeTrashman (talk | contribs) No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
-- Cumulative rarity bonus per stat. |
|||
local STAT_RARITY_BONUS = { |
local STAT_RARITY_BONUS = { |
||
["attack"] = { 0, 1000, 2200, 3600, 5300 }, |
["attack"] = { 0, 1000, 2200, 3600, 5300 }, |
||
Line 13: | Line 14: | ||
function p.calculate( frame ) |
function p.calculate( frame ) |
||
local lvl = tonumber( |
local lvl = tonumber(frame.args.lvl) |
||
local rarity = tonumber ( |
local rarity = tonumber (frame.args.rarity) |
||
local stat = frame.args.stat |
local stat = frame.args.stat |
||
local val1 = tonumber( |
local val1 = tonumber(frame.args.val1) |
||
local val100 = tonumber( |
local val100 = tonumber(frame.args.val100) |
||
return math.ceil(lerp(lvl, 1, 100, val1, val100) * (10000 + STAT_RARITY_BONUS[stat][rarity]) / 10000) |
return math.ceil(lerp(lvl, 1, 100, val1, val100) * (10000 + STAT_RARITY_BONUS[stat][rarity]) / 10000) |
Latest revision as of 20:27, 6 September 2021
Module for interpolating a character's attack/defense/heal/HP stats given their values at levels 1 and 100.
Example usage: {{#invoke:CharacterStat|calculate|lvl=73|rarity=3|stat=defense|val1=19|val100=115}}
local p = {}
-- Cumulative rarity bonus per stat.
local STAT_RARITY_BONUS = {
["attack"] = { 0, 1000, 2200, 3600, 5300 },
["defense"] = { 0, 0, 0, 0, 0 },
["heal"] = { 0, 750, 1750, 2950, 4450 },
["hp"] = { 0, 500, 1200, 2100, 3500 }
}
local function lerp( x, x0, x1, y0, y1 )
return y0 + (y1 - y0) * (x - x0) / (x1 - x0)
end
function p.calculate( frame )
local lvl = tonumber(frame.args.lvl)
local rarity = tonumber (frame.args.rarity)
local stat = frame.args.stat
local val1 = tonumber(frame.args.val1)
local val100 = tonumber(frame.args.val100)
return math.ceil(lerp(lvl, 1, 100, val1, val100) * (10000 + STAT_RARITY_BONUS[stat][rarity]) / 10000)
end
return p