added color support for eventual console overhaul and more (unit?)tests
This commit is contained in:
13
src/main/java/mau/mau/Console.java
Normal file
13
src/main/java/mau/mau/Console.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package mau.mau;
|
||||||
|
|
||||||
|
public class Console {
|
||||||
|
public static void print(String message) {
|
||||||
|
System.out.println(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printColoredMessage(String message, String color) {
|
||||||
|
System.out.println(color + message + ConsoleColors.RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
76
src/main/java/mau/mau/ConsoleColors.java
Normal file
76
src/main/java/mau/mau/ConsoleColors.java
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
package mau.mau;
|
||||||
|
|
||||||
|
public class ConsoleColors {
|
||||||
|
// Reset
|
||||||
|
public static final String RESET = "\033[0m"; // Text Reset
|
||||||
|
|
||||||
|
// Regular Colors
|
||||||
|
public static final String BLACK = "\033[0;30m"; // BLACK
|
||||||
|
public static final String RED = "\033[0;31m"; // RED
|
||||||
|
public static final String GREEN = "\033[0;32m"; // GREEN
|
||||||
|
public static final String YELLOW = "\033[0;33m"; // YELLOW
|
||||||
|
public static final String BLUE = "\033[0;34m"; // BLUE
|
||||||
|
public static final String PURPLE = "\033[0;35m"; // PURPLE
|
||||||
|
public static final String CYAN = "\033[0;36m"; // CYAN
|
||||||
|
public static final String WHITE = "\033[0;37m"; // WHITE
|
||||||
|
|
||||||
|
// Bold
|
||||||
|
public static final String BLACK_BOLD = "\033[1;30m"; // BLACK
|
||||||
|
public static final String RED_BOLD = "\033[1;31m"; // RED
|
||||||
|
public static final String GREEN_BOLD = "\033[1;32m"; // GREEN
|
||||||
|
public static final String YELLOW_BOLD = "\033[1;33m"; // YELLOW
|
||||||
|
public static final String BLUE_BOLD = "\033[1;34m"; // BLUE
|
||||||
|
public static final String PURPLE_BOLD = "\033[1;35m"; // PURPLE
|
||||||
|
public static final String CYAN_BOLD = "\033[1;36m"; // CYAN
|
||||||
|
public static final String WHITE_BOLD = "\033[1;37m"; // WHITE
|
||||||
|
|
||||||
|
// Underline
|
||||||
|
public static final String BLACK_UNDERLINED = "\033[4;30m"; // BLACK
|
||||||
|
public static final String RED_UNDERLINED = "\033[4;31m"; // RED
|
||||||
|
public static final String GREEN_UNDERLINED = "\033[4;32m"; // GREEN
|
||||||
|
public static final String YELLOW_UNDERLINED = "\033[4;33m"; // YELLOW
|
||||||
|
public static final String BLUE_UNDERLINED = "\033[4;34m"; // BLUE
|
||||||
|
public static final String PURPLE_UNDERLINED = "\033[4;35m"; // PURPLE
|
||||||
|
public static final String CYAN_UNDERLINED = "\033[4;36m"; // CYAN
|
||||||
|
public static final String WHITE_UNDERLINED = "\033[4;37m"; // WHITE
|
||||||
|
|
||||||
|
// Background
|
||||||
|
public static final String BLACK_BACKGROUND = "\033[40m"; // BLACK
|
||||||
|
public static final String RED_BACKGROUND = "\033[41m"; // RED
|
||||||
|
public static final String GREEN_BACKGROUND = "\033[42m"; // GREEN
|
||||||
|
public static final String YELLOW_BACKGROUND = "\033[43m"; // YELLOW
|
||||||
|
public static final String BLUE_BACKGROUND = "\033[44m"; // BLUE
|
||||||
|
public static final String PURPLE_BACKGROUND = "\033[45m"; // PURPLE
|
||||||
|
public static final String CYAN_BACKGROUND = "\033[46m"; // CYAN
|
||||||
|
public static final String WHITE_BACKGROUND = "\033[47m"; // WHITE
|
||||||
|
|
||||||
|
// High Intensity
|
||||||
|
public static final String BLACK_BRIGHT = "\033[0;90m"; // BLACK
|
||||||
|
public static final String RED_BRIGHT = "\033[0;91m"; // RED
|
||||||
|
public static final String GREEN_BRIGHT = "\033[0;92m"; // GREEN
|
||||||
|
public static final String YELLOW_BRIGHT = "\033[0;93m"; // YELLOW
|
||||||
|
public static final String BLUE_BRIGHT = "\033[0;94m"; // BLUE
|
||||||
|
public static final String PURPLE_BRIGHT = "\033[0;95m"; // PURPLE
|
||||||
|
public static final String CYAN_BRIGHT = "\033[0;96m"; // CYAN
|
||||||
|
public static final String WHITE_BRIGHT = "\033[0;97m"; // WHITE
|
||||||
|
|
||||||
|
// Bold High Intensity
|
||||||
|
public static final String BLACK_BOLD_BRIGHT = "\033[1;90m"; // BLACK
|
||||||
|
public static final String RED_BOLD_BRIGHT = "\033[1;91m"; // RED
|
||||||
|
public static final String GREEN_BOLD_BRIGHT = "\033[1;92m"; // GREEN
|
||||||
|
public static final String YELLOW_BOLD_BRIGHT = "\033[1;93m";// YELLOW
|
||||||
|
public static final String BLUE_BOLD_BRIGHT = "\033[1;94m"; // BLUE
|
||||||
|
public static final String PURPLE_BOLD_BRIGHT = "\033[1;95m";// PURPLE
|
||||||
|
public static final String CYAN_BOLD_BRIGHT = "\033[1;96m"; // CYAN
|
||||||
|
public static final String WHITE_BOLD_BRIGHT = "\033[1;97m"; // WHITE
|
||||||
|
|
||||||
|
// High Intensity backgrounds
|
||||||
|
public static final String BLACK_BACKGROUND_BRIGHT = "\033[0;100m";// BLACK
|
||||||
|
public static final String RED_BACKGROUND_BRIGHT = "\033[0;101m";// RED
|
||||||
|
public static final String GREEN_BACKGROUND_BRIGHT = "\033[0;102m";// GREEN
|
||||||
|
public static final String YELLOW_BACKGROUND_BRIGHT = "\033[0;103m";// YELLOW
|
||||||
|
public static final String BLUE_BACKGROUND_BRIGHT = "\033[0;104m";// BLUE
|
||||||
|
public static final String PURPLE_BACKGROUND_BRIGHT = "\033[0;105m"; // PURPLE
|
||||||
|
public static final String CYAN_BACKGROUND_BRIGHT = "\033[0;106m"; // CYAN
|
||||||
|
public static final String WHITE_BACKGROUND_BRIGHT = "\033[0;107m"; // WHITE
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ public class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupGame() {
|
private void setupGame() {
|
||||||
|
System.out.println(ConsoleColors.RED_BOLD + Messages.WELCOME + ConsoleColors.RESET);
|
||||||
dealer = new Dealer(deck);
|
dealer = new Dealer(deck);
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
System.out.println(Messages.ASK_FOR_PLAYER_NAME);
|
System.out.println(Messages.ASK_FOR_PLAYER_NAME);
|
||||||
@@ -32,6 +33,7 @@ public class Game {
|
|||||||
input = "Koet";
|
input = "Koet";
|
||||||
System.out.println(Messages.BAD_PLAYER_NAME);
|
System.out.println(Messages.BAD_PLAYER_NAME);
|
||||||
}
|
}
|
||||||
|
new Scanner(System.in).nextLine();
|
||||||
Human human = new Human(input, dealer);
|
Human human = new Human(input, dealer);
|
||||||
players.add(human);
|
players.add(human);
|
||||||
players.add(new Bot("Jordan", dealer));
|
players.add(new Bot("Jordan", dealer));
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ public class TurnTable {
|
|||||||
this.direction = 1;
|
this.direction = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDirection() {
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
public Player getCurrentPlayer() {
|
public Player getCurrentPlayer() {
|
||||||
return players.get(currentPlayerIndex);
|
return players.get(currentPlayerIndex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
* Kattenkaarten (Mau Mau)
|
* Kattenkaarten (Mau Mau)
|
||||||
* Jokers = Koet
|
* Jokers = Koet
|
||||||
* Verslepen van kaarten voor de volgorde
|
* Verslepen van kaarten voor de volgorde
|
||||||
2. Multiplayer
|
2. Multiplayer (websockets?)
|
||||||
3. Game settings
|
3. Game settings
|
||||||
4. Betere bot
|
4. Betere bot
|
||||||
|
* Hyper futuristic AI system
|
||||||
107
src/test/java/mau/mau/CardHandlerTest.java
Normal file
107
src/test/java/mau/mau/CardHandlerTest.java
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
package mau.mau;
|
||||||
|
|
||||||
|
import mau.mau.players.Bot;
|
||||||
|
import mau.mau.players.Player;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
public class CardHandlerTest {
|
||||||
|
|
||||||
|
private CardHandler sut;
|
||||||
|
private TurnTable turnTable;
|
||||||
|
private List<Player> players;
|
||||||
|
private Dealer dealer;
|
||||||
|
private Bot bot1, bot2, bot3;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void setUp() {
|
||||||
|
//Arrange
|
||||||
|
dealer = new Dealer(new Deck());
|
||||||
|
sut = new CardHandler();
|
||||||
|
players = new ArrayList<>();
|
||||||
|
turnTable = new TurnTable(players);
|
||||||
|
bot1 = new Bot("Bot1", dealer);
|
||||||
|
bot2 = new Bot("Bot2", dealer);
|
||||||
|
bot3 = new Bot("Bot3", dealer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void doesAceOfSpadesReverseTheFlowTest() {
|
||||||
|
//Arrange
|
||||||
|
Card card = new Card(TYPENUM.SPADES, VALUENUM.ACE);
|
||||||
|
players.add(bot1);
|
||||||
|
players.add(bot2);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
sut.handleCard(card, turnTable);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot1, turnTable.getCurrentPlayer());
|
||||||
|
assertEquals(-1, turnTable.getDirection());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void doesTwoOfSpadesGiveTheNextPlayerTwoCardsTest() {
|
||||||
|
//Arrange
|
||||||
|
var hand = new ArrayList<Card>();
|
||||||
|
|
||||||
|
Card card = new Card(TYPENUM.SPADES, VALUENUM.TWO);
|
||||||
|
players.add(bot1);
|
||||||
|
players.add(bot2);
|
||||||
|
bot2.setHand(hand);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
sut.handleCard(card, turnTable);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(2, bot2.getHand().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isSevenStickyAndDoesNotChangeThePlayerTest() {
|
||||||
|
//Arrange
|
||||||
|
Card card = new Card(TYPENUM.SPADES, VALUENUM.SEVEN);
|
||||||
|
players.add(bot1);
|
||||||
|
players.add(bot2);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
sut.handleCard(card, turnTable);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot1, turnTable.getCurrentPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void doesEightSkipTheNextPlayerTest() {
|
||||||
|
//Arrange
|
||||||
|
Card card = new Card(TYPENUM.SPADES, VALUENUM.EIGHT);
|
||||||
|
players.add(bot1);
|
||||||
|
players.add(bot2);
|
||||||
|
players.add(bot3);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
sut.handleCard(card, turnTable);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot3, turnTable.getCurrentPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isKingKinkyAndDoesNotChangeThePlayerTest() {
|
||||||
|
//Arrange
|
||||||
|
Card card = new Card(TYPENUM.SPADES, VALUENUM.KING);
|
||||||
|
players.add(bot1);
|
||||||
|
players.add(bot2);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
sut.handleCard(card, turnTable);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot1, turnTable.getCurrentPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ public class CardTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAceOfSpadesPrintedCorrectlyTest() {
|
public void isAceOfSpadesPrintedCorrectlyTest() {
|
||||||
//Assign
|
//Arrange
|
||||||
Card card = new Card(TYPENUM.SPADES, VALUENUM.ACE);
|
Card card = new Card(TYPENUM.SPADES, VALUENUM.ACE);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@@ -20,7 +20,7 @@ public class CardTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isJokerPrintedCorrectlyTest() {
|
public void isJokerPrintedCorrectlyTest() {
|
||||||
//Assign
|
//Arrange
|
||||||
Card card = new Card(TYPENUM.JOKER, VALUENUM.TWO);
|
Card card = new Card(TYPENUM.JOKER, VALUENUM.TWO);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class DeckTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isDeckEmptyWhenDrawingTheFirstCardTest() {
|
public void isDeckEmptyWhenDrawingTheFirstCardTest() {
|
||||||
// Assign
|
// Arrange
|
||||||
int cardsToDraw = 1;
|
int cardsToDraw = 1;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class RefereeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSameCardTypeValidMoveTest(){
|
public void isSameCardTypeValidMoveTest(){
|
||||||
//Assign
|
//Arrange
|
||||||
Card testCardOne = new Card(TYPENUM.HEARTS, VALUENUM.ACE);
|
Card testCardOne = new Card(TYPENUM.HEARTS, VALUENUM.ACE);
|
||||||
Card testCardTwo = new Card(TYPENUM.HEARTS, VALUENUM.EIGHT);
|
Card testCardTwo = new Card(TYPENUM.HEARTS, VALUENUM.EIGHT);
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ public class RefereeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSameCardValueValidMoveTest(){
|
public void isSameCardValueValidMoveTest(){
|
||||||
//Assign
|
//Arrange
|
||||||
Card testCardOne = new Card(TYPENUM.HEARTS, VALUENUM.ACE);
|
Card testCardOne = new Card(TYPENUM.HEARTS, VALUENUM.ACE);
|
||||||
Card testCardTwo = new Card(TYPENUM.DIAMONDS, VALUENUM.ACE);
|
Card testCardTwo = new Card(TYPENUM.DIAMONDS, VALUENUM.ACE);
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ public class RefereeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isJokerOnAnyCardValidMoveTest() {
|
public void isJokerOnAnyCardValidMoveTest() {
|
||||||
//Assign
|
//Arrange
|
||||||
Card testCardOne = new Card(TYPENUM.HEARTS, VALUENUM.ACE);
|
Card testCardOne = new Card(TYPENUM.HEARTS, VALUENUM.ACE);
|
||||||
Card testCardTwo = new Card(TYPENUM.JOKER, VALUENUM.THREE);
|
Card testCardTwo = new Card(TYPENUM.JOKER, VALUENUM.THREE);
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ public class RefereeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAnyCardOnJokerValidMoveTest(){
|
public void isAnyCardOnJokerValidMoveTest(){
|
||||||
//Assign
|
//Arrange
|
||||||
Card testCardOne = new Card(TYPENUM.HEARTS, VALUENUM.ACE);
|
Card testCardOne = new Card(TYPENUM.HEARTS, VALUENUM.ACE);
|
||||||
Card testCardTwo = new Card(TYPENUM.JOKER, VALUENUM.THREE);
|
Card testCardTwo = new Card(TYPENUM.JOKER, VALUENUM.THREE);
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ public class RefereeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isTwoOfHeartsAMauCardTest(){
|
public void isTwoOfHeartsAMauCardTest(){
|
||||||
//Assign
|
//Arrange
|
||||||
Card testCard = new Card(TYPENUM.HEARTS, VALUENUM.TWO);
|
Card testCard = new Card(TYPENUM.HEARTS, VALUENUM.TWO);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@@ -73,7 +73,7 @@ public class RefereeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isJokerAMauCardTest(){
|
public void isJokerAMauCardTest(){
|
||||||
//Assign
|
//Arrange
|
||||||
Card testCard = new Card(TYPENUM.JOKER, VALUENUM.THREE);
|
Card testCard = new Card(TYPENUM.JOKER, VALUENUM.THREE);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@@ -85,7 +85,7 @@ public class RefereeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isThreeOfSpadesAMauCardTest(){
|
public void isThreeOfSpadesAMauCardTest(){
|
||||||
//Assign
|
//Arrange
|
||||||
Card testCard = new Card(TYPENUM.HEARTS, VALUENUM.THREE);
|
Card testCard = new Card(TYPENUM.HEARTS, VALUENUM.THREE);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@@ -98,7 +98,7 @@ public class RefereeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAceOfSpadesValidEndcardTest(){
|
public void isAceOfSpadesValidEndcardTest(){
|
||||||
//Assign
|
//Arrange
|
||||||
Card testCardOne = new Card(TYPENUM.SPADES, VALUENUM.ACE);
|
Card testCardOne = new Card(TYPENUM.SPADES, VALUENUM.ACE);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@@ -110,7 +110,7 @@ public class RefereeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isThreeOfHeartsValidEndcardTest(){
|
public void isThreeOfHeartsValidEndcardTest(){
|
||||||
//Assign
|
//Arrange
|
||||||
Card testCardOne = new Card(TYPENUM.HEARTS, VALUENUM.THREE);
|
Card testCardOne = new Card(TYPENUM.HEARTS, VALUENUM.THREE);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
|||||||
118
src/test/java/mau/mau/TurnTableTest.java
Normal file
118
src/test/java/mau/mau/TurnTableTest.java
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
package mau.mau;
|
||||||
|
|
||||||
|
import mau.mau.players.Bot;
|
||||||
|
import mau.mau.players.Player;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
public class TurnTableTest {
|
||||||
|
private TurnTable sut;
|
||||||
|
private ArrayList<Player> players;
|
||||||
|
private Bot bot1, bot2, bot3;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void setUp() {
|
||||||
|
Dealer dealer = new Dealer(new Deck());
|
||||||
|
players = new ArrayList<>();
|
||||||
|
bot1 = new Bot("Bot1", dealer);
|
||||||
|
bot2 = new Bot("Bot2", dealer);
|
||||||
|
bot3 = new Bot("Bot3", dealer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isNextPlayerBot2WhenCurrentPlayerIsBot1(){
|
||||||
|
//Arrange
|
||||||
|
players.add(bot1);
|
||||||
|
players.add(bot2);
|
||||||
|
players.add(bot3);
|
||||||
|
sut = new TurnTable(players);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot1, sut.getCurrentPlayer());
|
||||||
|
|
||||||
|
//Act
|
||||||
|
sut.nextPlayer();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot2, sut.getCurrentPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isNextPlayerBot3WhenBot1SkipsNextPlayer(){
|
||||||
|
//Arrange
|
||||||
|
players.add(bot1);
|
||||||
|
players.add(bot2);
|
||||||
|
players.add(bot3);
|
||||||
|
sut = new TurnTable(players);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot1, sut.getCurrentPlayer());
|
||||||
|
|
||||||
|
|
||||||
|
//Act
|
||||||
|
sut.skipNextPlayer();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot3, sut.getCurrentPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isNextPlayerBot3WhenBot1PlayedAce(){
|
||||||
|
//Arrange
|
||||||
|
players.add(bot1);
|
||||||
|
players.add(bot2);
|
||||||
|
players.add(bot3);
|
||||||
|
sut = new TurnTable(players);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot1, sut.getCurrentPlayer());
|
||||||
|
|
||||||
|
//Act
|
||||||
|
sut.reverseDirection();
|
||||||
|
sut.nextPlayer();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot3, sut.getCurrentPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isNextPlayerBot1WhenBot1PlayedAceAndBot3Skipped(){
|
||||||
|
//Arrange
|
||||||
|
players.add(bot1);
|
||||||
|
players.add(bot2);
|
||||||
|
players.add(bot3);
|
||||||
|
sut = new TurnTable(players);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot1, sut.getCurrentPlayer());
|
||||||
|
|
||||||
|
//Act
|
||||||
|
sut.reverseDirection();
|
||||||
|
sut.skipNextPlayer();
|
||||||
|
sut.nextPlayer();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot1, sut.getCurrentPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isNextPlayerBot1WhenBot1PlayedEightAndThereAreOnlyTwoPlayers(){
|
||||||
|
//Arrange
|
||||||
|
players.add(bot1);
|
||||||
|
players.add(bot2);
|
||||||
|
sut = new TurnTable(players);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot1, sut.getCurrentPlayer());
|
||||||
|
|
||||||
|
//Act
|
||||||
|
sut.skipNextPlayer();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(bot1, sut.getCurrentPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ public class UtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isNumericStringNumericTest() {
|
public void isNumericStringNumericTest() {
|
||||||
//Assign
|
//Arrange
|
||||||
String numericString = "123";
|
String numericString = "123";
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@@ -21,7 +21,7 @@ public class UtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAlphabeticStringNumericTest() {
|
public void isAlphabeticStringNumericTest() {
|
||||||
//Assign
|
//Arrange
|
||||||
String numericString = "Koet";
|
String numericString = "Koet";
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@@ -33,7 +33,7 @@ public class UtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isEmptyStringNumericTest() {
|
public void isEmptyStringNumericTest() {
|
||||||
//Assign
|
//Arrange
|
||||||
String numericString = "";
|
String numericString = "";
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
@@ -45,7 +45,7 @@ public class UtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isCarriageReturnStringNumericTest() {
|
public void isCarriageReturnStringNumericTest() {
|
||||||
//Assign
|
//Arrange
|
||||||
String numericString = "\n";
|
String numericString = "\n";
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class BotTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canBotEndTheGameWithFourOfHeartsOnThreeOfHeartsTest() {
|
public void canBotEndTheGameWithFourOfHeartsOnThreeOfHeartsTest() {
|
||||||
//Assign
|
//Arrange
|
||||||
Card currentCard = new Card(TYPENUM.HEARTS, VALUENUM.THREE);
|
Card currentCard = new Card(TYPENUM.HEARTS, VALUENUM.THREE);
|
||||||
hand.add(new Card(TYPENUM.HEARTS, VALUENUM.FOUR));
|
hand.add(new Card(TYPENUM.HEARTS, VALUENUM.FOUR));
|
||||||
sut.setHand(hand);
|
sut.setHand(hand);
|
||||||
@@ -43,7 +43,7 @@ public class BotTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canBotDrawACardTest() {
|
public void canBotDrawACardTest() {
|
||||||
//Assign
|
//Arrange
|
||||||
Card currentCard = new Card(TYPENUM.SPADES, VALUENUM.THREE);
|
Card currentCard = new Card(TYPENUM.SPADES, VALUENUM.THREE);
|
||||||
hand.add(new Card(TYPENUM.HEARTS, VALUENUM.FOUR));
|
hand.add(new Card(TYPENUM.HEARTS, VALUENUM.FOUR));
|
||||||
sut.setHand(hand);
|
sut.setHand(hand);
|
||||||
@@ -60,7 +60,7 @@ public class BotTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canBotPlayACardWithSameTypeTest() {
|
public void canBotPlayACardWithSameTypeTest() {
|
||||||
//Assign
|
//Arrange
|
||||||
Card currentCard = new Card(TYPENUM.HEARTS, VALUENUM.THREE);
|
Card currentCard = new Card(TYPENUM.HEARTS, VALUENUM.THREE);
|
||||||
Card spadesFive = new Card(TYPENUM.SPADES, VALUENUM.FIVE);
|
Card spadesFive = new Card(TYPENUM.SPADES, VALUENUM.FIVE);
|
||||||
Card clubsEight = new Card(TYPENUM.CLUBS, VALUENUM.EIGHT);
|
Card clubsEight = new Card(TYPENUM.CLUBS, VALUENUM.EIGHT);
|
||||||
@@ -82,7 +82,7 @@ public class BotTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canBotPlayACardWithSameValueTest() {
|
public void canBotPlayACardWithSameValueTest() {
|
||||||
//Assign
|
//Arrange
|
||||||
Card currentCard = new Card(TYPENUM.DIAMONDS, VALUENUM.FIVE);
|
Card currentCard = new Card(TYPENUM.DIAMONDS, VALUENUM.FIVE);
|
||||||
Card spadesFive = new Card(TYPENUM.SPADES, VALUENUM.FIVE);
|
Card spadesFive = new Card(TYPENUM.SPADES, VALUENUM.FIVE);
|
||||||
Card clubsEight = new Card(TYPENUM.CLUBS, VALUENUM.EIGHT);
|
Card clubsEight = new Card(TYPENUM.CLUBS, VALUENUM.EIGHT);
|
||||||
@@ -104,11 +104,49 @@ public class BotTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canBotChooseTheTypeItHasTheMostOfTest() {
|
public void canBotChooseTheTypeItHasTheMostOfTest() {
|
||||||
//TODO: implement test
|
//Arrange
|
||||||
|
Card spadesFive = new Card(TYPENUM.SPADES, VALUENUM.FIVE);
|
||||||
|
Card clubsEight = new Card(TYPENUM.CLUBS, VALUENUM.EIGHT);
|
||||||
|
Card heartsNine = new Card(TYPENUM.HEARTS, VALUENUM.NINE);
|
||||||
|
Card heartsSeven = new Card(TYPENUM.HEARTS, VALUENUM.SEVEN);
|
||||||
|
Card heartsThree = new Card(TYPENUM.HEARTS, VALUENUM.THREE);
|
||||||
|
hand.add(spadesFive);
|
||||||
|
hand.add(clubsEight);
|
||||||
|
hand.add(heartsNine);
|
||||||
|
hand.add(heartsSeven);
|
||||||
|
hand.add(heartsThree);
|
||||||
|
sut.setHand(hand);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
TYPENUM result = sut.getTypeChoice();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertEquals(TYPENUM.HEARTS, result);
|
||||||
|
assertNotSame(TYPENUM.SPADES, result);
|
||||||
|
assertNotSame(TYPENUM.CLUBS, result);
|
||||||
|
assertNotSame(TYPENUM.DIAMONDS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canBotChooseTheTypeItHasTheMostOfWhenThereIsATieTest() {
|
public void canBotChooseTheTypeItHasTheMostOfWhenThereIsATieTest() {
|
||||||
//TODO: implement test
|
//Arrange
|
||||||
|
Card spadesFive = new Card(TYPENUM.SPADES, VALUENUM.FIVE);
|
||||||
|
Card spadesEight = new Card(TYPENUM.SPADES, VALUENUM.EIGHT);
|
||||||
|
Card clubsEight = new Card(TYPENUM.CLUBS, VALUENUM.EIGHT);
|
||||||
|
Card heartsNine = new Card(TYPENUM.HEARTS, VALUENUM.NINE);
|
||||||
|
Card heartsThree = new Card(TYPENUM.HEARTS, VALUENUM.THREE);
|
||||||
|
hand.add(spadesFive);
|
||||||
|
hand.add(spadesEight);
|
||||||
|
hand.add(clubsEight);
|
||||||
|
hand.add(heartsNine);
|
||||||
|
hand.add(heartsThree);
|
||||||
|
sut.setHand(hand);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
TYPENUM result = sut.getTypeChoice();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
assertNotEquals(TYPENUM.CLUBS, result);
|
||||||
|
assertNotEquals(TYPENUM.DIAMONDS, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
1. Bot
|
1. ~~Bot~~
|
||||||
2. Human
|
2. Human
|
||||||
3. Player
|
3. ~~Card~~
|
||||||
4. Card
|
4. CardHandler
|
||||||
5. CardHandler
|
5. Dealer
|
||||||
6. Dealer
|
6. ~~Deck~~
|
||||||
7. ~~Deck~~
|
7. ~~Game~~
|
||||||
8. ~~Game~~
|
8. ~~Referee~~
|
||||||
9. ~~Referee~~
|
9. TurnTable
|
||||||
10. TurnTable
|
10. ~~Utils~~
|
||||||
11. ~~Utils~~
|
|
||||||
|
|||||||
Reference in New Issue
Block a user