From 6ee92620cb7fd93f08b9cbbcc2c1ffcbad7204b8 Mon Sep 17 00:00:00 2001
From: fdai7736 <yannis.liebermann@informatik.hs-fulda.de>
Date: Thu, 8 Feb 2024 23:37:03 +0100
Subject: [PATCH] fix gameOver not working

---
 src/main/java/de/hsfulda/onses/App.java              | 12 +++++++++++-
 .../de/hsfulda/onses/controllers/GameController.java |  2 --
 src/main/java/de/hsfulda/onses/models/Game.java      |  2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)

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);
     }