From a53e367e01ea7f9f39f4464683fc891121acc2c9 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 13 Aug 2021 19:25:26 +0200 Subject: [PATCH] feat: prepare for more complex statuses --- .../datas/gamedata/statuses.lua | 45 +++++++++++++------ .../game/abstractmobs/parent.lua | 44 ++++++++++-------- 2 files changed, 56 insertions(+), 33 deletions(-) diff --git a/sonic-radiance.love/datas/gamedata/statuses.lua b/sonic-radiance.love/datas/gamedata/statuses.lua index 10d0b27..34dea6c 100644 --- a/sonic-radiance.love/datas/gamedata/statuses.lua +++ b/sonic-radiance.love/datas/gamedata/statuses.lua @@ -1,38 +1,55 @@ return { + ko = { + temporary = false, + replaceAll = true + }, hidden = { - {"evasion", 30}, + stats = {{"evasion", 30}}, }, focus = { - {"critical", 30}, + stats = {{"critical", 30}}, + remove = "distracted" }, shielded = { - {"armor", 20} + stats = {{"armor", 20}}, + remove = "vulnerable" }, hyper = { - {"damage", 25}, - {"critical", 20} + stats = { + {"damage", 25}, + {"critical", 20} + }, + remove = "weakened" }, lucky = { - {"evasion", 20}, - {"luck", 20}, + stats = { + {"evasion", 20}, + {"luck", 20}, + }, + remove = "cursed" }, regen = { - {"hpregen", 8} + stats = {{"hpregen", 8}} }, poison = { - {"hpregen", -15} + stats = {{"hpregen", -15}} }, weakened = { - {"damage", -20} + stats = {{"damage", -20}}, + remove = "hyper" }, vulnerable = { - {"armor", -20} + stats = {{"armor", -20}} }, cursed = { - {"evasion", 0}, - {"luck", -30} + stats = { + {"evasion", 0}, + {"luck", -30} + }, + remove = "lucky" }, distracted = { - {"accuracy", -30} + stats = {{"accuracy", -30}}, + remove = "focus" } } \ No newline at end of file diff --git a/sonic-radiance.love/game/abstractmobs/parent.lua b/sonic-radiance.love/game/abstractmobs/parent.lua index 61f2ee1..478d0e3 100644 --- a/sonic-radiance.love/game/abstractmobs/parent.lua +++ b/sonic-radiance.love/game/abstractmobs/parent.lua @@ -69,23 +69,12 @@ function AbstractMobParent:getStats() return self.stats end -function AbstractMobParent:getStatutsStat(statName) - local stat = 0 - for statut, _ in pairs(self.statuts) do - for _, statutStat in ipairs(statutStatList[statut]) do - if (statutStat[1] == statName) then - stat = stat + statutStat[2] - end - end - end - return stat -end - -- STATUT HANDLING -function AbstractMobParent:addStatut(name, duration) +function AbstractMobParent:addStatut(name, duration, source) local duration = duration or -1 - self.statuts[name] = duration + self.statuts[name] = {} + self.statuts[name].duration = duration end function AbstractMobParent:haveStatuts(statutName) @@ -109,13 +98,30 @@ function AbstractMobParent:isAlive() end function AbstractMobParent:removeOneTurnToStatut() - for name, duration in pairs(self.statuts) do - if (duration == 1) then - self.statuts[name] = nil - else - self.statuts[name] = (duration - 1) + for name, statut in pairs(self.statuts) do + if (statut ~= nil) then + if (statut.duration == 1) then + self.statuts[name] = nil + else + self.statuts[name].duration = (statut.duration - 1) + end end end end +function AbstractMobParent:getStatutsStat(statName) + local stat = 0 + for statutName, _ in pairs(self.statuts) do + local statut = statutStatList[statutName] + if (statut ~= nil) then + for _, statutStat in ipairs(statut.stats) do + if (statutStat[1] == statName) then + stat = stat + statutStat[2] + end + end + end + end + return stat +end + return AbstractMobParent