bdd-creature/classes/dataholders/statholder.lua
2024-08-06 22:25:27 +02:00

20 lines
No EOL
534 B
Lua

local StatHolder = Object:extend()
function StatHolder:new(key, datas)
self.key = key
self.datas = datas
self.commands = {}
end
function StatHolder:applyCommand(command, args)
self.commands[command] = args
end
function StatHolder:reduce(level)
local stat = self.commands.base + ((self.commands.lvl or 0) * level) + (self.commands.add or 0) + (self.commands.bonus or 0)
local modulo = commands.structs[self.key].modulo or 1
stat = math.floor(stat / modulo) * modulo
return stat
end
return StatHolder