sonic-radiance/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua

47 lines
947 B
Lua
Raw Normal View History

local FighterControllerParent = Object:extend()
2020-07-18 09:51:02 +02:00
function FighterControllerParent:new(turnSystem)
self.turnSystem = turnSystem
self.world = turnSystem.world
self.list = {}
2020-07-18 09:51:02 +02:00
end
function FighterControllerParent:add(fighter)
table.insert(self.list, fighter)
end
function FighterControllerParent:count()
return #self.list
end
function FighterControllerParent:setActive(activeActor)
2020-07-18 09:51:02 +02:00
self.activeActor = activeActor
activeActor:setActive()
end
function FighterControllerParent:update(dt)
2020-07-18 09:51:02 +02:00
end
function FighterControllerParent:endAction()
2020-07-18 09:51:02 +02:00
self.owner:nextAction()
end
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
return FighterControllerParent