From 9b39a8f99f336cf4e414ae6a0af423abc70f7aae Mon Sep 17 00:00:00 2001 From: fdai7736 Date: Wed, 7 Feb 2024 20:52:13 +0100 Subject: [PATCH] show cards face down if the player is enemy --- .../onses/controllers/CardController.java | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/main/java/de/hsfulda/onses/controllers/CardController.java b/src/main/java/de/hsfulda/onses/controllers/CardController.java index 0f9ca86..eeffa39 100644 --- a/src/main/java/de/hsfulda/onses/controllers/CardController.java +++ b/src/main/java/de/hsfulda/onses/controllers/CardController.java @@ -23,28 +23,34 @@ public class CardController implements Controller { final Pane mainPane = (Pane) parent.lookup("#cardPane"); final Label cardName = (Label) parent.lookup("#labelName"); - switch(card.getColor()) { - case RED -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: red")); - case BLUE -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: blue")); - case GREEN -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: green")); - case YELLOW -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: yellow")); - default -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: black")); + if(!card.isFacedown()) { + switch(card.getColor()) { + case RED -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: red")); + case BLUE -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: blue")); + case GREEN -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: green")); + case YELLOW -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: yellow")); + default -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: black")); + } } - switch(card.getValue()) { - case ONE -> cardName.setText("1"); - case TWO -> cardName.setText("2"); - case THREE -> cardName.setText("3"); - case FOUR -> cardName.setText("4"); - case FIVE -> cardName.setText("5"); - case SIX -> cardName.setText("6"); - case SEVEN -> cardName.setText("7"); - case EIGHT -> cardName.setText("8"); - case NINE -> cardName.setText("9"); - case SKIP -> cardName.setText("skip player"); - case CHOOSE -> cardName.setText("wish card"); - case DRAWTWO -> cardName.setText("+2"); - case REVERSE -> cardName.setText("reverse"); + if(card.isFacedown()) { + cardName.setText("Card"); + } else { + switch(card.getValue()) { + case ONE -> cardName.setText("1"); + case TWO -> cardName.setText("2"); + case THREE -> cardName.setText("3"); + case FOUR -> cardName.setText("4"); + case FIVE -> cardName.setText("5"); + case SIX -> cardName.setText("6"); + case SEVEN -> cardName.setText("7"); + case EIGHT -> cardName.setText("8"); + case NINE -> cardName.setText("9"); + case SKIP -> cardName.setText("skip player"); + case CHOOSE -> cardName.setText("wish card"); + case DRAWTWO -> cardName.setText("+2"); + case REVERSE -> cardName.setText("reverse"); + } }