feat: add inbattle stats bonus

This commit is contained in:
Kazhnuz 2021-07-03 13:18:24 +02:00
parent 109ed7c9b2
commit 295f98ebd9
2 changed files with 22 additions and 1 deletions

View file

@ -70,4 +70,6 @@ createBattleStat("ppregen", 10)
CONST.ARMOR_AND_DAMAGE_RATIO = .5
CONST.BONUS = {0.75, 0.8125, 0.875, 0.9375, 1, 1.125, 1.25, 1.375, 1.5}
return CONST

View file

@ -23,6 +23,7 @@ function FighterParent:new(owner, isHero, id)
self.isDefending = false
self.action = nil
self.statsBonus = {}
end
-- LIFE handling functions
@ -163,7 +164,25 @@ function FighterParent:getNbrActionPerTurn()
end
function FighterParent:getStat(statname)
return self.abstract.stats:get(statname)
local stat = (self.abstract.stats:get(statname) * self:getStatBonusValue(statname))
print(statname, stat)
return stat
end
function FighterParent:getStatBonusValue(statname)
return STATS.BONUS[self:getStatBonus(statname) + 5]
end
function FighterParent:getStatBonus(statname)
return self.statsBonus[statname] or 0
end
function FighterParent:setStatBonus(statname, value, relative)
local statBonus = 0
if (relative) then
statBonus = self:getStatBonus(statname)
end
self.statsBonus[statname] = math.max(-4, math.min(statBonus + value, 4))
end
function FighterParent:getStats()