2020-07-19 15:07:35 +02:00
|
|
|
local FighterControllerParent = Object:extend()
|
2020-07-18 09:51:02 +02:00
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
function FighterControllerParent:new(turnSystem)
|
|
|
|
self.turnSystem = turnSystem
|
|
|
|
self.world = turnSystem.world
|
|
|
|
self.list = {}
|
2020-07-18 09:51:02 +02:00
|
|
|
end
|
|
|
|
|
2020-07-19 21:41:14 +02:00
|
|
|
function FighterControllerParent:get(id)
|
|
|
|
return self.list[id]
|
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
function FighterControllerParent:add(fighter)
|
|
|
|
table.insert(self.list, fighter)
|
|
|
|
end
|
|
|
|
|
|
|
|
function FighterControllerParent:count()
|
|
|
|
return #self.list
|
|
|
|
end
|
|
|
|
|
2020-07-25 08:44:03 +02:00
|
|
|
function FighterControllerParent:applyDeath()
|
|
|
|
for i, fighter in ipairs(self.list) do
|
|
|
|
fighter:applyDeath()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
function FighterControllerParent:setActive(activeActor)
|
2020-07-18 09:51:02 +02:00
|
|
|
self.activeActor = activeActor
|
|
|
|
activeActor:setActive()
|
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
function FighterControllerParent:update(dt)
|
2020-07-19 16:20:57 +02:00
|
|
|
for i, fighter in ipairs(self.list) do
|
|
|
|
fighter:updateAssets(dt)
|
|
|
|
end
|
2020-07-18 09:51:02 +02:00
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
function FighterControllerParent:endAction()
|
2020-07-18 09:51:02 +02:00
|
|
|
self.owner:nextAction()
|
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
function FighterControllerParent:putActions(actionList)
|
|
|
|
for i, fighter in ipairs(self.list) do
|
|
|
|
|
|
|
|
if fighter:canFight() then
|
|
|
|
for i=1, fighter:getNbrActionPerTurn() do
|
|
|
|
local action = {}
|
|
|
|
action.fighter = fighter
|
|
|
|
action.number = i
|
|
|
|
table.insert(actionList, action)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
function FighterControllerParent:draw()
|
|
|
|
--Aucun dessin par defaut, ils sont géré différements
|
|
|
|
end
|
|
|
|
|
2020-07-19 16:57:58 +02:00
|
|
|
function FighterControllerParent:removeFighter(fighterToRemove)
|
|
|
|
-- remove the actor from the battler liste
|
|
|
|
for i, fighter in ipairs(self.list) do
|
|
|
|
if fighter == fighterToRemove then
|
|
|
|
table.remove(self.list, i)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Also remove all actions related to the actor
|
|
|
|
self.turnSystem:removeAllActionsFromFighter(fighterToRemove)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
|
|
|
|
return FighterControllerParent
|