diff --git a/out/test/sp21-cs242-assignment1/PlayerTest.class b/out/test/sp21-cs242-assignment1/PlayerTest.class index 014a5f9933fb477faa6762523256715174095f82..6b4f7d3b1bcc3e1fcf24f953480526d5c58666ff 100644 Binary files a/out/test/sp21-cs242-assignment1/PlayerTest.class and b/out/test/sp21-cs242-assignment1/PlayerTest.class differ diff --git a/src/Test/PlayerTest.java b/src/Test/PlayerTest.java index 62be5d0539653e4524e7686a3ed377b37307bc4e..de27e2a1ece62ed539550ab2787edf99425cc513 100644 --- a/src/Test/PlayerTest.java +++ b/src/Test/PlayerTest.java @@ -21,6 +21,7 @@ class PlayerTest { @Test /** + * Test 1 * Test when a card is played, it goes to the discard pile * Run 100 times to cancel randomness */ @@ -46,6 +47,7 @@ class PlayerTest { /** + * Test 2 * Test the situation where player choose to draw a card * Run 100 times to cancel randomness */ @@ -82,4 +84,34 @@ class PlayerTest { game.gameStart(); assert(game.rounds == 7); } + + + + /** + * Test 4 + * Test when a player plays a wild card and declare the matchable color as "red", + * the game state (controlled by ruleController) is properly updated. + * Notice the declaration is hard-coded in stage assignment-1.0 + */ + @Test + void testPlayerDeclareColorWithWild() { + Game game = null; + Player player = null; + int wildCardID = -1; + boolean hasWild = false; + while (!hasWild) { + game = new Game(1); + player = game.players.get(0); + for (int cardID : player.getCards()) { + if (cardID >= 101 && cardID <= 104) { + wildCardID = cardID; + hasWild = true; + break; // the player has a wild card + } + } + } + player.optionPlayOwnedCard(wildCardID); + assert(game.ruler.getMatchableColor().equals("red")); + } + } \ No newline at end of file