2020-07-19 15:07:35 +02:00
|
|
|
local FighterParent = Object:extend()
|
|
|
|
|
|
|
|
local counter = 0
|
|
|
|
|
|
|
|
function FighterParent:new(owner, isHero, id)
|
|
|
|
self.owner = owner
|
|
|
|
self.turnSystem = owner.turnSystem
|
|
|
|
self.world = owner.world
|
|
|
|
self.isHero = isHero
|
2020-07-19 16:20:57 +02:00
|
|
|
self.assets = self.turnSystem.scene.assets
|
2020-07-19 15:07:35 +02:00
|
|
|
|
|
|
|
-- Note : l'ID est ici relatif à chaque quand, il n'est donc pas unique,
|
|
|
|
-- ce qui est unique étant le combo id + isHero
|
|
|
|
self.id = id
|
|
|
|
|
|
|
|
self.abstract = self:getAbstract()
|
|
|
|
self.actor = self:createActor()
|
|
|
|
|
|
|
|
self.isActive = false
|
2020-07-24 19:49:24 +02:00
|
|
|
self.isAlive = true
|
|
|
|
end
|
|
|
|
|
|
|
|
-- LIFE handling functions
|
|
|
|
|
|
|
|
function FighterParent:setHP(value, relative)
|
|
|
|
self.abstract:setHP(value, relative)
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:setPP(value, relative)
|
|
|
|
self.abstract:setPP(value, relative)
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:applyDeath()
|
|
|
|
if (self.hp <= 0 and self.isAlive) then
|
|
|
|
self:die()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:die()
|
|
|
|
self.isAlive = false
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:getAbstract()
|
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:createActor()
|
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:update(dt)
|
|
|
|
counter = counter + dt
|
2020-07-19 21:46:17 +02:00
|
|
|
if (counter > 1) then
|
2020-07-19 15:07:35 +02:00
|
|
|
counter = 0
|
|
|
|
self:setInactive()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
function FighterParent:updateAssets(dt)
|
|
|
|
-- Vide pour l'instant
|
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
function FighterParent:setActive()
|
|
|
|
counter = 0
|
|
|
|
self.isActive = true
|
|
|
|
self:startAction()
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:setInactive()
|
|
|
|
self.isActive = false
|
2020-07-19 18:09:53 +02:00
|
|
|
self.turnSystem:endAction()
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:getNbrActionPerTurn()
|
|
|
|
return self.abstract.turns
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:getStats()
|
|
|
|
return self.abstract:getStats()
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:startAction()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:getUniqueIdentificator()
|
|
|
|
local side = 1
|
|
|
|
if (isHero == false) then
|
|
|
|
side = -1
|
|
|
|
end
|
|
|
|
return self.id * side
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:getNonUniqueIdentificator()
|
|
|
|
return self.id
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterParent:canFight()
|
2020-07-24 19:49:24 +02:00
|
|
|
return self.isAlive
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
-- DRAW FUNCTIONS
|
|
|
|
|
|
|
|
function FighterParent:drawIcon(x, y)
|
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
love.graphics.rectangle("fill", x, y, 16, 16)
|
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
return FighterParent
|