feat: initial statuse system
This commit is contained in:
parent
ef788afd70
commit
69d296b2f7
1 changed files with 41 additions and 4 deletions
|
@ -4,6 +4,7 @@ function AbstractMobParent:new()
|
||||||
self:initBasicElements()
|
self:initBasicElements()
|
||||||
self.stats = self:createStats()
|
self.stats = self:createStats()
|
||||||
self.skills = self:createSkills()
|
self.skills = self:createSkills()
|
||||||
|
self.statuts = {}
|
||||||
self:initLife()
|
self:initLife()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,6 +49,9 @@ function AbstractMobParent:setHP(newHP, relative)
|
||||||
self.hp = newHP
|
self.hp = newHP
|
||||||
end
|
end
|
||||||
self.hp = math.floor(math.max(0, self.hp))
|
self.hp = math.floor(math.max(0, self.hp))
|
||||||
|
if (self.hp == 0) then
|
||||||
|
self:die()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function AbstractMobParent:setPP(newPP, relative)
|
function AbstractMobParent:setPP(newPP, relative)
|
||||||
|
@ -59,14 +63,47 @@ function AbstractMobParent:setPP(newPP, relative)
|
||||||
self.pp = math.floor(math.max(0, self.pp))
|
self.pp = math.floor(math.max(0, self.pp))
|
||||||
end
|
end
|
||||||
|
|
||||||
function AbstractMobParent:isAlive()
|
|
||||||
return (self.hp > 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
function AbstractMobParent:getStats()
|
function AbstractMobParent:getStats()
|
||||||
return self.stats
|
return self.stats
|
||||||
end
|
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
|
-- Bonus stuff
|
||||||
|
|
||||||
function AbstractMobParent:setBonus(pvFactor, statFactor)
|
function AbstractMobParent:setBonus(pvFactor, statFactor)
|
||||||
|
|
Loading…
Reference in a new issue