sonic-radiance/sonic-radiance.love/game/abstractmobs/parent.lua
2020-07-24 19:49:24 +02:00

68 lines
1.2 KiB
Lua

local AbstractMobParent = Object:extend()
function AbstractMobParent:new()
self:initBasicElements()
self.stats = self:createStats()
self.skills = self:createSkills()
self:initLife()
end
function AbstractMobParent:initBasicElements()
self.name = "PlaceHolder"
self.fullname = "PlaceHolder"
self.turns = 2
end
function AbstractMobParent:createStats()
local stats = {}
stats.hpmax = 0
stats.ppmax = 0
stats.attack = 0
stats.power = 0
stats.defense = 0
stats.technic = 0
stats.mind = 0
stats.speed = 0
return stats
end
function AbstractMobParent:createSkills()
return {}
end
-- LIFE FUNCTIONS
-- Handle HP and stuff like that
function AbstractMobParent:initLife()
self.hp = self.stats.hpmax
self.pp = self.stats.ppmax
self.status = 0
end
function AbstractMobParent:setHP(newHP, relative)
if (relative) then
self.hp = self.hp + newHP
else
self.hp = newHP
end
end
function AbstractMobParent:setPP(newPP, relative)
if (relative) then
self.pp = self.pp + newPP
else
self.pp = newPP
end
end
function AbstractMobParent:isAlive()
return (self.hp > 0)
end
function AbstractMobParent:getStats()
return self.stats
end
return AbstractMobParent