From 6475b63a22638e23b3e271f7fd046a139614b31c Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Sun, 6 Oct 2024 14:52:33 +0200 Subject: [PATCH] fixed incorrect remove function and corrected a mistake during the initiation of a game over state --- .../src/main/java/pp/battleship/game/client/BattleState.java | 2 +- .../model/src/main/java/pp/battleship/model/ShipMap.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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 fa8d731..99df8d0 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 @@ class BattleState extends ClientState { 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 bb73d6b..5a16278 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 @@ package pp.battleship.model; 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 class ShipMap { */ public void remove(Item item) { items.remove(item); - notifyListeners(new ItemAddedEvent(item, this)); + notifyListeners(new ItemRemovedEvent(item, this)); } /**