diff --git a/src/main/java/de/hsfulda/onses/App.java b/src/main/java/de/hsfulda/onses/App.java index 8a7436f..d57e6e6 100644 --- a/src/main/java/de/hsfulda/onses/App.java +++ b/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()); diff --git a/src/main/java/de/hsfulda/onses/controllers/GameController.java b/src/main/java/de/hsfulda/onses/controllers/GameController.java index 3246d95..45d0e47 100644 --- a/src/main/java/de/hsfulda/onses/controllers/GameController.java +++ b/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); } } diff --git a/src/main/java/de/hsfulda/onses/models/Game.java b/src/main/java/de/hsfulda/onses/models/Game.java index 1b14ddd..343de38 100644 --- a/src/main/java/de/hsfulda/onses/models/Game.java +++ b/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); }