Browse Source

add Player to constructor for info for the player

main
fdai7736 11 months ago
parent
commit
a91db3b2c3
  1. 4
      src/main/java/de/hsfulda/onses/controllers/GameController.java
  2. 11
      src/main/java/de/hsfulda/onses/controllers/PlayerController.java

4
src/main/java/de/hsfulda/onses/controllers/GameController.java

@ -28,8 +28,8 @@ public class GameController implements Controller {
final Button playButton = (Button) parent.lookup("#playCardBtn");
CardController lastPlayedCardController = new CardController(new Card().setValue(Card.Value.FIVE).setColor(Card.Color.BLUE));
PlayerController playerController = new PlayerController();
PlayerController enemyController = new PlayerController();
PlayerController playerController = new PlayerController(gameService.getGame().getPlayerService().getPlayerList().getFirst());
PlayerController enemyController = new PlayerController(gameService.getGame().getPlayerService().getPlayerList().getLast());
game.listeners().addPropertyChangeListener(Game.PROPERTY_LAST_PLAYED_CARD, e -> {
lastPlayedCardPane.getChildren().removeAll();

11
src/main/java/de/hsfulda/onses/controllers/PlayerController.java

@ -1,16 +1,27 @@
package de.hsfulda.onses.controllers;
import de.hsfulda.onses.Main;
import de.hsfulda.onses.models.Player;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import java.io.IOException;
import java.util.Objects;
public class PlayerController implements Controller {
private final Player player;
public PlayerController(Player player) {
this.player = player;
}
@Override
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");
playerNameLabel.setText("Test");
return parent;
}

Loading…
Cancel
Save