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"); final Button playButton = (Button) parent.lookup("#playCardBtn");
CardController lastPlayedCardController = new CardController(new Card().setValue(Card.Value.FIVE).setColor(Card.Color.BLUE)); 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 -> { game.listeners().addPropertyChangeListener(Game.PROPERTY_LAST_PLAYED_CARD, e -> {
lastPlayedCardPane.getChildren().removeAll(); lastPlayedCardPane.getChildren().removeAll();

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

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

Loading…
Cancel
Save