From 1f3eab3dde108d0239a7776480009e2974851107 Mon Sep 17 00:00:00 2001 From: fdai7736 Date: Thu, 8 Feb 2024 12:15:28 +0100 Subject: [PATCH] refactoring: fix play card --- .../de/hsfulda/onses/controllers/GameController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hsfulda/onses/controllers/GameController.java b/src/main/java/de/hsfulda/onses/controllers/GameController.java index 70cc61b..0abedb7 100644 --- a/src/main/java/de/hsfulda/onses/controllers/GameController.java +++ b/src/main/java/de/hsfulda/onses/controllers/GameController.java @@ -41,7 +41,14 @@ public class GameController implements Controller { }); playButton.setOnAction(e -> { - gameService.playCard(new Card().setColor(Card.Color.GREEN).setValue(Card.Value.ONE)); + Card cardToPlay = game.getPlayerService().getPlayerList().getFirst().getCurrentCard(); + if(gameService.legalMove(cardToPlay)) { + System.out.println(cardToPlay.getPlayer()); + if(cardToPlay.getPlayer() != null) { + cardToPlay.getPlayer().removeCardFromPlayerDeck(cardToPlay); + gameService.playCard(cardToPlay); + } + } });