Module:CharacterStat: Difference between revisions
no edit summary
LeTrashman (talk | contribs) (Created page with "local p = {} local STAT_RARITY_BONUS = { ["attack"] = { 0, 1000, 2200, 3600, 5300 }, ["heal"] = { 0, 750, 1750, 2950, 4450 }, ["hp"] = { 0, 500, 1200, 2100, 3500 } } func...") |
LeTrashman (talk | contribs) No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1:
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(
local rarity = tonumber (
local stat = frame.args.stat
local val1 = tonumber(
local val100 = tonumber(
return math.ceil(lerp(lvl, 1, 100, val1, val100) * (10000 + STAT_RARITY_BONUS[stat][rarity]) / 10000)
▲end
▲local function lerp( x, x0, x1, y0, y1 )
▲ return y0 + (y1 - y0) * (x - x0) / (x1 - x0)
end
|