diff --git a/classes/dataholders/statholder.lua b/classes/dataholders/statholder.lua new file mode 100644 index 0000000..6c6e9d9 --- /dev/null +++ b/classes/dataholders/statholder.lua @@ -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 \ No newline at end of file diff --git a/classes/datalist.lua b/classes/datalist.lua index e78d5d5..222b600 100644 --- a/classes/datalist.lua +++ b/classes/datalist.lua @@ -3,6 +3,7 @@ local DataList = Object:extend() local ListHolder = require "classes.dataholders.listholder" local SimpleHolder = require "classes.dataholders.simpleholder" +local StatHolder = require "classes.dataholders.statholder" function RawData.fromLine(line) line = utils.removeComment(line) @@ -46,10 +47,10 @@ end function DataList.getHolder(key, value) if (value.dataType == "comp" or value.dataType == "list") then - print("list", key, value) return ListHolder(key, value) + elseif (value.dataType == "stat") then + return StatHolder(key, value) end - print("simple", key, value.dataType) return SimpleHolder(key, value) end