From bac78b56ffd7a2d53ee9cf722108b74716f453f5 Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Thu, 25 Jan 2024 19:39:48 +0100 Subject: [PATCH] Refactoring: change Name of allowedMove --- .../java/de/hsfulda/onses/services/GameService.java | 8 ++++---- src/test/java/de/hsfulda/onses/GameServiceTest.java | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/hsfulda/onses/services/GameService.java b/src/main/java/de/hsfulda/onses/services/GameService.java index 3edca44..bdee4d5 100644 --- a/src/main/java/de/hsfulda/onses/services/GameService.java +++ b/src/main/java/de/hsfulda/onses/services/GameService.java @@ -24,14 +24,14 @@ public class GameService { // check for special rules (draw, colorchoose, skip,...) } - public boolean allowedMove(Player player, Card card) + public boolean legalMove(Player player, Card card) { - boolean isAllowed = false; + boolean legalMoveFound = false; Card lastCard = game.getLastPlayedCard(); // rules: - if (card.getColor() == lastCard.getColor()) isAllowed = true; // same color + if (card.getColor() == lastCard.getColor()) legalMoveFound = true; // same color - return isAllowed; + return legalMoveFound; } } diff --git a/src/test/java/de/hsfulda/onses/GameServiceTest.java b/src/test/java/de/hsfulda/onses/GameServiceTest.java index 97cba48..8a22108 100644 --- a/src/test/java/de/hsfulda/onses/GameServiceTest.java +++ b/src/test/java/de/hsfulda/onses/GameServiceTest.java @@ -7,7 +7,6 @@ import static org.junit.jupiter.api.Assertions.*; import de.hsfulda.onses.models.Card; import de.hsfulda.onses.models.Player; -import de.hsfulda.onses.models.Game; import de.hsfulda.onses.services.GameService; public class GameServiceTest { @@ -37,8 +36,8 @@ public class GameServiceTest { } @Test - @DisplayName("allowedMoveSameColorRed") - public void allowedMoveSameColorRed() { + @DisplayName("legalMoveSameColorRed") + public void legalMoveSameColorRed() { // arrange Card input = new Card().setColor(Card.Color.RED).setValue(Card.Value.TWO); boolean expected = true; @@ -46,13 +45,13 @@ public class GameServiceTest { GameService gameService = new GameService(); gameService.getGame().setLastPlayedCard(new Card().setColor(Card.Color.RED).setValue(Card.Value.FIVE)); - boolean answer = gameService.allowedMove(new Player(), input); + boolean answer = gameService.legalMove(new Player(), input); // assert assertEquals(expected, answer); } @Test - @DisplayName("allowedMoveSameColorBlue") - public void allowedMoveSameColorBlue() { + @DisplayName("legalMoveSameColorBlue") + public void legalMoveSameColorBlue() { // arrange Card input = new Card().setColor(Card.Color.BLUE).setValue(Card.Value.THREE); boolean expected = true; @@ -60,7 +59,7 @@ public class GameServiceTest { GameService gameService = new GameService(); gameService.getGame().setLastPlayedCard(new Card().setColor(Card.Color.BLUE).setValue(Card.Value.ONE)); - boolean answer = gameService.allowedMove(new Player(), input); + boolean answer = gameService.legalMove(new Player(), input); // assert assertEquals(expected, answer); }