diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/init.lua index 0455c1d..b36a0e0 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/init.lua @@ -82,6 +82,14 @@ function TurnController:calculateTurn() table.sort(self.actionList, maputils.sortBattlers) end +function TurnController:removeAllActionsFromFighter(fighterToRemove) + for i, action in ipairs(self.actionlist) do + if action.fighter == fighterToRemove then + table.remove(self.actionlist, i) + end + end +end + function TurnController:startAction() core.debug:print("cbs/turns", "Starting action " .. self.turns.current) local nextAction = self.actionList[self.turns.current] diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua b/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua index 5bdf754..de032d3 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua @@ -48,5 +48,18 @@ function FighterControllerParent:draw() --Aucun dessin par defaut, ils sont géré différements end +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 + + return FighterControllerParent