From 295f98ebd930dd34beff5566a81f0108e40e84d9 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 3 Jul 2021 13:18:24 +0200 Subject: [PATCH] feat: add inbattle stats bonus --- sonic-radiance.love/datas/consts/stats.lua | 2 ++ .../controllers/fighters/parent.lua | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sonic-radiance.love/datas/consts/stats.lua b/sonic-radiance.love/datas/consts/stats.lua index a29d184..201455c 100644 --- a/sonic-radiance.love/datas/consts/stats.lua +++ b/sonic-radiance.love/datas/consts/stats.lua @@ -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 diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua index b0effe7..6874027 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua @@ -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()