feat: system de boosts
This commit is contained in:
parent
478e6fb95b
commit
a72bdf1315
3 changed files with 48 additions and 5 deletions
30
classes/dataholders/boostholder.lua
Normal file
30
classes/dataholders/boostholder.lua
Normal file
|
@ -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
|
|
@ -8,6 +8,8 @@ local CompetenceHolder = require "classes.dataholders.competenceholder"
|
||||||
local ArmesHolder = require "classes.dataholders.armesholder"
|
local ArmesHolder = require "classes.dataholders.armesholder"
|
||||||
local ArmureHolder = require "classes.dataholders.armureholder"
|
local ArmureHolder = require "classes.dataholders.armureholder"
|
||||||
|
|
||||||
|
local BoostHolder = require "classes.dataholders.boostholder"
|
||||||
|
|
||||||
function RawData.fromLine(line)
|
function RawData.fromLine(line)
|
||||||
line = utils.removeComment(line)
|
line = utils.removeComment(line)
|
||||||
if (#line == 0) then
|
if (#line == 0) then
|
||||||
|
@ -78,6 +80,8 @@ function DataList:new(forceLevel)
|
||||||
for key, struct in pairs(commands.structs) do
|
for key, struct in pairs(commands.structs) do
|
||||||
self.holders[key] = DataList.getHolder(key, struct)
|
self.holders[key] = DataList.getHolder(key, struct)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.boosts = BoostHolder(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function DataList:addLine(line)
|
function DataList:addLine(line)
|
||||||
|
@ -88,6 +92,10 @@ function DataList:forceName(name)
|
||||||
self.forcedName = name
|
self.forcedName = name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function DataList:addToHolder(key, command, arguments)
|
||||||
|
self.holders[key]:applyCommand(command, arguments)
|
||||||
|
end
|
||||||
|
|
||||||
function DataList:reduce()
|
function DataList:reduce()
|
||||||
local level = 0
|
local level = 0
|
||||||
local mode = "creature"
|
local mode = "creature"
|
||||||
|
@ -98,6 +106,9 @@ function DataList:reduce()
|
||||||
if (rawdata.name == "mode") then
|
if (rawdata.name == "mode") then
|
||||||
mode = rawdata.arguments
|
mode = rawdata.arguments
|
||||||
end
|
end
|
||||||
|
if (rawdata.name == "boost") then
|
||||||
|
self.boosts:add(rawdata.arguments[1], rawdata.arguments[2])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,13 +117,14 @@ function DataList:reduce()
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, rawdata in ipairs(self.list) do
|
for _, rawdata in ipairs(self.list) do
|
||||||
if (rawdata:canBeUsed(level)) then
|
if (rawdata:canBeUsed(level) and rawdata.name ~= "boost" and rawdata.name ~= "halfboost") then
|
||||||
self.holders[rawdata:getKey()]:applyCommand(rawdata:getCommand(), rawdata.arguments)
|
self:addToHolder(rawdata:getKey(), rawdata:getCommand(), rawdata.arguments)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.boosts:apply()
|
||||||
|
|
||||||
for key, holder in pairs(self.holders) do
|
for key, holder in pairs(self.holders) do
|
||||||
--self.reducedList[key] = holder:reduce(level)
|
|
||||||
self:addToReducedList(key, holder:reduce(level, mode))
|
self:addToReducedList(key, holder:reduce(level, mode))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ return {
|
||||||
immunite={contentType = "list", args=1},
|
immunite={contentType = "list", args=1},
|
||||||
level={contentType = "number", default = 0, preParse = true},
|
level={contentType = "number", default = 0, preParse = true},
|
||||||
pression={contentType = "number", default = 5},
|
pression={contentType = "number", default = 5},
|
||||||
|
boost={dataType = "boost", args=2},
|
||||||
atk= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.for"},
|
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"},
|
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"},
|
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"},
|
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"},
|
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"},
|
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},
|
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=3},
|
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"},
|
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"},
|
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"},
|
armurepsy= {dataType= "armure", modulo= 1, default= 0, max=9999999, min=0, to="armure.psy"},
|
||||||
|
|
Loading…
Reference in a new issue