diff --git a/src/main/java/de/hsfulda/onses/controllers/PlayerController.java b/src/main/java/de/hsfulda/onses/controllers/PlayerController.java index 72497b8..1757520 100644 --- a/src/main/java/de/hsfulda/onses/controllers/PlayerController.java +++ b/src/main/java/de/hsfulda/onses/controllers/PlayerController.java @@ -1,12 +1,15 @@ package de.hsfulda.onses.controllers; import de.hsfulda.onses.Main; +import de.hsfulda.onses.models.Card; import de.hsfulda.onses.models.Player; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.control.Label; +import javafx.scene.layout.HBox; import java.io.IOException; +import java.util.ArrayList; import java.util.Objects; public class PlayerController implements Controller { @@ -20,6 +23,22 @@ public class PlayerController implements Controller { public Parent render() throws IOException { final Parent parent = FXMLLoader.load(Objects.requireNonNull(Main.class.getResource("views/player.fxml"))); final Label playerNameLabel = (Label) parent.lookup("#playerNameLabel"); + final HBox cards = (HBox) parent.lookup("#cardsHBox"); + + for(Card card : player.getPlayerDeck()) { + cards.getChildren().add(new CardController(card).render()); + } + + player.listeners().addPropertyChangeListener(Player.PROPERTY_PLAYER_DECK, e -> { + cards.getChildren().clear(); + for(Card card : player.getPlayerDeck()) { + try { + cards.getChildren().add(new CardController(card).render()); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + }); playerNameLabel.setText("Test");