diff --git a/classes/dataholders/boostholder.lua b/classes/dataholders/boostholder.lua new file mode 100644 index 0000000..dabf86d --- /dev/null +++ b/classes/dataholders/boostholder.lua @@ -0,0 +1,30 @@ +local BoostHolder = Object:extend() + +function BoostHolder:new(list) + self.parent = list + self.table = {} +end + +function BoostHolder:add(name, val) + if (self.table[name] == nil) then + self.table[name] = val + else + self.table[name] = self.table[name] + val + end +end + +function BoostHolder:getValue(name, val) + if (name == "pv" or name == "pe") then + return val * 3 + else + return val * 5 + end +end + +function BoostHolder:apply() + for key, value in pairs(self.table) do + self.parent:addToHolder(key, "lvl", self:getValue(key, value)) + end +end + +return BoostHolder \ No newline at end of file diff --git a/classes/datalist.lua b/classes/datalist.lua index a95b2dc..bb0057b 100644 --- a/classes/datalist.lua +++ b/classes/datalist.lua @@ -8,6 +8,8 @@ local CompetenceHolder = require "classes.dataholders.competenceholder" local ArmesHolder = require "classes.dataholders.armesholder" local ArmureHolder = require "classes.dataholders.armureholder" +local BoostHolder = require "classes.dataholders.boostholder" + function RawData.fromLine(line) line = utils.removeComment(line) if (#line == 0) then @@ -78,6 +80,8 @@ function DataList:new(forceLevel) for key, struct in pairs(commands.structs) do self.holders[key] = DataList.getHolder(key, struct) end + + self.boosts = BoostHolder(self) end function DataList:addLine(line) @@ -88,6 +92,10 @@ function DataList:forceName(name) self.forcedName = name end +function DataList:addToHolder(key, command, arguments) + self.holders[key]:applyCommand(command, arguments) +end + function DataList:reduce() local level = 0 local mode = "creature" @@ -98,6 +106,9 @@ function DataList:reduce() if (rawdata.name == "mode") then mode = rawdata.arguments end + if (rawdata.name == "boost") then + self.boosts:add(rawdata.arguments[1], rawdata.arguments[2]) + end end @@ -106,13 +117,14 @@ function DataList:reduce() end for _, rawdata in ipairs(self.list) do - if (rawdata:canBeUsed(level)) then - self.holders[rawdata:getKey()]:applyCommand(rawdata:getCommand(), rawdata.arguments) + if (rawdata:canBeUsed(level) and rawdata.name ~= "boost" and rawdata.name ~= "halfboost") then + self:addToHolder(rawdata:getKey(), rawdata:getCommand(), rawdata.arguments) end end + self.boosts:apply() + for key, holder in pairs(self.holders) do - --self.reducedList[key] = holder:reduce(level) self:addToReducedList(key, holder:reduce(level, mode)) end diff --git a/struct.lua b/struct.lua index 2de9a26..aeafab2 100644 --- a/struct.lua +++ b/struct.lua @@ -8,6 +8,7 @@ return { immunite={contentType = "list", args=1}, level={contentType = "number", default = 0, preParse = true}, pression={contentType = "number", default = 5}, + boost={dataType = "boost", args=2}, atk= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.for"}, con= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.con"}, hab= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.hab"}, @@ -18,8 +19,8 @@ return { dis= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.dis"}, rel= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.rel"}, per= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.per"}, - pv= {dataType= "stat", modulo= 1, default= 12, max=9999999, min=1, to="vita.pv", lvl=3}, - pe= {dataType= "stat", modulo= 1, default= 12, max=9999999, min=1, to="vita.pe", lvl=3}, + pv= {dataType= "stat", modulo= 1, default= 12, max=9999999, min=1, to="vita.pv", lvl=1}, + pe= {dataType= "stat", modulo= 1, default= 12, max=9999999, min=1, to="vita.pe", lvl=1}, eclat= {dataType= "stat", modulo= 1, default= 10, max=200, min=1, to="vita.eclat"}, armurephy= {dataType= "armure", modulo= 1, default= 0, max=9999999, min=0, to="armure.phy"}, armurepsy= {dataType= "armure", modulo= 1, default= 0, max=9999999, min=0, to="armure.psy"},