From 93ade342820dddc5de748e9e9deb746f5fb77b51 Mon Sep 17 00:00:00 2001 From: Lukas Bauer <157071544+Heady045@users.noreply.github.com> Date: Wed, 2 Oct 2024 00:31:40 +0200 Subject: [PATCH] =?UTF-8?q?Aufgabe=207.=20fix:=20in=20class=20ShipMap=20fu?= =?UTF-8?q?nction=20remove=20hierbei=20wurde=20nach=20dem=20entfernen=20ei?= =?UTF-8?q?nes=20Items=20dass=20Event=20ItemAddedEvent=20ausgel=C3=B6st=20?= =?UTF-8?q?hierbei=20sollte=20aber=20logischerwei=C3=9Fe=20dass=20Event=20?= =?UTF-8?q?ItemRemovedEvent=20ausgel=C3=B6st=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: in class BattleState function receivedEffect hierbei wurde die eigene map für die Bedingung isGameOver verglichen wobei man für isGameOver die OpponentMap auf remainingShips untersuchen muss. --- Projekte/.run/BattleshipApp.run.xml | 19 ++++++++++--------- .../battleship/game/client/BattleState.java | 2 +- .../java/pp/battleship/model/ShipMap.java | 3 ++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Projekte/.run/BattleshipApp.run.xml b/Projekte/.run/BattleshipApp.run.xml index 49eecb28..66457cd2 100644 --- a/Projekte/.run/BattleshipApp.run.xml +++ b/Projekte/.run/BattleshipApp.run.xml @@ -1,18 +1,19 @@ - - \ No newline at end of file diff --git a/Projekte/battleship/model/src/main/java/pp/battleship/game/client/BattleState.java b/Projekte/battleship/model/src/main/java/pp/battleship/game/client/BattleState.java index fa8d731d..99df8d0b 100644 --- a/Projekte/battleship/model/src/main/java/pp/battleship/game/client/BattleState.java +++ b/Projekte/battleship/model/src/main/java/pp/battleship/game/client/BattleState.java @@ -60,7 +60,7 @@ public void receivedEffect(EffectMessage msg) { if (destroyedOpponentShip(msg)) logic.getOpponentMap().add(msg.getDestroyedShip()); if (msg.isGameOver()) { - msg.getRemainingOpponentShips().forEach(logic.getOwnMap()::add); + msg.getRemainingOpponentShips().forEach(logic.getOpponentMap()::add); logic.setState(new GameOverState(logic)); } } diff --git a/Projekte/battleship/model/src/main/java/pp/battleship/model/ShipMap.java b/Projekte/battleship/model/src/main/java/pp/battleship/model/ShipMap.java index bb73d6b0..5a162785 100644 --- a/Projekte/battleship/model/src/main/java/pp/battleship/model/ShipMap.java +++ b/Projekte/battleship/model/src/main/java/pp/battleship/model/ShipMap.java @@ -10,6 +10,7 @@ import pp.battleship.notification.GameEvent; import pp.battleship.notification.GameEventBroker; import pp.battleship.notification.ItemAddedEvent; +import pp.battleship.notification.ItemRemovedEvent; import java.util.ArrayList; import java.util.Collections; @@ -97,7 +98,7 @@ public void add(Shot shot) { */ public void remove(Item item) { items.remove(item); - notifyListeners(new ItemAddedEvent(item, this)); + notifyListeners(new ItemRemovedEvent(item, this)); } /**