From 73a69a4e6c6b9f61cb09fa2b97476346609ad26d Mon Sep 17 00:00:00 2001 From: fdai7736 Date: Tue, 6 Feb 2024 21:23:59 +0100 Subject: [PATCH] add Color and Type to CardController --- .../onses/controllers/CardController.java | 30 +++++++++++++++---- .../de/hsfulda/onses/views/card.fxml | 4 +-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/hsfulda/onses/controllers/CardController.java b/src/main/java/de/hsfulda/onses/controllers/CardController.java index 1ef955e..0f9ca86 100644 --- a/src/main/java/de/hsfulda/onses/controllers/CardController.java +++ b/src/main/java/de/hsfulda/onses/controllers/CardController.java @@ -20,12 +20,32 @@ public class CardController implements Controller { @Override public Parent render() throws IOException { final Parent parent = FXMLLoader.load(Objects.requireNonNull(Main.class.getResource("views/card.fxml"))); - Pane mainPane = (Pane) parent.lookup("#cardPane"); - - mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: red")); - + final Pane mainPane = (Pane) parent.lookup("#cardPane"); final Label cardName = (Label) parent.lookup("#labelName"); - cardName.setText(this.card.getValue().name()); + + 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"); + } return parent; diff --git a/src/main/resources/de/hsfulda/onses/views/card.fxml b/src/main/resources/de/hsfulda/onses/views/card.fxml index 4d7f84d..964130d 100644 --- a/src/main/resources/de/hsfulda/onses/views/card.fxml +++ b/src/main/resources/de/hsfulda/onses/views/card.fxml @@ -7,9 +7,9 @@ -