feat: add statholder

This commit is contained in:
Kazhnuz 2024-08-02 08:39:28 +02:00
parent ee31689f9e
commit df05425b8a
2 changed files with 20 additions and 2 deletions

View file

@ -0,0 +1,17 @@
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)
return self.commands.base + ((self.commands.level or 0) * level) + (self.commands.add or 0) + (self.commands.bonus or 0)
end
return StatHolder

View file

@ -3,6 +3,7 @@ local DataList = Object:extend()
local ListHolder = require "classes.dataholders.listholder" local ListHolder = require "classes.dataholders.listholder"
local SimpleHolder = require "classes.dataholders.simpleholder" local SimpleHolder = require "classes.dataholders.simpleholder"
local StatHolder = require "classes.dataholders.statholder"
function RawData.fromLine(line) function RawData.fromLine(line)
line = utils.removeComment(line) line = utils.removeComment(line)
@ -46,10 +47,10 @@ end
function DataList.getHolder(key, value) function DataList.getHolder(key, value)
if (value.dataType == "comp" or value.dataType == "list") then if (value.dataType == "comp" or value.dataType == "list") then
print("list", key, value)
return ListHolder(key, value) return ListHolder(key, value)
elseif (value.dataType == "stat") then
return StatHolder(key, value)
end end
print("simple", key, value.dataType)
return SimpleHolder(key, value) return SimpleHolder(key, value)
end end