Skip to content
Snippets Groups Projects
Commit a5f44e78 authored by FrederickPi1969's avatar FrederickPi1969
Browse files

Add testcase for player declaring colo with Wild

parent 8746825f
No related branches found
No related tags found
1 merge request!1Implementation of <assignment-1.0>
No preview for this file type
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment