From cf6f5207a41b7baabf79c4679d7d1d7cac982653 Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Wed, 31 Jan 2024 14:23:10 +0100 Subject: [PATCH 1/6] add legalMove-SameValue --- src/main/java/de/hsfulda/onses/services/GameService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/de/hsfulda/onses/services/GameService.java b/src/main/java/de/hsfulda/onses/services/GameService.java index bdee4d5..1cac834 100644 --- a/src/main/java/de/hsfulda/onses/services/GameService.java +++ b/src/main/java/de/hsfulda/onses/services/GameService.java @@ -31,6 +31,8 @@ public class GameService { // rules: if (card.getColor() == lastCard.getColor()) legalMoveFound = true; // same color + if (card.getValue() == lastCard.getValue()) legalMoveFound = true; // same value + return legalMoveFound; } From 6660d94a147f1f229882bd42d216e38c52a9a3a4 Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Wed, 31 Jan 2024 14:28:26 +0100 Subject: [PATCH 2/6] Test.legalMoveSameValueOne --- .../java/de/hsfulda/onses/GameServiceTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/de/hsfulda/onses/GameServiceTest.java b/src/test/java/de/hsfulda/onses/GameServiceTest.java index 8a22108..f3190a1 100644 --- a/src/test/java/de/hsfulda/onses/GameServiceTest.java +++ b/src/test/java/de/hsfulda/onses/GameServiceTest.java @@ -64,4 +64,19 @@ public class GameServiceTest { assertEquals(expected, answer); } + @Test + @DisplayName("legalMoveSameValueOne") + public void legalMoveSameValueOne() { + // arrange + Card input = new Card().setColor(Card.Color.RED).setValue(Card.Value.ONE); + boolean expected = true; + // act + GameService gameService = new GameService(); + gameService.getGame().setLastPlayedCard(new Card().setColor(Card.Color.YELLOW).setValue(Card.Value.ONE)); + + boolean answer = gameService.legalMove(new Player(), input); + // assert + assertEquals(expected, answer); + } + } From c34b4d38849e756b7c831c61f8398e4d0649a4b2 Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Wed, 31 Jan 2024 14:33:47 +0100 Subject: [PATCH 3/6] Test.legalMoveSameValueThree --- .../java/de/hsfulda/onses/GameServiceTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/de/hsfulda/onses/GameServiceTest.java b/src/test/java/de/hsfulda/onses/GameServiceTest.java index f3190a1..ba7059d 100644 --- a/src/test/java/de/hsfulda/onses/GameServiceTest.java +++ b/src/test/java/de/hsfulda/onses/GameServiceTest.java @@ -79,4 +79,19 @@ public class GameServiceTest { assertEquals(expected, answer); } + @Test + @DisplayName("legalMoveSameValueThree") + public void legalMoveSameValueThree() { + // arrange + Card input = new Card().setColor(Card.Color.GREEN).setValue(Card.Value.THREE); + boolean expected = true; + // act + GameService gameService = new GameService(); + gameService.getGame().setLastPlayedCard(new Card().setColor(Card.Color.YELLOW).setValue(Card.Value.THREE)); + + boolean answer = gameService.legalMove(new Player(), input); + // assert + assertEquals(expected, answer); + } + } From 672f21267d294edb27063c006215062a5b52ff37 Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Wed, 31 Jan 2024 14:42:12 +0100 Subject: [PATCH 4/6] legalMoveColorBlack --- src/main/java/de/hsfulda/onses/services/GameService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/de/hsfulda/onses/services/GameService.java b/src/main/java/de/hsfulda/onses/services/GameService.java index 1cac834..ca49d7c 100644 --- a/src/main/java/de/hsfulda/onses/services/GameService.java +++ b/src/main/java/de/hsfulda/onses/services/GameService.java @@ -33,6 +33,8 @@ public class GameService { if (card.getValue() == lastCard.getValue()) legalMoveFound = true; // same value + if (card.getColor() == Card.Color.BLACK) legalMoveFound = true; // Color Black + return legalMoveFound; } From 7e3afbee5bf4e79776299b4ee80000bff640f08d Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Wed, 31 Jan 2024 14:45:01 +0100 Subject: [PATCH 5/6] Test.legalMoveColorBlackChoose --- .../java/de/hsfulda/onses/GameServiceTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/de/hsfulda/onses/GameServiceTest.java b/src/test/java/de/hsfulda/onses/GameServiceTest.java index ba7059d..a951735 100644 --- a/src/test/java/de/hsfulda/onses/GameServiceTest.java +++ b/src/test/java/de/hsfulda/onses/GameServiceTest.java @@ -94,4 +94,19 @@ public class GameServiceTest { assertEquals(expected, answer); } + @Test + @DisplayName("legalMoveColorBlack") + public void legalMoveColorBlack() { + // arrange + Card input = new Card().setColor(Card.Color.BLACK).setValue(Card.Value.CHOOSE); + boolean expected = true; + // act + GameService gameService = new GameService(); + gameService.getGame().setLastPlayedCard(new Card().setColor(Card.Color.YELLOW).setValue(Card.Value.THREE)); + + boolean answer = gameService.legalMove(new Player(), input); + // assert + assertEquals(expected, answer); + } + } From 4e93ab5038f77968088ca905f7b6362b40bb0526 Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Wed, 31 Jan 2024 14:48:14 +0100 Subject: [PATCH 6/6] Test.legalMoveColorBlackChoosedraw --- .../java/de/hsfulda/onses/GameServiceTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/de/hsfulda/onses/GameServiceTest.java b/src/test/java/de/hsfulda/onses/GameServiceTest.java index a951735..7397d79 100644 --- a/src/test/java/de/hsfulda/onses/GameServiceTest.java +++ b/src/test/java/de/hsfulda/onses/GameServiceTest.java @@ -109,4 +109,19 @@ public class GameServiceTest { assertEquals(expected, answer); } + @Test + @DisplayName("legalMoveColorBlackCHOOSEDRAW") + public void legalMoveColorBlackCHOOSEDRAW() { + // arrange + Card input = new Card().setColor(Card.Color.BLACK).setValue(Card.Value.CHOOSEDRAW); + boolean expected = true; + // act + GameService gameService = new GameService(); + gameService.getGame().setLastPlayedCard(new Card().setColor(Card.Color.GREEN).setValue(Card.Value.FIVE)); + + boolean answer = gameService.legalMove(new Player(), input); + // assert + assertEquals(expected, answer); + } + }