diff --git a/sonic-radiance.love/game/abstractmobs/parent.lua b/sonic-radiance.love/game/abstractmobs/parent.lua index 489a242..e641128 100644 --- a/sonic-radiance.love/game/abstractmobs/parent.lua +++ b/sonic-radiance.love/game/abstractmobs/parent.lua @@ -4,6 +4,7 @@ function AbstractMobParent:new() self:initBasicElements() self.stats = self:createStats() self.skills = self:createSkills() + self.statuts = {} self:initLife() end @@ -48,6 +49,9 @@ function AbstractMobParent:setHP(newHP, relative) self.hp = newHP end self.hp = math.floor(math.max(0, self.hp)) + if (self.hp == 0) then + self:die() + end end function AbstractMobParent:setPP(newPP, relative) @@ -59,14 +63,47 @@ function AbstractMobParent:setPP(newPP, relative) self.pp = math.floor(math.max(0, self.pp)) end -function AbstractMobParent:isAlive() - return (self.hp > 0) -end - function AbstractMobParent:getStats() return self.stats end +-- STATUT HANDLING + +function AbstractMobParent:addStatut(name, duration) + local duration = duration or -1 + self.statuts[name] = duration +end + +function AbstractMobParent:haveStatuts(statutName) + return (self.statuts[statutName] ~= nil) +end + +function AbstractMobParent:removeStatut(statutName) + self.statuts[statutName] = nil +end + +function AbstractMobParent:resetStatut() + self.statuts = {} +end + +function AbstractMobParent:die() + self:addStatut("ko") +end + +function AbstractMobParent:isAlive() + return (not self:haveStatuts("ko")) +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) + end + end +end + -- Bonus stuff function AbstractMobParent:setBonus(pvFactor, statFactor)