From 26836d16cce3ced62181c33a9e99adcf9817af0a Mon Sep 17 00:00:00 2001 From: Felix Koppe Date: Fri, 6 Dec 2024 09:48:24 +0100 Subject: [PATCH] Fix card select issue --- .../java/pp/mdga/client/ModelSynchronizer.java | 16 ++++++++++------ .../pp/mdga/client/NotificationSynchronizer.java | 1 + .../main/java/pp/mdga/client/view/GameView.java | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java index 429b9ade..f0b74100 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java @@ -74,10 +74,11 @@ public void selectCard(BonusCard card) { this.card = card; GameView gameView = (GameView) app.getView(); - if(card != null) { + + if(card == null) { gameView.needConfirm(); } else { - gameView.noConfirm(); + gameView.needNoPower(); } } @@ -93,14 +94,17 @@ public void confirm() { } else if (a != null) { selectPiece(a); gameView.getBoardHandler().clearSelectable(); - } else if (card != null){ - selectCard(card); - gameView.getGuiHandler().clearSelectableCards(); } else { - throw new RuntimeException("nothing to confirm"); + if(null == card) { + selectCard(null); + } else { + selectCard(card); + gameView.getGuiHandler().clearSelectableCards(); + } } gameView.noConfirm(); + gameView.needNoPower(); } public void selectTsk(Color color) { 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 64bc3545..39c8ccfd 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 @@ -164,6 +164,7 @@ private void handleGame(Notification notification) { } } else if (notification instanceof SelectableCardsNotification n) { guiHandler.setSelectableCards(n.getCards()); + gameView.needNoPower(); } else if (notification instanceof ShieldActiveNotification n) { boardHandler.shieldPiece(n.getPieceId()); } else if (notification instanceof ShieldSuppressedNotification n) { 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 21a1e788..6450defc 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 @@ -20,6 +20,8 @@ public class GameView extends MdgaView { private ButtonLeft leaveButton; private ButtonRight confirmButton; + private ButtonRight noPowerButton; + private Color ownColor = null; private InterruptDialog interruptDialog; @@ -36,6 +38,8 @@ public GameView(MdgaApp app) { confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1); + noPowerButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Keine Powercard", 1); + interruptDialog = new InterruptDialog(app, guiNode); fpp = new FilterPostProcessor(app.getAssetManager()); @@ -110,6 +114,7 @@ public Color getOwnColor() { } public void needConfirm() { + noPowerButton.hide(); confirmButton.show(); } @@ -117,6 +122,15 @@ public void noConfirm() { confirmButton.hide(); } + public void needNoPower() { + confirmButton.hide(); + noPowerButton.hide(); + } + + public void noNoPower() { + noPowerButton.show(); + } + public void enterInterrupt(Color color) { enterOverlay(Overlay.INTERRUPT);