From 5e1ee752ac0f64e1b1e49f7223600e4495e555e4 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jul 2020 16:57:58 +0200 Subject: [PATCH] fix: readd fighter removal --- .../scenes/battlesystem/controllers/init.lua | 8 ++++++++ .../scenes/battlesystem/controllers/parent.lua | 13 +++++++++++++ 2 files changed, 21 insertions(+) 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