From 453aacfe1a4723d755cc2ded1fb2f7d36c6f8ab5 Mon Sep 17 00:00:00 2001 From: Cedric Beck Date: Sun, 1 Dec 2024 18:12:31 +0100 Subject: [PATCH] fixed missing messages --- .../mdga/client/NotificationSynchronizer.java | 14 +++--- .../java/pp/mdga/client/gui/GuiHandler.java | 8 ++-- .../java/pp/mdga/client/view/GameView.java | 47 ++++++++++++++----- .../mdga/client/gameState/SpectatorState.java | 2 +- .../mdga/client/gameState/WaitingState.java | 2 +- .../notification/RollDiceNotification.java | 28 +++++++---- .../SelectableShieldNotification.java | 16 +++++++ .../notification/TurboActiveNotification.java | 4 ++ 8 files changed, 86 insertions(+), 35 deletions(-) create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectableShieldNotification.java create mode 100644 Projekte/mdga/model/src/main/java/pp/mdga/notification/TurboActiveNotification.java diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java index e0314c46..3d2c674c 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java @@ -145,11 +145,11 @@ private void handleGame(Notification notification) { //TODO } else if (notification instanceof RollDiceNotification n) { if(n.getColor() == gameView.getOwnColor()){ - //guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1); + guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1); } else { - //if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor()); - //else guiHandler.showRolledDice(n.getEyes(), n.getColor()); + if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor()); + else guiHandler.showRolledDice(n.getEyes(), n.getColor()); } } else if (notification instanceof SelectableCardsNotification n) { guiHandler.setSelectableCards(n.getCards()); @@ -168,10 +168,10 @@ private void handleGame(Notification notification) { boardHandler.outlineMove(n.getPieces(), n.getMoveIndexe(), n.getHomeMoves()); } else if (notification instanceof SelectableSwapNotification n) { boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces()); - // } //else if (notification instanceof SelectableShieldNotification n) { - // boardHandler.outlineShield(n.getOwnPieces()); - //} else if (notification instanceof TurboActiveNotification){ - // guiHandler.turbo(); + } else if (notification instanceof SelectableShieldNotification n) { + boardHandler.outlineShield(n.getPieces()); + } else if (notification instanceof TurboActiveNotification){ + guiHandler.turbo(); } else { throw new RuntimeException("notification not expected: " + notification.toString()); } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/GuiHandler.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/GuiHandler.java index 8393653f..8f15fe92 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/GuiHandler.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/gui/GuiHandler.java @@ -15,11 +15,11 @@ public class GuiHandler { private final CardLayerHandler cardLayerHandler; private final PlayerNameHandler playerNameHandler; private final ActionTextHandler actionTextHandler; - private final Color ownColor; + private Color ownColor; private FrameBuffer backFrameBuffer; - public GuiHandler(MdgaApp app, Node guiNode, Color ownColor) { + public GuiHandler(MdgaApp app, Node guiNode) { this.app = app; this.ownColor = ownColor; @@ -33,8 +33,10 @@ public GuiHandler(MdgaApp app, Node guiNode, Color ownColor) { actionTextHandler = new ActionTextHandler(guiNode, app.getAssetManager(), app.getContext().getSettings()); } - public void init() { + public void init(Color ownColor) { cardLayerHandler.init(); + playerNameHandler.show(); + this.ownColor = ownColor; app.getViewPort().setOutputFrameBuffer(backFrameBuffer); } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java index a84fe762..edd74e52 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java @@ -12,11 +12,15 @@ import pp.mdga.game.BonusCard; import pp.mdga.game.Color; import pp.mdga.notification.AcquireCardNotification; +import pp.mdga.notification.ActivePlayerNotification; +import pp.mdga.notification.DiceNowNotification; import pp.mdga.notification.GameNotification; import pp.mdga.notification.MovePieceNotification; import pp.mdga.notification.PlayerInGameNotification; +import pp.mdga.notification.RollDiceNotification; import pp.mdga.notification.SelectableCardsNotification; import pp.mdga.notification.SelectableMoveNotification; +import pp.mdga.notification.ShieldActiveNotification; import java.util.ArrayList; import java.util.List; @@ -48,10 +52,23 @@ public GameView(MdgaApp app) { this.camera = new CameraHandler(app, fpp); this.boardHandler = new BoardHandler(app, rootNode, fpp); - guiHandler = new GuiHandler(app, guiNode, ownColor); + guiHandler = new GuiHandler(app, guiNode); + + } + + @Override + public void onEnter() { + camera.init(); + boardHandler.init(); + setOwnColor(Color.AIRFORCE); + guiHandler.init(ownColor); + + app.getViewPort().addProcessor(fpp); + + app.getAcousticHandler().playSound(MdgaSound.START); + //Test - setOwnColor(Color.AIRFORCE); List uuid1 = new ArrayList<>(); UUID p1 = UUID.randomUUID(); @@ -60,27 +77,31 @@ public GameView(MdgaApp app) { uuid1.add(p2); uuid1.add(UUID.randomUUID()); uuid1.add(UUID.randomUUID()); + List uuid2 = new ArrayList<>(); + UUID p1_2 = UUID.randomUUID(); + UUID p2_2 = UUID.randomUUID(); + uuid2.add(p1_2); + uuid2.add(p2_2); + uuid2.add(UUID.randomUUID()); + uuid2.add(UUID.randomUUID()); app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.AIRFORCE, uuid1, "Cedric")); + app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.NAVY, uuid2, "Test")); app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1, 0, true)); + app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1_2, 30, true)); app.getNotificationSynchronizer().addTestNotification(new SelectableMoveNotification(List.of(p1), List.of(4), List.of(false))); app.getNotificationSynchronizer().addTestNotification(new AcquireCardNotification(BonusCard.SHIELD)); app.getNotificationSynchronizer().addTestNotification(new SelectableCardsNotification(List.of(BonusCard.SHIELD))); + app.getNotificationSynchronizer().addTestNotification(new ShieldActiveNotification(p1)); + app.getNotificationSynchronizer().addTestNotification(new ActivePlayerNotification(Color.NAVY)); + +// app.getNotificationSynchronizer().addTestNotification(new DiceNowNotification()); +// app.getNotificationSynchronizer().addTestNotification(new RollDiceNotification(Color.AIRFORCE, 5, true, 2)); - } - - @Override - public void onEnter() { - camera.init(); - boardHandler.init(); - guiHandler.init(); - - app.getViewPort().addProcessor(fpp); - - app.getAcousticHandler().playSound(MdgaSound.START); + p1 = p1; } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/SpectatorState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/SpectatorState.java index 13680223..9a0cbd7d 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/SpectatorState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/SpectatorState.java @@ -34,7 +34,7 @@ public void received(CeremonyMessage msg){ @Override public void received(DieMessage msg){ logic.getGame().setDiceEyes(msg.getDiceEye()); - logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); +// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); if(msg.getDiceEye() == 6){ logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6(); logic.getGame().getGameStatistics().increaseDiced6(); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/WaitingState.java b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/WaitingState.java index 69d8299c..0a2f72b0 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/WaitingState.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/client/gameState/WaitingState.java @@ -40,7 +40,7 @@ public void received(DiceNowMessage msg){ @Override public void received(DieMessage msg){ logic.getGame().setDiceEyes(msg.getDiceEye()); - logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); +// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); if(msg.getDiceEye() == 6){ logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6(); logic.getGame().getGameStatistics().increaseDiced6(); diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/notification/RollDiceNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/RollDiceNotification.java index 3f778d3f..13bf849b 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/notification/RollDiceNotification.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/RollDiceNotification.java @@ -9,18 +9,26 @@ public class RollDiceNotification extends Notification{ private Color color; private int eyes; - private int moveNumber; + private boolean turbo; + private int multiplier; /** * Constructor. * @param color the color of the player that rolled the die. * @param eyes the number of eyes that were rolled. - * @param moveNumber the number of the move that was made. */ - public RollDiceNotification(Color color, int eyes, int moveNumber) { + public RollDiceNotification(Color color, int eyes) { this.color = color; this.eyes = eyes; - this.moveNumber = moveNumber; + this.turbo = false; + this.multiplier = -1; + } + + public RollDiceNotification(Color color, int eyes, boolean turbo, int multiplier) { + this.color = color; + this.eyes = eyes; + this.turbo = turbo; + this.multiplier = multiplier; } /** @@ -39,11 +47,11 @@ public int getEyes() { return eyes; } - /** - * Get the number of the move that was made. - * @return the number of the move that was made. - */ - public int getMoveNumber() { - return moveNumber; + public int getMultiplier() { + return multiplier; + } + + public boolean isTurbo() { + return turbo; } } diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectableShieldNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectableShieldNotification.java new file mode 100644 index 00000000..f0a9982d --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/SelectableShieldNotification.java @@ -0,0 +1,16 @@ +package pp.mdga.notification; + +import java.util.List; +import java.util.UUID; + +public class SelectableShieldNotification extends Notification{ + private List pieces; + + public SelectableShieldNotification(List pieces){ + this.pieces = pieces; + } + + public List getPieces() { + return pieces; + } +} diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/notification/TurboActiveNotification.java b/Projekte/mdga/model/src/main/java/pp/mdga/notification/TurboActiveNotification.java new file mode 100644 index 00000000..890f2451 --- /dev/null +++ b/Projekte/mdga/model/src/main/java/pp/mdga/notification/TurboActiveNotification.java @@ -0,0 +1,4 @@ +package pp.mdga.notification; + +public class TurboActiveNotification extends Notification{ +}