From d7dfa4a2e39261458a711a1e6f4e06c24933b8b6 Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Wed, 24 Jan 2024 14:36:16 +0100 Subject: [PATCH] add allowedMove --- .../java/de/hsfulda/onses/services/GameService.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hsfulda/onses/services/GameService.java b/src/main/java/de/hsfulda/onses/services/GameService.java index b50422a..3edca44 100644 --- a/src/main/java/de/hsfulda/onses/services/GameService.java +++ b/src/main/java/de/hsfulda/onses/services/GameService.java @@ -20,9 +20,18 @@ public class GameService { public void playCard(Player player, Card card) { // add lastPlayedCard back to drawCardDeck - game.setLastPlayedCard(card); + game.setLastPlayedCard(card); // check for special rules (draw, colorchoose, skip,...) + } + + public boolean allowedMove(Player player, Card card) + { + boolean isAllowed = false; + Card lastCard = game.getLastPlayedCard(); + // rules: + if (card.getColor() == lastCard.getColor()) isAllowed = true; // same color + return isAllowed; } }