Browse Source

fix gameOver not working

main^2
fdai7736 11 months ago
parent
commit
6ee92620cb
  1. 12
      src/main/java/de/hsfulda/onses/App.java
  2. 2
      src/main/java/de/hsfulda/onses/controllers/GameController.java
  3. 2
      src/main/java/de/hsfulda/onses/models/Game.java

12
src/main/java/de/hsfulda/onses/App.java

@ -15,10 +15,20 @@ public class App extends Application {
private Stage stage;
private Controller controller;
private final GameService gameService;
public App() {
this(new GameService());
}
public App(GameService gameService) {
this.gameService = gameService;
}
@Override
public void start(Stage stage) {
this.stage = stage;
final AppController appController = new AppController(this, new GameService());
final AppController appController = new AppController(this, this.gameService);
stage.setScene(new Scene(new Label("Loading...")));
stage.setOnCloseRequest(e -> controller.destroy());

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

@ -98,13 +98,11 @@ public class GameController implements Controller {
if(cardToPlay.getValue().equals(Card.Value.CHOOSE) || cardToPlay.getValue().equals(Card.Value.CHOOSEDRAW)) {
if(!cardToPlay.getColor().equals(Card.Color.BLACK)) {
if(cardToPlay.getPlayer() != null) {
cardToPlay.getPlayer().removeCardFromPlayerDeck(cardToPlay);
gameService.playCard(cardToPlay);
}
}
} else if(gameService.legalMove(cardToPlay)){
if(cardToPlay.getPlayer() != null) {
cardToPlay.getPlayer().removeCardFromPlayerDeck(cardToPlay);
gameService.playCard(cardToPlay);
}
}

2
src/main/java/de/hsfulda/onses/models/Game.java

@ -71,7 +71,7 @@ public class Game {
}
public void setGameOver(boolean gameOver) {
final boolean oldValue = gameOver;
final boolean oldValue = this.gameOver;
this.gameOver = gameOver;
this.firePropertyChange(PROPERTY_GAME_OVER, oldValue, gameOver);
}

Loading…
Cancel
Save