commit a3161603e57aa4c6970ad23a51a2a502d4e58a5b Author: peet Date: Sun May 12 14:25:54 2024 +0200 initial commit diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/bin/cards/Card.class b/bin/cards/Card.class new file mode 100644 index 0000000..41dcbd5 Binary files /dev/null and b/bin/cards/Card.class differ diff --git a/bin/cards/Rank.class b/bin/cards/Rank.class new file mode 100644 index 0000000..e012f33 Binary files /dev/null and b/bin/cards/Rank.class differ diff --git a/bin/cards/Suit.class b/bin/cards/Suit.class new file mode 100644 index 0000000..2675d5c Binary files /dev/null and b/bin/cards/Suit.class differ diff --git a/bin/cards/maumau/MauMauDeck.class b/bin/cards/maumau/MauMauDeck.class new file mode 100644 index 0000000..aef60b8 Binary files /dev/null and b/bin/cards/maumau/MauMauDeck.class differ diff --git a/bin/cards/maumau/MauMauGame.class b/bin/cards/maumau/MauMauGame.class new file mode 100644 index 0000000..9719dea Binary files /dev/null and b/bin/cards/maumau/MauMauGame.class differ diff --git a/bin/cards/maumau/gui/CardListRenderer.class b/bin/cards/maumau/gui/CardListRenderer.class new file mode 100644 index 0000000..46c3622 Binary files /dev/null and b/bin/cards/maumau/gui/CardListRenderer.class differ diff --git a/bin/cards/maumau/gui/GameTableModel.class b/bin/cards/maumau/gui/GameTableModel.class new file mode 100644 index 0000000..eafd47f Binary files /dev/null and b/bin/cards/maumau/gui/GameTableModel.class differ diff --git a/bin/cards/maumau/gui/PlayerFrame.class b/bin/cards/maumau/gui/PlayerFrame.class new file mode 100644 index 0000000..98f538d Binary files /dev/null and b/bin/cards/maumau/gui/PlayerFrame.class differ diff --git a/bin/cards/maumau/model/ActionHandler.class b/bin/cards/maumau/model/ActionHandler.class new file mode 100644 index 0000000..f329904 Binary files /dev/null and b/bin/cards/maumau/model/ActionHandler.class differ diff --git a/bin/cards/maumau/model/CardHandler.class b/bin/cards/maumau/model/CardHandler.class new file mode 100644 index 0000000..24778c3 Binary files /dev/null and b/bin/cards/maumau/model/CardHandler.class differ diff --git a/bin/cards/maumau/model/GameState.class b/bin/cards/maumau/model/GameState.class new file mode 100644 index 0000000..808c0e9 Binary files /dev/null and b/bin/cards/maumau/model/GameState.class differ diff --git a/bin/cards/maumau/model/IObserver.class b/bin/cards/maumau/model/IObserver.class new file mode 100644 index 0000000..7854e86 Binary files /dev/null and b/bin/cards/maumau/model/IObserver.class differ diff --git a/bin/cards/maumau/model/MauMau.class b/bin/cards/maumau/model/MauMau.class new file mode 100644 index 0000000..b0e84a4 Binary files /dev/null and b/bin/cards/maumau/model/MauMau.class differ diff --git a/bin/cards/maumau/model/Player.class b/bin/cards/maumau/model/Player.class new file mode 100644 index 0000000..e939995 Binary files /dev/null and b/bin/cards/maumau/model/Player.class differ diff --git a/bin/cards/maumau/model/PlayerHandler.class b/bin/cards/maumau/model/PlayerHandler.class new file mode 100644 index 0000000..7ce73d1 Binary files /dev/null and b/bin/cards/maumau/model/PlayerHandler.class differ diff --git a/src/cards/Card.java b/src/cards/Card.java new file mode 100644 index 0000000..561feb4 --- /dev/null +++ b/src/cards/Card.java @@ -0,0 +1,29 @@ +package cards; + +/** + * Represents a playing card with a rank and a suit. + */ +public record Card(Rank rank, Suit suit) implements Comparable { + + /** + * Returns a string representation of the card. + * + * @return A string representing the card's rank followed by its suit. + */ + @Override + public String toString() { + return rank.toString() + suit; + } + + /** + * Compares this card with another card for order. + * + * @param other The card to be compared. + * @return A negative integer, zero, or a positive integer if this card is less than, equal to, or greater than the specified card. + */ + @Override + public int compareTo(Card other) { + //TODO implement + return 0; + } +} diff --git a/src/cards/Rank.java b/src/cards/Rank.java new file mode 100644 index 0000000..ba0fe06 --- /dev/null +++ b/src/cards/Rank.java @@ -0,0 +1,19 @@ +package cards; + +/** + * Represents the ranks of playing cards. + */ +public enum Rank { + TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE; + + /** + * Returns a string representation of the rank. + * + * @return A string representing the rank. + */ + @Override + public String toString() { + //TODO implement + return super.toString(); + } +} diff --git a/src/cards/Suit.java b/src/cards/Suit.java new file mode 100644 index 0000000..333688d --- /dev/null +++ b/src/cards/Suit.java @@ -0,0 +1,34 @@ +package cards; + +/** + * Represents the suits of playing cards. + */ +public enum Suit { + /** + * Represents the Hearts suit. + */ + HEARTS, + /** + * Represents the Diamonds suit. + */ + DIAMONDS, + /** + * Represents the Clubs suit. + */ + CLUBS, + /** + * Represents the Spades suit. + */ + SPADES; + + /** + * Returns a string representation of the suit. + * + * @return A string representing the suit. + */ + @Override + public String toString() { + //TODO implement + return super.toString(); + } +} diff --git a/src/cards/maumau/MauMauDeck.java b/src/cards/maumau/MauMauDeck.java new file mode 100644 index 0000000..9595b17 --- /dev/null +++ b/src/cards/maumau/MauMauDeck.java @@ -0,0 +1,26 @@ +package cards.maumau; + +import cards.Card; + +import java.util.List; + +/** + * Represents a deck of cards used in the Mau-Mau game. + */ +public class MauMauDeck { + /** + * Private constructor to prevent instantiation of this class. + */ + private MauMauDeck() { /* do nothing */ } + + /** + * Generates a deck of Mau-Mau cards and shuffles it. + * + * @param numDecks Number of decks to be included in the game. + * @return A list containing the generated deck of cards. + */ + public static List makeDeck(int numDecks) { + //TODO implement + return null; + } +} diff --git a/src/cards/maumau/MauMauGame.java b/src/cards/maumau/MauMauGame.java new file mode 100644 index 0000000..23425bc --- /dev/null +++ b/src/cards/maumau/MauMauGame.java @@ -0,0 +1,82 @@ +package cards.maumau; + +import cards.Card; +import cards.maumau.gui.PlayerFrame; +import cards.maumau.model.MauMau; +import cards.maumau.model.Player; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +/** + * Represents the main class for running the Mau-Mau card game. + */ +public class MauMauGame { + + /** + * Prints usage information for running the game. + */ + private static void usage() { + System.err.println("usage: <#cards per player> <#decks> ..."); + System.err.println(" where <#cards per player> >= 2 and <#decks> >= 1"); + System.exit(1); + } + + /** + * Main method for running the Mau-Mau game. + * + * @param args Command line arguments. + */ + public static void main(String[] args) { + if (args.length == 0) + makeSimpleGame(); + else + makeGeneralGame(args); + } + + /** + * Runs a simple game with predefined settings. + */ + private static void makeSimpleGame() { + final List deck = MauMauDeck.makeDeck(1); + final MauMau game = new MauMau(5, deck); + game.addPlayer("Jacqueline"); + game.addPlayer("Chantal"); + start(game); + } + + /** + * Runs a game with customizable settings based on command line arguments. + * + * @param args Command line arguments specifying game parameters. + */ + private static void makeGeneralGame(String[] args) { + if (args.length < 4) usage(); + final Iterator it = Arrays.asList(args).iterator(); + try { + final int numCardsPerPlayer = Integer.parseInt(it.next()); + final int numDecks = Integer.parseInt(it.next()); + if (numCardsPerPlayer < 2 || numDecks < 1) usage(); + final List deck = MauMauDeck.makeDeck(numDecks); + final MauMau game = new MauMau(numCardsPerPlayer, deck); + while (it.hasNext()) + game.addPlayer(it.next()); + start(game); + } + catch (NumberFormatException ex) { + usage(); + } + } + + /** + * Starts the Mau-Mau game. + * + * @param game The Mau-Mau game to start. + */ + private static void start(MauMau game) { + game.startGame(); + for (Player player : game.getPlayers()) + new PlayerFrame(player).setVisible(true); + } +} diff --git a/src/cards/maumau/gui/CardListRenderer.java b/src/cards/maumau/gui/CardListRenderer.java new file mode 100644 index 0000000..a9c1bdc --- /dev/null +++ b/src/cards/maumau/gui/CardListRenderer.java @@ -0,0 +1,49 @@ +package cards.maumau.gui; + +import cards.Card; +import cards.maumau.model.Player; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import java.awt.Component; + +import static java.awt.Color.GREEN; +import static java.awt.Color.RED; + +/** + * Custom renderer for rendering cards in a JList representing the cards on a player's hand. + */ +class CardListRenderer extends DefaultListCellRenderer { + private final transient Player player; + + /** + * Constructs a CardListRenderer object. + * + * @param player The player associated with the renderer. + */ + CardListRenderer(Player player) { + this.player = player; + } + + /** + * Custom rendering of list cell components. + * + * @param list The JList being rendered. + * @param value The value to be rendered. + * @param index The cell index. + * @param isSelected True if the cell is selected. + * @param cellHasFocus True if the cell has focus. + * @return The rendered component. + */ + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof Card card) { + setText(card.toString()); + setBackground(player.canPlay(card) ? GREEN : RED); + if (isSelected) + setBackground(getBackground().darker()); + } + return c; + } +} diff --git a/src/cards/maumau/gui/GameTableModel.java b/src/cards/maumau/gui/GameTableModel.java new file mode 100644 index 0000000..223f5dd --- /dev/null +++ b/src/cards/maumau/gui/GameTableModel.java @@ -0,0 +1,67 @@ +package cards.maumau.gui; + +import cards.maumau.model.MauMau; + +import javax.swing.table.AbstractTableModel; + +import static cards.maumau.model.GameState.GAME_CANCELED; +import static cards.maumau.model.GameState.GAME_OVER; + +/** + * Represents the table model for displaying player information in the Mau-Mau game. + */ +class GameTableModel extends AbstractTableModel { + private final transient MauMau game; + + /** + * Constructs a GameTableModel object. + * + * @param game The Mau-Mau game. + */ + public GameTableModel(MauMau game) { + this.game = game; + } + + /** + * Updates the table data. + */ + void update() { + fireTableDataChanged(); + } + + @Override + public int getRowCount() { + if (showRanking()) + return game.getRanking().size(); + return game.getPlayers().size(); + } + + @Override + public int getColumnCount() { + return 2; + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + if (showRanking()) + return switch (columnIndex) { + case 0 -> game.getRanking().get(rowIndex).getName(); + case 1 -> rowIndex + 1; + default -> null; + }; + return switch (columnIndex) { + case 0 -> game.getPlayers().get(rowIndex).getName(); + case 1 -> game.getPlayers().get(rowIndex).getCards().size(); + default -> null; + }; + } + + /** + * Checks if the ranking should be shown based on the current game state. + * + * @return True if the ranking should be shown, false otherwise. + */ + private boolean showRanking() { + return game.getGameState() == GAME_CANCELED || game.getGameState() == GAME_OVER; + } +} diff --git a/src/cards/maumau/gui/PlayerFrame.java b/src/cards/maumau/gui/PlayerFrame.java new file mode 100644 index 0000000..850f28f --- /dev/null +++ b/src/cards/maumau/gui/PlayerFrame.java @@ -0,0 +1,231 @@ +package cards.maumau.gui; + +import cards.Card; +import cards.Suit; +import cards.maumau.model.IObserver; +import cards.maumau.model.MauMau; +import cards.maumau.model.Player; + +import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTable; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +import static cards.maumau.model.GameState.CHOOSE_SUIT; +import static cards.maumau.model.GameState.GAME_CANCELED; +import static cards.maumau.model.GameState.GAME_OVER; +import static java.awt.BorderLayout.CENTER; +import static java.awt.Color.GREEN; +import static java.awt.Color.RED; + +/** + * Represents the graphical user interface for a player in the Mau-Mau card game. + */ +public class PlayerFrame extends JFrame implements IObserver { + private final transient Player player; + private final GameTableModel playerTableModel; + private final DefaultListModel cardListModel = new DefaultListModel<>(); + private final JList cardList = new JList<>(cardListModel); + private final JLabel topCardLabel = new JLabel("top card:"); + private final JLabel stateLabel = new JLabel("game starts"); + private final JPanel pane = new JPanel(new GridBagLayout()); + + /** + * Constructs a new PlayerFrame object. + * + * @param player The player associated with this frame. + */ + public PlayerFrame(Player player) { + super(player.getName()); + this.player = player; + final MauMau game = player.getGame(); + playerTableModel = new GameTableModel(game); + update(); + initializeUI(); + game.addObserver(this); + } + + /** + * Initializes the user interface components. + */ + private void initializeUI() { + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(pane, CENTER); + + final GridBagConstraints constraints = new GridBagConstraints(); + constraints.gridx = 0; + constraints.gridy = 0; + constraints.gridheight = 9; + constraints.weightx = 1; + constraints.weighty = 1; + constraints.fill = GridBagConstraints.BOTH; + constraints.ipadx = 15; + constraints.ipady = 15; + constraints.insets = new Insets(5, 5, 5, 5); + + cardList.setBorder(BorderFactory.createLoweredBevelBorder()); + cardList.setCellRenderer(new CardListRenderer(player)); + pane.add(cardList, constraints); + + constraints.gridx = 1; + constraints.gridheight = 1; + constraints.gridwidth = 4; + constraints.weightx = 0; + constraints.weighty = 0; + constraints.fill = GridBagConstraints.HORIZONTAL; + final JTable table = new JTable(playerTableModel); + table.setBorder(BorderFactory.createLoweredBevelBorder()); + pane.add(table, constraints); + + constraints.gridy++; + constraints.ipadx = 0; + constraints.ipady = 5; + constraints.insets = new Insets(0, 0, 0, 0); + pane.add(topCardLabel, constraints); + + constraints.gridy++; + pane.add(stateLabel, constraints); + + constraints.gridy++; + pane.add(makeButton("choose card", this::chooseCard), constraints); + + constraints.gridy++; + pane.add(makeButton("skip", e -> player.skip()), constraints); + + constraints.gridy++; + constraints.gridwidth = 1; + for (Suit suit : Suit.values()) { + pane.add(makeButton(suit.toString(), e -> player.chooseSuit(suit)), constraints); + constraints.gridx++; + } + + constraints.gridy++; + constraints.gridx = 1; + constraints.gridwidth = 4; + pane.add(makeButton("have no 7", e -> player.no7()), constraints); + + constraints.gridy++; + constraints.gridwidth = 2; + pane.add(makeButton("\"Mau\"", e -> player.mau()), constraints); + + constraints.gridx = 3; + pane.add(makeButton("\"Mau-Mau\"", e -> player.maumau()), constraints); + + pack(); + } + + /** + * Creates a JButton with the specified text and action listener. + * + * @param text The text displayed on the button. + * @param listener The action listener for the button. + * @return The created JButton. + */ + private JButton makeButton(String text, ActionListener listener) { + final JButton button = new JButton(text); + button.addActionListener(listener); + return button; + } + + /** + * Action performed when the "choose card" button is clicked. + * + * @param e The ActionEvent object. + */ + private void chooseCard(ActionEvent e) { + final List selected = cardList.getSelectedValuesList(); + if (selected.size() == 1) + player.chooseCard(selected.getFirst()); + else if (selected.isEmpty()) + error("You must select a card first!"); + else + error("You must not select more than a single card!"); + } + + /** + * Updates the user interface. + */ + @Override + public void update() { + playerTableModel.update(); + updateCardList(); + updateTopCardLabel(); + updateStateLabel(); + updateBorderColor(); + } + + /** + * Updates the card list displayed in the UI. + */ + private void updateCardList() { + cardListModel.clear(); + player.getCards().stream().sorted().forEach(cardListModel::addElement); + } + + /** + * Updates the label displaying the top card on the discard pile. + */ + private void updateTopCardLabel() { + final List pile = player.getGame().getDiscardPile(); + topCardLabel.setText(pile.isEmpty() ? "no top card" : "top card: " + pile.getFirst()); + } + + /** + * Updates the label displaying the current game state. + */ + private void updateStateLabel() { + final MauMau game = player.getGame(); + if (game.getGameState() == GAME_CANCELED) + stateLabel.setText("Game canceled"); + else if (game.getGameState() == GAME_OVER) + stateLabel.setText("Game over"); + else if (game.get7Counter() > 0) + stateLabel.setText(game.get7Counter() + " seven on discard pile"); + else if (game.getChosenSuit() != null) + stateLabel.setText(game.getChosenSuit() + " chosen"); + else if (game.getGameState() == CHOOSE_SUIT && game.getCurrentPlayer() == player) + stateLabel.setText("Choose a suit"); + else + stateLabel.setText(" "); + } + + /** + * Updates the border color of the frame based on the current player's turn. + */ + private void updateBorderColor() { + final Color borderColor = player.getGame().getCurrentPlayer() == player ? GREEN : RED; + pane.setBorder(BorderFactory.createLineBorder(borderColor, 5)); + } + + /** + * Displays an error message dialog. + * + * @param msg The error message to display. + */ + private void error(String msg) { + JOptionPane.showMessageDialog(this, msg, "Error", JOptionPane.ERROR_MESSAGE); + } + + /** + * Displays a message dialog. + * + * @param msg The message to display. + */ + @Override + public void message(String msg) { + JOptionPane.showMessageDialog(this, msg, "Message", JOptionPane.INFORMATION_MESSAGE); + } +} diff --git a/src/cards/maumau/model/ActionHandler.java b/src/cards/maumau/model/ActionHandler.java new file mode 100644 index 0000000..e4cbbdb --- /dev/null +++ b/src/cards/maumau/model/ActionHandler.java @@ -0,0 +1,153 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Suit; + +/** + * Manages the actions and state transitions within a MauMau game. + */ +class ActionHandler { + private final MauMau game; + private Suit chosenSuit; + private int ctr7 = 0; + + /** + * Constructs an ActionHandler for the specified MauMau game. + * + * @param game The MauMau game instance. + */ + ActionHandler(MauMau game) { + this.game = game; + } + + /** + * Adds the specified player to the game. + * + * @param player The player to be added to the game. + */ + void addPlayer(Player player) { + //TODO implement + } + + /** + * Starts the game. + */ + void startGame() { + //TODO implement + } + + /** + * Transitions the game state to GAME_OVER. + */ + void finishGame() { + //TODO implement + } + + /** + * Transitions the game state to GAME_CANCELED. + */ + void cancelGame() { + //TODO implement + } + + /** + * Handles the player's choice of a card in the current state. + * + * @param c The card chosen by the player. + */ + void chooseCard(Card c) { + //TODO implement + } + + /** + * Handles the player's choice of a suit in the current state. + * + * @param suit The suit chosen by the player. + */ + void chooseSuit(Suit suit) { + //TODO implement + } + + /** + * Lets the player skip a round. + **/ + void skip() { + //TODO implement + } + + /** + * Handles the player saying "no 7" in the current state. + */ + void no7() { + //TODO implement + } + + /** + * Returns the MauMau game instance associated with this action handler. + * + * @return The MauMau game instance. + */ + MauMau getGame() { + return game; + } + + /** + * Returns the suit chosen by a player after playing a Jack card. + * + * @return The chosen suit. + */ + Suit getChosenSuit() { + return chosenSuit; + } + + /** + * Sets the suit chosen by a player after playing a Jack card. + * + * @param chosenSuit The suit chosen by the player. + */ + void setChosenSuit(Suit chosenSuit) { + this.chosenSuit = chosenSuit; + } + + /** + * Returns the number of number 7 cards played recently. + * + * @return The number of number 7 cards played recently. + */ + int get7Counter() { + return ctr7; + } + + /** + * Resets the counter of number 7 cards played to zero. + */ + void reset7Counter() { + ctr7 = 0; + } + + /** + * Increments the counter of number 7 cards played by one. + */ + void increment7Counter() { + ctr7++; + } + + /** + * Returns the current state of the game. + */ + GameState getGameState() { + //TODO implement + return null; + } + + /** + * Checks if a card can be played by the current player in the current state. + * + * @param c The card being played. + * @return True if the card can be played, false otherwise. + */ + boolean canPlay(Card c) { + //TODO implement + return false; + } +} diff --git a/src/cards/maumau/model/CardHandler.java b/src/cards/maumau/model/CardHandler.java new file mode 100644 index 0000000..c69a174 --- /dev/null +++ b/src/cards/maumau/model/CardHandler.java @@ -0,0 +1,96 @@ +package cards.maumau.model; + +import cards.Card; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +/** + * Manages the draw pile and discard pile in a MauMau game. + */ +class CardHandler { + private final MauMau game; + private final int numCardsPerPlayer; + private final List drawPile = new LinkedList<>(); + private final List discardPile = new LinkedList<>(); + + /** + * Constructs a CardHandler for the specified MauMau game, deck, and number of cards per player. + * + * @param game The MauMau game instance. + * @param deck The deck of cards. + * @param numCardsPerPlayer The number of cards per player. + */ + CardHandler(MauMau game, List deck, int numCardsPerPlayer) { + this.game = game; + this.numCardsPerPlayer = numCardsPerPlayer; + drawPile.addAll(deck); + } + + /** + * Returns the draw pile containing remaining cards. + * + * @return The draw pile. + */ + List getDrawPile() { + return drawPile; + } + + /** + * Returns the discard pile containing played cards. + * + * @return The discard pile. + */ + List getDiscardPile() { + return discardPile; + } + + /** + * Draws a card from the draw pile. + * + * @return The drawn card, or null if the draw pile is empty. + */ + Card drawCard() { + if (drawPile.isEmpty()) + reuseDiscardedCards(); + if (!drawPile.isEmpty()) + return drawPile.removeFirst(); + game.getActionHandler().cancelGame(); + return null; + } + + private void reuseDiscardedCards() { + if (discardPile.isEmpty()) return; + final Card top = discardPile.removeFirst(); + Collections.shuffle(discardPile); + drawPile.addAll(discardPile); + discardPile.clear(); + discardPile.addFirst(top); + } + + /** + * Deals cards to all players. + */ + void dealCards() { + //TODO implement + } + + /** + * Discards a card onto the discard pile. + * + * @param c The card to discard. + */ + void discard(Card c) { + discardPile.addFirst(c); + } + + /** + * Returns the top card of the discard pile. + * + * @return The top card of the discard pile. + */ + Card top() { + return discardPile.getFirst(); + } +} diff --git a/src/cards/maumau/model/GameState.java b/src/cards/maumau/model/GameState.java new file mode 100644 index 0000000..b85a2c7 --- /dev/null +++ b/src/cards/maumau/model/GameState.java @@ -0,0 +1,29 @@ +package cards.maumau.model; + +/** + * Represents the state of the Mau-Mau game. + */ +public enum GameState { + /** + * The game has been initialized, but has not yet started. + */ + GAME_INITIALIZED, + /** + * The game is over. The final ranking of players can be + * obtained using {@link MauMau#getRanking()}. + */ + GAME_OVER, + /** + * The game has been canceled due to insufficient cards. + */ + GAME_CANCELED, + /** + * The game is currently in progress with players taking turns. + */ + PLAY, + /** + * The game is in progress and the current player has played + * a Jack, and is required to choose a suit. + */ + CHOOSE_SUIT +} diff --git a/src/cards/maumau/model/IObserver.java b/src/cards/maumau/model/IObserver.java new file mode 100644 index 0000000..f5ca908 --- /dev/null +++ b/src/cards/maumau/model/IObserver.java @@ -0,0 +1,18 @@ +package cards.maumau.model; + +/** + * Interface for observing changes in the Mau-Mau game. + */ +public interface IObserver { + /** + * Method called to notify the observer of a general update in the game. + */ + void update(); + + /** + * Method called to send a message to the observer. + * + * @param msg The message to be sent. + */ + void message(String msg); +} diff --git a/src/cards/maumau/model/MauMau.java b/src/cards/maumau/model/MauMau.java new file mode 100644 index 0000000..46ae664 --- /dev/null +++ b/src/cards/maumau/model/MauMau.java @@ -0,0 +1,227 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Suit; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * Represents a Mau-Mau card game. + */ +public class MauMau { + private final ActionHandler actionHandler = new ActionHandler(this); + private final PlayerHandler playerHandler = new PlayerHandler(this); + private final CardHandler cardHandler; + private final List observers = new ArrayList<>(); + + /** + * Constructs a MauMau game with the specified parameters. + * + * @param numCardsPerPlayer The number of cards each player should have initially. + * @param deck The deck of cards to be used in the game. + */ + public MauMau(int numCardsPerPlayer, List deck) { + cardHandler = new CardHandler(this, deck, numCardsPerPlayer); + } + + /** + * Adds an observer to the game. + * + * @param observer The observer to add. + */ + public void addObserver(IObserver observer) { + observers.add(observer); + } + + /** + * Notifies all observers of the game. + */ + void notifyObservers() { + for (IObserver o : observers) + o.update(); + } + + /** + * Sends a message to all observers. + * + * @param msg The message to send. + */ + void sendMessage(String msg) { + for (IObserver o : observers) + o.message(msg); + } + + /** + * Gets the player handler for the game. + * + * @return The player handler. + */ + PlayerHandler getPlayerHandler() { + return playerHandler; + } + + /** + * Gets the card handler for the game. + * + * @return The card handler. + */ + CardHandler getCardHandler() { + return cardHandler; + } + + /** + * Gets the action handler for the game. + * + * @return The action handler. + */ + ActionHandler getActionHandler() { + return actionHandler; + } + + /** + * Returns the suit chosen by a player after playing a Jack. + * + * @return The chosen suit. + */ + public Suit getChosenSuit() { + return actionHandler.getChosenSuit(); + } + + /** + * Returns the number of number 7 cards played recently. + * + * @return The number of number 7 cards played recently. + */ + public int get7Counter() { + return actionHandler.get7Counter(); + } + + /** + * Starts the Mau-Mau game. + */ + public void startGame() { + actionHandler.startGame(); + } + + /** + * Returns a string representation of the game. + * + * @return String representation of the game. + */ + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("Game state: ").append(getGameState()).append("\n"); + sb.append("State: ").append(actionHandler).append("\n"); + sb.append("Players:\n"); + sb.append(mkString(getPlayers(), " ", "\n ")); + sb.append(mkString(getDrawPile(), "draw pile: ", " ")); + sb.append(mkString(getDiscardPile(), "discard pile: ", " ")); + sb.append(mkString(getRanking(), Player::getName, "ranking: ", ", ", "\n")); + sb.append("chosen suit: ").append(getChosenSuit()).append("\n"); + sb.append("7 count: ").append(get7Counter()).append("\n"); + return sb.toString(); + } + + /** + * Joins the elements of the list into a single string with the specified prefix and delimiter. + * + * @param list The list to join. + * @param func Function to convert list elements to strings. + * @param prefix Prefix for the resulting string. + * @param delimiter Delimiter to separate list elements. + * @param suffix Suffix for the resulting string. + * @param Type of elements in the list. + * @return Joined string representation of the list. + */ + static String mkString(List list, Function func, String prefix, String delimiter, String suffix) { + return list.stream() + .map(func) + .collect(Collectors.joining(delimiter, prefix, suffix)); + } + + /** + * Joins the elements of the list into a single string with the specified prefix and delimiter. + * + * @param list The list to join. + * @param prefix Prefix for the resulting string. + * @param delimiter Delimiter to separate list elements. + * @param Type of elements in the list. + * @return Joined string representation of the list. + */ + static String mkString(List list, String prefix, String delimiter) { + return mkString(list, Objects::toString, prefix, delimiter, "\n"); + } + + /** + * Gets the list of players still participating in the game. + * The first player in the list is the current player. + * + * @return The list of players. + */ + public List getPlayers() { + return playerHandler.getPlayers(); + } + + /** + * Adds a player to the game. + * + * @param name The name of the player. + * @return The player added to the game. + */ + public Player addPlayer(String name) { + final Player player = new Player(name, this); + actionHandler.addPlayer(player); + return player; + } + + /** + * Returns the ranking of players that have already discarded all of their cards + * and, when the game is over, also the loser. + * + * @return The ranking of players. + */ + public List getRanking() { + return playerHandler.getRanking(); + } + + /** + * Returns the current player whose turn it is. + * + * @return The current player. + */ + public Player getCurrentPlayer() { + return playerHandler.getCurrentPlayer(); + } + + /** + * Returns the draw pile containing remaining cards. + * + * @return The draw pile. + */ + public List getDrawPile() { + return cardHandler.getDrawPile(); + } + + /** + * Returns the discard pile containing played cards. + * + * @return The discard pile. + */ + public List getDiscardPile() { + return cardHandler.getDiscardPile(); + } + + /** + * Returns the current state of the game. + * + * @return The state of the game. + */ + public GameState getGameState() { + return actionHandler.getGameState(); + } +} diff --git a/src/cards/maumau/model/Player.java b/src/cards/maumau/model/Player.java new file mode 100644 index 0000000..a1ef343 --- /dev/null +++ b/src/cards/maumau/model/Player.java @@ -0,0 +1,174 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Suit; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Represents a player in a Mau-Mau card game. + */ +public class Player { + private final MauMau game; + private final String name; + private final List cards = new ArrayList<>(); + + /** + * Constructor for Player class. + * + * @param name The name of the player. + * @param game The MauMau game instance the player is part of. + */ + Player(String name, MauMau game) { + this.name = name; + this.game = game; + } + + /** + * Returns a string representation of the player, including their name and their cards. + * + * @return String representation of the player. + */ + @Override + public String toString() { + return name + cards.stream() + .map(Object::toString) + .collect(Collectors.joining(" ", " (cards ", ")")); + } + + /** + * Gets the name of the player. + * + * @return The name of the player. + */ + public String getName() { + return name; + } + + /** + * Gets the MauMau game instance the player is part of. + * + * @return The MauMau game instance. + */ + public MauMau getGame() { + return game; + } + + /** + * Gets the list of cards held by the player. + * + * @return List of cards held by the player. + */ + public List getCards() { + return cards; + } + + /** + * Draws a specified number of cards from the draw pile. + * + * @param n The number of cards to draw. + */ + void drawCards(int n) { + for (int i = 0; i < n; i++) { + final Card c = game.getCardHandler().drawCard(); + if (c == null) return; + cards.add(c); + } + } + + /** + * Plays a card from the player's hand onto the discard pile. + * + * @param c The card to be played. + */ + void playCard(Card c) { + if (!cards.remove(c)) + throw new IllegalArgumentException(this + " doesn't have " + c); + game.getCardHandler().discard(c); + } + + /** + * Checks if the player can legally play a specific card. + * + * @param c The card to check. + * @return True if the player can legally play the card, false otherwise. + */ + public boolean canPlay(Card c) { + return game.getCurrentPlayer() == this && game.getActionHandler().canPlay(c); + } + + /** + * Selects a card to play from the player's hand. + * + * @param c The card to play. + */ + public void chooseCard(Card c) { + if (isCurrentPlayer()) { + game.getActionHandler().chooseCard(c); + game.notifyObservers(); + } + } + + /** + * Chooses a suit after playing a Jack card. + * + * @param s The suit chosen by the player. + */ + public void chooseSuit(Suit s) { + if (isCurrentPlayer()) { + game.getActionHandler().chooseSuit(s); + game.notifyObservers(); + } + } + + /** + * Skips the player's turn. + */ + public void skip() { + if (isCurrentPlayer()) { + game.getActionHandler().skip(); + game.notifyObservers(); + } + } + + /** + * Executes special action when the player cannot play a seven card. + */ + public void no7() { + if (isCurrentPlayer()) { + game.getActionHandler().no7(); + game.notifyObservers(); + } + } + + /** + * Executes special action when the player calls "Mau". + */ + public void mau() { + game.getPlayerHandler().mau(this); + game.notifyObservers(); + } + + /** + * Executes special action when the player calls "Mau-Mau". + */ + public void maumau() { + game.getPlayerHandler().maumau(this); + game.notifyObservers(); + } + + /** + * Checks if the current player is this player instance. + * If not, sends a message indicating it's not their turn. + * + * @return True if it's this player's turn, false otherwise. + */ + private boolean isCurrentPlayer() { + if (this == game.getCurrentPlayer()) + return true; + game.sendMessage(String.format("It's %s's turn, not %s's.", game.getCurrentPlayer().getName(), name)); + return false; + } +} diff --git a/src/cards/maumau/model/PlayerHandler.java b/src/cards/maumau/model/PlayerHandler.java new file mode 100644 index 0000000..8a145c7 --- /dev/null +++ b/src/cards/maumau/model/PlayerHandler.java @@ -0,0 +1,106 @@ +package cards.maumau.model; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * Handles players in a MauMau game. + */ +class PlayerHandler { + private final MauMau game; + private final List players = new LinkedList<>(); + private final List ranking = new ArrayList<>(); + private Player remember; + + /** + * Constructs a PlayerHandler for the specified MauMau game. + * + * @param game The MauMau game instance. + */ + PlayerHandler(MauMau game) { + this.game = game; + } + + /** + * Initiates the next turn in the game. + * + * @param n The number of turns to proceed. + */ + void nextTurn(int n) { + //TODO implement + } + + /** + * Handles a player calling "Mau". + * + * @param p The player calling "Mau". + */ + void mau(Player p) { + //TODO implement + } + + /** + * Handles a player calling "Mau-Mau". + * + * @param p The player calling "Mau-Mau". + */ + void maumau(Player p) { + //TODO implement + } + + /** + * Returns the list of players participating in the game. + * + * @return The list of players. + */ + List getPlayers() { + return players; + } + + /** + * Returns the ranking of players based on the order they finished the game. + * + * @return The ranking of players. + */ + List getRanking() { + return ranking; + } + + /** + * Adds a player to the game. + * + * @param player The player to add. + * @throws IllegalArgumentException if a player with the same name already exists. + */ + void addPlayer(Player player) { + //TODO implement + } + + /** + * Moves to the next player's turn in the game. + * + * @param n The number of turns to proceed. + */ + private void localNextTurn(int n) { + //TODO implement + } + + /** + * Finishes a player's participation in the game. + * + * @param p The player to finish. + */ + private void finishPlayer(Player p) { + //TODO implement + } + + /** + * Returns the current player whose turn it is. + * + * @return The current player. + */ + Player getCurrentPlayer() { + return players.isEmpty() ? null : players.getFirst(); + } +} diff --git a/test/cards/CardTest.java b/test/cards/CardTest.java new file mode 100644 index 0000000..f8ffc00 --- /dev/null +++ b/test/cards/CardTest.java @@ -0,0 +1,25 @@ +package cards; + +import org.junit.Test; + +import static cards.Rank.THREE; +import static cards.Rank.TWO; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class CardTest { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void compareToTest() { + assertEquals(0, c(TWO, HEARTS).compareTo(c(TWO, HEARTS))); + assertTrue(c(TWO, HEARTS).compareTo(c(TWO, SPADES)) < 0); + assertTrue(c(TWO, SPADES).compareTo(c(TWO, HEARTS)) > 0); + assertTrue(c(TWO, SPADES).compareTo(c(THREE, HEARTS)) < 0); + assertTrue(c(THREE, HEARTS).compareTo(c(TWO, SPADES)) > 0); + } +} diff --git a/test/cards/RankTest.java b/test/cards/RankTest.java new file mode 100644 index 0000000..b2c7e24 --- /dev/null +++ b/test/cards/RankTest.java @@ -0,0 +1,37 @@ +package cards; + +import org.junit.Test; + +import static cards.Rank.ACE; +import static cards.Rank.EIGHT; +import static cards.Rank.FIVE; +import static cards.Rank.FOUR; +import static cards.Rank.JACK; +import static cards.Rank.KING; +import static cards.Rank.NINE; +import static cards.Rank.QUEEN; +import static cards.Rank.SEVEN; +import static cards.Rank.SIX; +import static cards.Rank.TEN; +import static cards.Rank.THREE; +import static cards.Rank.TWO; +import static org.junit.Assert.assertEquals; + +public class RankTest { + @Test + public void toStringTest() { + assertEquals("2", TWO.toString()); + assertEquals("3", THREE.toString()); + assertEquals("4", FOUR.toString()); + assertEquals("5", FIVE.toString()); + assertEquals("6", SIX.toString()); + assertEquals("7", SEVEN.toString()); + assertEquals("8", EIGHT.toString()); + assertEquals("9", NINE.toString()); + assertEquals("10", TEN.toString()); + assertEquals("J", JACK.toString()); + assertEquals("Q", QUEEN.toString()); + assertEquals("K", KING.toString()); + assertEquals("A", ACE.toString()); + } +} diff --git a/test/cards/SuitTest.java b/test/cards/SuitTest.java new file mode 100644 index 0000000..1020272 --- /dev/null +++ b/test/cards/SuitTest.java @@ -0,0 +1,19 @@ +package cards; + +import org.junit.Test; + +import static cards.Suit.CLUBS; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static org.junit.Assert.assertEquals; + +public class SuitTest { + @Test + public void toStringTest() { + assertEquals("♥︎", HEARTS.toString()); + assertEquals("♦︎", DIAMONDS.toString()); + assertEquals("♣︎", CLUBS.toString()); + assertEquals("♠︎", SPADES.toString()); + } +} diff --git a/test/cards/maumau/MauMauDeckTest.java b/test/cards/maumau/MauMauDeckTest.java new file mode 100644 index 0000000..e6e1665 --- /dev/null +++ b/test/cards/maumau/MauMauDeckTest.java @@ -0,0 +1,34 @@ +package cards.maumau; + +import cards.Card; +import cards.Rank; +import cards.Suit; +import org.junit.Test; + +import java.util.List; + +import static cards.Rank.ACE; +import static cards.Rank.SIX; +import static cards.Rank.TEN; +import static cards.Rank.TWO; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +public class MauMauDeckTest { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void dealCardsTest() { + final List deck = MauMauDeck.makeDeck(5); + assertEquals(160, deck.size()); + assertFalse(deck.contains(c(TWO, DIAMONDS))); + assertFalse(deck.contains(c(SIX, SPADES))); + assertEquals(5, deck.stream().filter(c -> c.equals(c(TEN, HEARTS))).count()); + assertEquals(5, deck.stream().filter(c -> c.equals(c(ACE, SPADES))).count()); + } +} diff --git a/test/cards/maumau/model/CardHandlerTest.java b/test/cards/maumau/model/CardHandlerTest.java new file mode 100644 index 0000000..e9c74ca --- /dev/null +++ b/test/cards/maumau/model/CardHandlerTest.java @@ -0,0 +1,43 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Rank; +import cards.Suit; +import org.junit.Test; + +import java.util.List; + +import static cards.Rank.ACE; +import static cards.Rank.EIGHT; +import static cards.Rank.JACK; +import static cards.Rank.KING; +import static cards.Rank.NINE; +import static cards.Rank.QUEEN; +import static cards.Rank.SEVEN; +import static cards.Rank.TEN; +import static cards.Suit.CLUBS; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class CardHandlerTest { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void dealCardsTest() { + final List deck = List.of(c(JACK, DIAMONDS), c(SEVEN, CLUBS), c(QUEEN, DIAMONDS), c(NINE, CLUBS), c(ACE, SPADES), c(NINE, SPADES), c(ACE, DIAMONDS), c(EIGHT, CLUBS), c(EIGHT, DIAMONDS), c(KING, HEARTS), c(ACE, HEARTS), c(SEVEN, SPADES), c(KING, CLUBS), c(KING, SPADES), c(QUEEN, SPADES), c(SEVEN, DIAMONDS), c(TEN, DIAMONDS), c(EIGHT, HEARTS), c(KING, DIAMONDS), c(QUEEN, CLUBS), c(JACK, HEARTS), c(EIGHT, SPADES), c(TEN, CLUBS), c(ACE, CLUBS), c(JACK, CLUBS), c(QUEEN, HEARTS), c(SEVEN, HEARTS), c(JACK, SPADES), c(NINE, DIAMONDS), c(NINE, HEARTS), c(TEN, HEARTS), c(TEN, SPADES)); + final MauMau game = new MauMau(5, deck); + final Player jacqueline = game.addPlayer("Jacqueline"); + final Player chantal = game.addPlayer("Chantal"); + assertTrue(jacqueline.getCards().isEmpty()); + assertTrue(chantal.getCards().isEmpty()); + game.getCardHandler().dealCards(); + assertEquals("[J♦︎, Q♦︎, A♠︎, A♦︎, 8♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♣︎, 9♣︎, 9♠︎, 8♣︎, K♥︎]", chantal.getCards().toString()); + assertEquals(c(ACE, HEARTS), game.getCardHandler().top()); + } +} diff --git a/test/cards/maumau/model/MauMau1Test.java b/test/cards/maumau/model/MauMau1Test.java new file mode 100644 index 0000000..52ba495 --- /dev/null +++ b/test/cards/maumau/model/MauMau1Test.java @@ -0,0 +1,181 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Rank; +import cards.Suit; +import org.junit.Test; + +import java.util.List; + +import static cards.Rank.ACE; +import static cards.Rank.EIGHT; +import static cards.Rank.JACK; +import static cards.Rank.KING; +import static cards.Rank.NINE; +import static cards.Rank.QUEEN; +import static cards.Rank.SEVEN; +import static cards.Rank.TEN; +import static cards.Suit.CLUBS; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static cards.maumau.model.GameState.CHOOSE_SUIT; +import static cards.maumau.model.GameState.GAME_INITIALIZED; +import static cards.maumau.model.GameState.GAME_OVER; +import static cards.maumau.model.GameState.PLAY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class MauMau1Test { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void game() { + final List deck = List.of(c(JACK, DIAMONDS), c(SEVEN, CLUBS), c(QUEEN, DIAMONDS), c(NINE, CLUBS), c(ACE, SPADES), c(NINE, SPADES), c(ACE, DIAMONDS), c(EIGHT, CLUBS), c(EIGHT, DIAMONDS), c(KING, HEARTS), c(ACE, HEARTS), c(SEVEN, SPADES), c(KING, CLUBS), c(KING, SPADES), c(QUEEN, SPADES), c(SEVEN, DIAMONDS), c(TEN, DIAMONDS), c(EIGHT, HEARTS), c(KING, DIAMONDS), c(QUEEN, CLUBS), c(JACK, HEARTS), c(EIGHT, SPADES), c(TEN, CLUBS), c(ACE, CLUBS), c(JACK, CLUBS), c(QUEEN, HEARTS), c(SEVEN, HEARTS), c(JACK, SPADES), c(NINE, DIAMONDS), c(NINE, HEARTS), c(TEN, HEARTS), c(TEN, SPADES)); + final MauMau game = new MauMau(5, deck); + final Player jacqueline = game.addPlayer("Jacqueline"); + final Player chantal = game.addPlayer("Chantal"); + + assertEquals(GAME_INITIALIZED, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[J♦︎, 7♣︎, Q♦︎, 9♣︎, A♠︎, 9♠︎, A♦︎, 8♣︎, 8♦︎, K♥︎, A♥︎, 7♠︎, K♣︎, K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + game.startGame(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♦︎, Q♦︎, A♠︎, A♦︎, 8♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♣︎, 9♣︎, 9♠︎, 8♣︎, K♥︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, K♣︎, K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[A♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(ACE, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♣︎, 9♣︎, 9♠︎, 8♣︎, K♥︎]", chantal.getCards().toString()); + assertEquals("[J♦︎, Q♦︎, A♦︎, 8♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♠︎, K♣︎, K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[A♠︎, A♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♦︎, Q♦︎, A♦︎, 8♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♣︎, 9♣︎, 8♣︎, K♥︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, K♣︎, K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[9♠︎, A♠︎, A♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(JACK, DIAMONDS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♦︎, A♦︎, 8♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♣︎, 9♣︎, 8♣︎, K♥︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, K♣︎, K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, 9♠︎, A♠︎, A♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseSuit(DIAMONDS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♣︎, 9♣︎, 8♣︎, K♥︎]", chantal.getCards().toString()); + assertEquals("[Q♦︎, A♦︎, 8♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♠︎, K♣︎, K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, 9♠︎, A♠︎, A♥︎]", game.getDiscardPile().toString()); + assertEquals(DIAMONDS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♦︎, A♦︎, 8♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♣︎, 9♣︎, 8♣︎, K♥︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[K♣︎, K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, 9♠︎, A♠︎, A♥︎]", game.getDiscardPile().toString()); + assertEquals(DIAMONDS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(EIGHT, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♦︎, A♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♣︎, 9♣︎, 8♣︎, K♥︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[K♣︎, K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[8♦︎, J♦︎, 9♠︎, A♠︎, A♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(QUEEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♣︎, 9♣︎, 8♣︎, K♥︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[A♦︎]", jacqueline.getCards().toString()); + assertEquals("[K♣︎, K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, 8♦︎, J♦︎, 9♠︎, A♠︎, A♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♣︎, 9♣︎, 8♣︎, K♥︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[A♦︎]", jacqueline.getCards().toString()); + assertEquals("[K♣︎, K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, 8♦︎, J♦︎, 9♠︎, A♠︎, A♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♣︎, 9♣︎, 8♣︎, K♥︎, 7♠︎, K♣︎]", chantal.getCards().toString()); + assertEquals("[K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, 8♦︎, J♦︎, 9♠︎, A♠︎, A♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(ACE, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♣︎, 9♣︎, 8♣︎, K♥︎, 7♠︎, K♣︎]", chantal.getCards().toString()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[A♦︎, Q♦︎, 8♦︎, J♦︎, 9♠︎, A♠︎, A♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.maumau(); + assertEquals(GAME_OVER, game.getGameState()); + assertEquals(List.of(), game.getPlayers()); + assertEquals(List.of(jacqueline, chantal), game.getRanking()); + assertEquals("[K♠︎, Q♠︎, 7♦︎, 10♦︎, 8♥︎, K♦︎, Q♣︎, J♥︎, 8♠︎, 10♣︎, A♣︎, J♣︎, Q♥︎, 7♥︎, J♠︎, 9♦︎, 9♥︎, 10♥︎, 10♠︎]", game.getDrawPile().toString()); + assertEquals("[A♦︎, Q♦︎, 8♦︎, J♦︎, 9♠︎, A♠︎, A♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + } +} diff --git a/test/cards/maumau/model/MauMau2Test.java b/test/cards/maumau/model/MauMau2Test.java new file mode 100644 index 0000000..29aafc0 --- /dev/null +++ b/test/cards/maumau/model/MauMau2Test.java @@ -0,0 +1,246 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Rank; +import cards.Suit; +import org.junit.Test; + +import java.util.List; + +import static cards.Rank.ACE; +import static cards.Rank.EIGHT; +import static cards.Rank.JACK; +import static cards.Rank.KING; +import static cards.Rank.NINE; +import static cards.Rank.QUEEN; +import static cards.Rank.SEVEN; +import static cards.Rank.TEN; +import static cards.Suit.CLUBS; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static cards.maumau.model.GameState.GAME_INITIALIZED; +import static cards.maumau.model.GameState.GAME_OVER; +import static cards.maumau.model.GameState.PLAY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class MauMau2Test { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void game() { + final List deck = List.of(c(KING, SPADES), c(QUEEN, DIAMONDS), c(EIGHT, DIAMONDS), c(ACE, SPADES), c(TEN, SPADES), c(EIGHT, HEARTS), c(QUEEN, SPADES), c(ACE, DIAMONDS), c(KING, DIAMONDS), c(SEVEN, SPADES), c(TEN, CLUBS), c(ACE, HEARTS), c(QUEEN, CLUBS), c(NINE, HEARTS), c(KING, CLUBS), c(SEVEN, CLUBS), c(JACK, DIAMONDS), c(NINE, DIAMONDS), c(ACE, CLUBS), c(EIGHT, SPADES), c(TEN, DIAMONDS), c(JACK, SPADES), c(JACK, HEARTS), c(JACK, CLUBS), c(TEN, HEARTS), c(KING, HEARTS), c(QUEEN, HEARTS), c(SEVEN, HEARTS), c(SEVEN, DIAMONDS), c(EIGHT, CLUBS), c(NINE, CLUBS), c(NINE, SPADES)); + final MauMau game = new MauMau(5, deck); + final Player jacqueline = game.addPlayer("Jacqueline"); + final Player chantal = game.addPlayer("Chantal"); + + assertEquals(GAME_INITIALIZED, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[K♠︎, Q♦︎, 8♦︎, A♠︎, 10♠︎, 8♥︎, Q♠︎, A♦︎, K♦︎, 7♠︎, 10♣︎, A♥︎, Q♣︎, 9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + game.startGame(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, 8♦︎, 10♠︎, Q♠︎, K♦︎]", jacqueline.getCards().toString()); + assertEquals("[Q♦︎, A♠︎, 8♥︎, A♦︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[A♥︎, Q♣︎, 9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(TEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♦︎, A♠︎, 8♥︎, A♦︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[K♠︎, 8♦︎, Q♠︎, K♦︎]", jacqueline.getCards().toString()); + assertEquals("[A♥︎, Q♣︎, 9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(SEVEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, 8♦︎, Q♠︎, K♦︎]", jacqueline.getCards().toString()); + assertEquals("[Q♦︎, A♠︎, 8♥︎, A♦︎]", chantal.getCards().toString()); + assertEquals("[A♥︎, Q♣︎, 9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + jacqueline.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, 8♦︎, Q♠︎, K♦︎, A♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♦︎, A♠︎, 8♥︎, A♦︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(EIGHT, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, 8♦︎, Q♠︎, K♦︎, A♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♦︎, A♠︎, 8♥︎, A♦︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(KING, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♦︎, A♠︎, 8♥︎, A♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, Q♠︎, K♦︎, A♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(ACE, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, Q♠︎, K♦︎, A♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♦︎, 8♥︎, A♦︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(ACE, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♦︎, 8♥︎, A♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, Q♠︎, K♦︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[A♥︎, A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(ACE, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, Q♠︎, K♦︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♦︎, 8♥︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[A♦︎, A♥︎, A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(EIGHT, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, K♦︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♦︎, 8♥︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[8♦︎, A♦︎, A♥︎, A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(KING, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♦︎, 8♥︎]", chantal.getCards().toString()); + assertEquals("[Q♠︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[K♦︎, 8♦︎, A♦︎, A♥︎, A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(QUEEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[8♥︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, K♦︎, 8♦︎, A♦︎, A♥︎, A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[8♥︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, K♦︎, 8♦︎, A♦︎, A♥︎, A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(QUEEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♥︎]", chantal.getCards().toString()); + assertEquals("[Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[Q♠︎, Q♦︎, K♦︎, 8♦︎, A♦︎, A♥︎, A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♥︎]", chantal.getCards().toString()); + assertEquals("[Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[9♥︎, K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[Q♠︎, Q♦︎, K♦︎, 8♦︎, A♦︎, A♥︎, A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[8♥︎, 9♥︎]", chantal.getCards().toString()); + assertEquals("[K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[Q♠︎, Q♦︎, K♦︎, 8♦︎, A♦︎, A♥︎, A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(QUEEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♥︎, 9♥︎]", chantal.getCards().toString()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[Q♣︎, Q♠︎, Q♦︎, K♦︎, 8♦︎, A♦︎, A♥︎, A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.maumau(); + assertEquals(GAME_OVER, game.getGameState()); + assertEquals(List.of(), game.getPlayers()); + assertEquals(List.of(jacqueline, chantal), game.getRanking()); + assertEquals("[K♣︎, 7♣︎, J♦︎, 9♦︎, A♣︎, 8♠︎, 10♦︎, J♠︎, J♥︎, J♣︎, 10♥︎, K♥︎, Q♥︎, 7♥︎, 7♦︎, 8♣︎, 9♣︎, 9♠︎]", game.getDrawPile().toString()); + assertEquals("[Q♣︎, Q♠︎, Q♦︎, K♦︎, 8♦︎, A♦︎, A♥︎, A♠︎, K♠︎, 7♠︎, 10♠︎, 10♣︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + } +} \ No newline at end of file diff --git a/test/cards/maumau/model/MauMau3Test.java b/test/cards/maumau/model/MauMau3Test.java new file mode 100644 index 0000000..612bcfd --- /dev/null +++ b/test/cards/maumau/model/MauMau3Test.java @@ -0,0 +1,173 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Rank; +import cards.Suit; +import org.junit.Test; + +import java.util.List; + +import static cards.Rank.ACE; +import static cards.Rank.KING; +import static cards.Rank.QUEEN; +import static cards.Rank.SEVEN; +import static cards.Rank.TEN; +import static cards.Suit.CLUBS; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static cards.maumau.model.GameState.GAME_CANCELED; +import static cards.maumau.model.GameState.GAME_INITIALIZED; +import static cards.maumau.model.GameState.PLAY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class MauMau3Test { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void game() { + final List deck = List.of(c(SEVEN, SPADES), c(SEVEN, DIAMONDS), c(SEVEN, DIAMONDS), c(SEVEN, SPADES), c(SEVEN, SPADES), c(SEVEN, HEARTS), c(SEVEN, SPADES), c(ACE, DIAMONDS), c(KING, DIAMONDS), c(SEVEN, SPADES), c(TEN, HEARTS), c(ACE, HEARTS), c(QUEEN, CLUBS)); + final MauMau game = new MauMau(5, deck); + final Player jacqueline = game.addPlayer("Jacqueline"); + final Player chantal = game.addPlayer("Chantal"); + + assertEquals(GAME_INITIALIZED, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[7♠︎, 7♦︎, 7♦︎, 7♠︎, 7♠︎, 7♥︎, 7♠︎, A♦︎, K♦︎, 7♠︎, 10♥︎, A♥︎, Q♣︎]", game.getDrawPile().toString()); + assertEquals("[]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + game.startGame(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♠︎, 7♦︎, 7♠︎, 7♠︎, K♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♦︎, 7♠︎, 7♥︎, A♦︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[A♥︎, Q♣︎]", game.getDrawPile().toString()); + assertEquals("[10♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♦︎, 7♠︎, 7♥︎, A♦︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, 7♦︎, 7♠︎, 7♠︎, K♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[Q♣︎]", game.getDrawPile().toString()); + assertEquals("[10♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(SEVEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♠︎, 7♦︎, 7♠︎, 7♠︎, K♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[7♦︎, 7♠︎, A♦︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[Q♣︎]", game.getDrawPile().toString()); + assertEquals("[7♥︎, 10♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♦︎, 7♠︎, A♦︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, 7♠︎, 7♠︎, K♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[Q♣︎]", game.getDrawPile().toString()); + assertEquals("[7♦︎, 7♥︎, 10♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(2, game.get7Counter()); + + chantal.chooseCard(c(SEVEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♠︎, 7♠︎, 7♠︎, K♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[7♠︎, A♦︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[Q♣︎]", game.getDrawPile().toString()); + assertEquals("[7♦︎, 7♦︎, 7♥︎, 10♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(3, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♠︎, A♦︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, 7♠︎, K♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[Q♣︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 7♦︎, 7♦︎, 7♥︎, 10♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(4, game.get7Counter()); + + chantal.chooseCard(c(SEVEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♠︎, 7♠︎, K♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[Q♣︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 7♠︎, 7♦︎, 7♦︎, 7♥︎, 10♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(5, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, 7♠︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, K♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[Q♣︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 7♠︎, 7♠︎, 7♦︎, 7♦︎, 7♥︎, 10♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(6, game.get7Counter()); + + chantal.chooseCard(c(SEVEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♠︎, K♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎]", chantal.getCards().toString()); + assertEquals("[Q♣︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 7♠︎, 7♠︎, 7♠︎, 7♦︎, 7♦︎, 7♥︎, 10♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(7, game.get7Counter()); + + chantal.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♠︎, K♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎]", chantal.getCards().toString()); + assertEquals("[Q♣︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 7♠︎, 7♠︎, 7♠︎, 7♦︎, 7♦︎, 7♥︎, 10♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(7, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎]", chantal.getCards().toString()); + assertEquals("[K♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[Q♣︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 7♠︎, 7♠︎, 7♠︎, 7♠︎, 7♦︎, 7♦︎, 7♥︎, 10♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(8, game.get7Counter()); + + chantal.no7(); + assertEquals(GAME_CANCELED, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + } +} \ No newline at end of file diff --git a/test/cards/maumau/model/MauMau4Test.java b/test/cards/maumau/model/MauMau4Test.java new file mode 100644 index 0000000..aedd9cb --- /dev/null +++ b/test/cards/maumau/model/MauMau4Test.java @@ -0,0 +1,368 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Rank; +import cards.Suit; +import org.junit.Test; + +import java.util.List; + +import static cards.Rank.ACE; +import static cards.Rank.EIGHT; +import static cards.Rank.JACK; +import static cards.Rank.KING; +import static cards.Rank.NINE; +import static cards.Rank.QUEEN; +import static cards.Rank.SEVEN; +import static cards.Rank.TEN; +import static cards.Suit.CLUBS; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static cards.maumau.model.GameState.CHOOSE_SUIT; +import static cards.maumau.model.GameState.GAME_INITIALIZED; +import static cards.maumau.model.GameState.GAME_OVER; +import static cards.maumau.model.GameState.PLAY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class MauMau4Test { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void game() { + final List deck = List.of(c(TEN, DIAMONDS), c(KING, DIAMONDS), c(JACK, CLUBS), c(TEN, SPADES), c(EIGHT, SPADES), c(JACK, HEARTS), c(SEVEN, DIAMONDS), c(JACK, SPADES), c(SEVEN, SPADES), c(QUEEN, SPADES), c(KING, SPADES), c(NINE, CLUBS), c(QUEEN, CLUBS), c(EIGHT, CLUBS), c(NINE, SPADES), c(TEN, CLUBS), c(ACE, HEARTS), c(SEVEN, HEARTS), c(NINE, DIAMONDS), c(EIGHT, HEARTS), c(SEVEN, CLUBS), c(QUEEN, DIAMONDS), c(ACE, SPADES), c(KING, HEARTS), c(QUEEN, HEARTS), c(EIGHT, DIAMONDS), c(ACE, CLUBS), c(TEN, HEARTS), c(JACK, DIAMONDS), c(NINE, HEARTS), c(KING, CLUBS), c(ACE, DIAMONDS)); + final MauMau game = new MauMau(5, deck); + final Player jacqueline = game.addPlayer("Jacqueline"); + final Player chantal = game.addPlayer("Chantal"); + + assertEquals(GAME_INITIALIZED, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[10♦︎, K♦︎, J♣︎, 10♠︎, 8♠︎, J♥︎, 7♦︎, J♠︎, 7♠︎, Q♠︎, K♠︎, 9♣︎, Q♣︎, 8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + game.startGame(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎, J♣︎, 8♠︎, 7♦︎, 7♠︎]", jacqueline.getCards().toString()); + assertEquals("[K♦︎, 10♠︎, J♥︎, J♠︎, Q♠︎]", chantal.getCards().toString()); + assertEquals("[9♣︎, Q♣︎, 8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♦︎, 10♠︎, J♥︎, J♠︎, Q♠︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, J♣︎, 8♠︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[9♣︎, Q♣︎, 8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + chantal.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♦︎, 10♠︎, J♥︎, J♠︎, Q♠︎, 9♣︎, Q♣︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, J♣︎, 8♠︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(TEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎, J♣︎, 8♠︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[K♦︎, J♥︎, J♠︎, Q♠︎, 9♣︎, Q♣︎]", chantal.getCards().toString()); + assertEquals("[8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(EIGHT, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎, J♣︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[K♦︎, J♥︎, J♠︎, Q♠︎, 9♣︎, Q♣︎]", chantal.getCards().toString()); + assertEquals("[8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(JACK, CLUBS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[K♦︎, J♥︎, J♠︎, Q♠︎, 9♣︎, Q♣︎]", chantal.getCards().toString()); + assertEquals("[8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseSuit(DIAMONDS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♦︎, J♥︎, J♠︎, Q♠︎, 9♣︎, Q♣︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertEquals(DIAMONDS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(JACK, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♦︎, J♥︎, J♠︎, Q♠︎, 9♣︎, Q♣︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertEquals(DIAMONDS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(KING, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[J♥︎, J♠︎, Q♠︎, 9♣︎, Q♣︎]", chantal.getCards().toString()); + assertEquals("[8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♥︎, J♠︎, Q♠︎, 9♣︎, Q♣︎]", chantal.getCards().toString()); + assertEquals("[10♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + jacqueline.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♥︎, J♠︎, Q♠︎, 9♣︎, Q♣︎]", chantal.getCards().toString()); + assertEquals("[10♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, 9♠︎, 10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + chantal.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♥︎, J♠︎, Q♠︎, 9♣︎, Q♣︎, 8♣︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[10♦︎]", jacqueline.getCards().toString()); + assertEquals("[10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(JACK, HEARTS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♠︎, Q♠︎, 9♣︎, Q♣︎, 8♣︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[10♦︎]", jacqueline.getCards().toString()); + assertEquals("[10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseSuit(CLUBS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎]", jacqueline.getCards().toString()); + assertEquals("[J♠︎, Q♠︎, 9♣︎, Q♣︎, 8♣︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[10♣︎, A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertEquals(CLUBS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♠︎, Q♠︎, 9♣︎, Q♣︎, 8♣︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, 10♣︎]", jacqueline.getCards().toString()); + assertEquals("[A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertEquals(CLUBS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(EIGHT, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♠︎, Q♠︎, 9♣︎, Q♣︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, 10♣︎]", jacqueline.getCards().toString()); + assertEquals("[A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎, 10♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♠︎, Q♠︎, Q♣︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(TEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♠︎, Q♠︎, Q♣︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[10♦︎]", jacqueline.getCards().toString()); + assertEquals("[A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♠︎, Q♠︎, Q♣︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[10♦︎]", jacqueline.getCards().toString()); + assertEquals("[A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(QUEEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎]", jacqueline.getCards().toString()); + assertEquals("[J♠︎, Q♠︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[A♥︎, 7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[Q♣︎, 10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♠︎, Q♠︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[Q♣︎, 10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(QUEEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[J♠︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[7♥︎, 9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[Q♠︎, Q♣︎, 10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♠︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, A♥︎, 7♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[Q♠︎, Q♣︎, 10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(JACK, SPADES)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♠︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, A♥︎, 7♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, Q♠︎, Q♣︎, 10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseSuit(SPADES); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎, A♥︎, 7♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♠︎]", chantal.getCards().toString()); + assertEquals("[9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, Q♠︎, Q♣︎, 10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertEquals(SPADES, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎, A♥︎, 7♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♠︎]", chantal.getCards().toString()); + assertEquals("[9♦︎, 8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, Q♠︎, Q♣︎, 10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertEquals(SPADES, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♠︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, A♥︎, 7♥︎, 9♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, Q♠︎, Q♣︎, 10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertEquals(SPADES, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎, A♥︎, 7♥︎, 9♦︎]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[9♠︎, J♠︎, Q♠︎, Q♣︎, 10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.maumau(); + assertEquals(GAME_OVER, game.getGameState()); + assertEquals(List.of(), game.getPlayers()); + assertEquals(List.of(chantal, jacqueline), game.getRanking()); + assertEquals("[8♥︎, 7♣︎, Q♦︎, A♠︎, K♥︎, Q♥︎, 8♦︎, A♣︎, 10♥︎, J♦︎, 9♥︎, K♣︎, A♦︎]", game.getDrawPile().toString()); + assertEquals("[9♠︎, J♠︎, Q♠︎, Q♣︎, 10♣︎, 9♣︎, 8♣︎, J♥︎, 7♦︎, K♦︎, J♣︎, 8♠︎, 10♠︎, 7♠︎, K♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + } +} \ No newline at end of file diff --git a/test/cards/maumau/model/MauMau5Test.java b/test/cards/maumau/model/MauMau5Test.java new file mode 100644 index 0000000..2b56c42 --- /dev/null +++ b/test/cards/maumau/model/MauMau5Test.java @@ -0,0 +1,533 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Rank; +import cards.Suit; +import org.junit.Test; + +import java.util.List; + +import static cards.Rank.ACE; +import static cards.Rank.EIGHT; +import static cards.Rank.JACK; +import static cards.Rank.KING; +import static cards.Rank.NINE; +import static cards.Rank.QUEEN; +import static cards.Rank.SEVEN; +import static cards.Rank.TEN; +import static cards.Suit.CLUBS; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static cards.maumau.model.GameState.CHOOSE_SUIT; +import static cards.maumau.model.GameState.GAME_INITIALIZED; +import static cards.maumau.model.GameState.GAME_OVER; +import static cards.maumau.model.GameState.PLAY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class MauMau5Test { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void game() { + final List deck = List.of(c(ACE, DIAMONDS), c(NINE, HEARTS), c(JACK, HEARTS), c(KING, SPADES), c(SEVEN, CLUBS), c(NINE, CLUBS), c(SEVEN, HEARTS), c(KING, DIAMONDS), c(TEN, HEARTS), c(ACE, CLUBS), c(JACK, SPADES), c(ACE, SPADES), c(SEVEN, DIAMONDS), c(ACE, HEARTS), c(QUEEN, SPADES), c(EIGHT, CLUBS), c(TEN, DIAMONDS), c(NINE, DIAMONDS), c(EIGHT, DIAMONDS), c(SEVEN, SPADES), c(QUEEN, HEARTS), c(JACK, CLUBS), c(KING, CLUBS), c(EIGHT, SPADES), c(JACK, DIAMONDS), c(EIGHT, HEARTS), c(QUEEN, CLUBS), c(NINE, SPADES), c(TEN, CLUBS), c(KING, HEARTS), c(TEN, SPADES), c(QUEEN, DIAMONDS)); + final MauMau game = new MauMau(5, deck); + final Player jacqueline = game.addPlayer("Jacqueline"); + final Player chantal = game.addPlayer("Chantal"); + + assertEquals(GAME_INITIALIZED, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[A♦︎, 9♥︎, J♥︎, K♠︎, 7♣︎, 9♣︎, 7♥︎, K♦︎, 10♥︎, A♣︎, J♠︎, A♠︎, 7♦︎, A♥︎, Q♠︎, 8♣︎, 10♦︎, 9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + game.startGame(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, J♥︎, 7♣︎, 7♥︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♥︎, K♠︎, 9♣︎, K♦︎, A♣︎]", chantal.getCards().toString()); + assertEquals("[A♠︎, 7♦︎, A♥︎, Q♠︎, 8♣︎, 10♦︎, 9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(JACK, HEARTS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, 7♣︎, 7♥︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♥︎, K♠︎, 9♣︎, K♦︎, A♣︎]", chantal.getCards().toString()); + assertEquals("[A♠︎, 7♦︎, A♥︎, Q♠︎, 8♣︎, 10♦︎, 9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseSuit(HEARTS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, K♠︎, 9♣︎, K♦︎, A♣︎]", chantal.getCards().toString()); + assertEquals("[A♦︎, 7♣︎, 7♥︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[A♠︎, 7♦︎, A♥︎, Q♠︎, 8♣︎, 10♦︎, 9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertEquals(HEARTS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, 7♣︎, 7♥︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, 9♣︎, K♦︎, A♣︎]", chantal.getCards().toString()); + assertEquals("[A♠︎, 7♦︎, A♥︎, Q♠︎, 8♣︎, 10♦︎, 9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, 9♣︎, K♦︎, A♣︎]", chantal.getCards().toString()); + assertEquals("[A♦︎, 7♣︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[A♠︎, 7♦︎, A♥︎, Q♠︎, 8♣︎, 10♦︎, 9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + chantal.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, 9♣︎, K♦︎, A♣︎, A♠︎, 7♦︎]", chantal.getCards().toString()); + assertEquals("[A♦︎, 7♣︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[A♥︎, Q♠︎, 8♣︎, 10♦︎, 9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(SEVEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, 7♣︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, 9♣︎, K♦︎, A♣︎, A♠︎]", chantal.getCards().toString()); + assertEquals("[A♥︎, Q♠︎, 8♣︎, 10♦︎, 9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, 9♣︎, K♦︎, A♣︎, A♠︎]", chantal.getCards().toString()); + assertEquals("[A♦︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[A♥︎, Q♠︎, 8♣︎, 10♦︎, 9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(2, game.get7Counter()); + + chantal.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, 9♣︎, K♦︎, A♣︎, A♠︎, A♥︎, Q♠︎, 8♣︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[A♦︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(EIGHT, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, 9♣︎, K♦︎, A♣︎, A♠︎, A♥︎, Q♠︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[A♦︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, K♦︎, A♣︎, A♠︎, A♥︎, Q♠︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[9♦︎, 8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, K♦︎, A♣︎, A♠︎, A♥︎, Q♠︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[A♦︎, 10♥︎, 9♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(ACE, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, 10♥︎, 9♦︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, K♦︎, A♠︎, A♥︎, Q♠︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(ACE, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, K♦︎, A♠︎, A♥︎, Q♠︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[10♥︎, 9♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(ACE, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♥︎, 9♦︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, K♦︎, A♥︎, Q♠︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, K♦︎, A♥︎, Q♠︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[10♥︎, 9♦︎, 8♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(ACE, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♥︎, 9♦︎, 8♦︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, K♦︎, Q♠︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(TEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, K♦︎, Q♠︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[9♦︎, 8♦︎]", jacqueline.getCards().toString()); + assertEquals("[7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(TEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♦︎, 8♦︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, K♦︎, Q♠︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(EIGHT, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♦︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, K♦︎, Q♠︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(NINE, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, K♦︎, Q♠︎]", chantal.getCards().toString()); + assertEquals("[7♠︎]", jacqueline.getCards().toString()); + assertEquals("[Q♥︎, J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(KING, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♠︎, Q♥︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, Q♠︎]", chantal.getCards().toString()); + assertEquals("[J♣︎, K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♠︎, Q♠︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, Q♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(KING, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♠︎, Q♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♠︎]", chantal.getCards().toString()); + assertEquals("[K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♠︎, Q♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♠︎]", chantal.getCards().toString()); + assertEquals("[K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎]", chantal.getCards().toString()); + assertEquals("[Q♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[K♣︎, 8♠︎, J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + chantal.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, K♣︎, 8♠︎]", chantal.getCards().toString()); + assertEquals("[Q♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(EIGHT, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, K♣︎]", chantal.getCards().toString()); + assertEquals("[Q♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(QUEEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[K♣︎]", chantal.getCards().toString()); + assertEquals("[J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[K♣︎]", chantal.getCards().toString()); + assertEquals("[J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(QUEEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♣︎]", chantal.getCards().toString()); + assertEquals("[J♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♣︎]", chantal.getCards().toString()); + assertEquals("[J♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎, 8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♣︎]", jacqueline.getCards().toString()); + assertEquals("[K♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(JACK, CLUBS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[K♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseSuit(CLUBS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[8♥︎, Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertEquals(CLUBS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(KING, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♥︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎]", chantal.getCards().toString()); + assertEquals("[Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[K♣︎, J♣︎, Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(EIGHT, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♥︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎]", chantal.getCards().toString()); + assertEquals("[Q♣︎, 9♠︎, 10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[K♣︎, J♣︎, Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♦︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[8♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[K♣︎, J♣︎, Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(JACK, DIAMONDS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♠︎]", chantal.getCards().toString()); + assertEquals("[8♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, K♣︎, J♣︎, Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseSuit(SPADES); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[9♠︎]", chantal.getCards().toString()); + assertEquals("[10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, K♣︎, J♣︎, Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertEquals(SPADES, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[9♠︎]", chantal.getCards().toString()); + assertEquals("[10♣︎, K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, K♣︎, J♣︎, Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertEquals(SPADES, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♠︎]", chantal.getCards().toString()); + assertEquals("[8♥︎, Q♣︎, 10♣︎]", jacqueline.getCards().toString()); + assertEquals("[K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, K♣︎, J♣︎, Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertEquals(SPADES, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♥︎, Q♣︎, 10♣︎]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[9♠︎, J♦︎, K♣︎, J♣︎, Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.maumau(); + assertEquals(GAME_OVER, game.getGameState()); + assertEquals(List.of(), game.getPlayers()); + assertEquals(List.of(chantal, jacqueline), game.getRanking()); + assertEquals("[K♥︎, 10♠︎, Q♦︎]", game.getDrawPile().toString()); + assertEquals("[9♠︎, J♦︎, K♣︎, J♣︎, Q♥︎, Q♠︎, 8♠︎, 7♠︎, K♠︎, K♦︎, 9♦︎, 8♦︎, 10♦︎, 10♥︎, A♥︎, A♠︎, A♦︎, A♣︎, 9♣︎, 8♣︎, 7♣︎, 7♦︎, 7♥︎, 9♥︎, J♥︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + } +} \ No newline at end of file diff --git a/test/cards/maumau/model/MauMau6Test.java b/test/cards/maumau/model/MauMau6Test.java new file mode 100644 index 0000000..9797741 --- /dev/null +++ b/test/cards/maumau/model/MauMau6Test.java @@ -0,0 +1,578 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Rank; +import cards.Suit; +import org.junit.Test; + +import java.util.List; + +import static cards.Rank.ACE; +import static cards.Rank.EIGHT; +import static cards.Rank.JACK; +import static cards.Rank.KING; +import static cards.Rank.NINE; +import static cards.Rank.QUEEN; +import static cards.Rank.SEVEN; +import static cards.Rank.TEN; +import static cards.Suit.CLUBS; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static cards.maumau.model.GameState.CHOOSE_SUIT; +import static cards.maumau.model.GameState.GAME_INITIALIZED; +import static cards.maumau.model.GameState.PLAY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class MauMau6Test { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void game() { + final List deck = List.of(c(QUEEN, SPADES), c(TEN, SPADES), c(SEVEN, DIAMONDS), c(EIGHT, DIAMONDS), c(ACE, SPADES), c(QUEEN, CLUBS), c(EIGHT, SPADES), c(NINE, CLUBS), c(SEVEN, SPADES), c(ACE, CLUBS), c(EIGHT, HEARTS), c(QUEEN, HEARTS), c(JACK, DIAMONDS), c(KING, CLUBS), c(NINE, HEARTS), c(EIGHT, CLUBS), c(ACE, DIAMONDS), c(QUEEN, DIAMONDS), c(JACK, HEARTS), c(TEN, HEARTS), c(KING, HEARTS), c(KING, DIAMONDS), c(JACK, SPADES), c(KING, SPADES), c(TEN, CLUBS), c(NINE, SPADES), c(JACK, CLUBS), c(SEVEN, CLUBS), c(ACE, HEARTS), c(NINE, DIAMONDS), c(TEN, DIAMONDS), c(SEVEN, HEARTS)); + final MauMau game = new MauMau(5, deck); + final Player jacqueline = game.addPlayer("Jacqueline"); + final Player chantal = game.addPlayer("Chantal"); + + assertEquals(GAME_INITIALIZED, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[Q♠︎, 10♠︎, 7♦︎, 8♦︎, A♠︎, Q♣︎, 8♠︎, 9♣︎, 7♠︎, A♣︎, 8♥︎, Q♥︎, J♦︎, K♣︎, 9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + game.startGame(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, 7♦︎, A♠︎, 8♠︎, 7♠︎]", jacqueline.getCards().toString()); + assertEquals("[10♠︎, 8♦︎, Q♣︎, 9♣︎, A♣︎]", chantal.getCards().toString()); + assertEquals("[Q♥︎, J♦︎, K♣︎, 9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(EIGHT, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, 7♦︎, A♠︎, 7♠︎]", jacqueline.getCards().toString()); + assertEquals("[10♠︎, 8♦︎, Q♣︎, 9♣︎, A♣︎]", chantal.getCards().toString()); + assertEquals("[Q♥︎, J♦︎, K♣︎, 9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♠︎, 8♦︎, Q♣︎, 9♣︎, A♣︎]", chantal.getCards().toString()); + assertEquals("[Q♠︎, 7♦︎, A♠︎]", jacqueline.getCards().toString()); + assertEquals("[Q♥︎, J♦︎, K♣︎, 9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + chantal.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♠︎, 8♦︎, Q♣︎, 9♣︎, A♣︎, Q♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[Q♠︎, 7♦︎, A♠︎]", jacqueline.getCards().toString()); + assertEquals("[K♣︎, 9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(TEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, 7♦︎, A♠︎]", jacqueline.getCards().toString()); + assertEquals("[8♦︎, Q♣︎, 9♣︎, A♣︎, Q♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[K♣︎, 9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(QUEEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, Q♣︎, 9♣︎, A♣︎, Q♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, A♠︎]", jacqueline.getCards().toString()); + assertEquals("[K♣︎, 9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(QUEEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♦︎, A♠︎]", jacqueline.getCards().toString()); + assertEquals("[8♦︎, Q♣︎, 9♣︎, A♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[K♣︎, 9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, Q♣︎, 9♣︎, A♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, A♠︎, K♣︎]", jacqueline.getCards().toString()); + assertEquals("[9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(QUEEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♦︎, A♠︎, K♣︎]", jacqueline.getCards().toString()); + assertEquals("[8♦︎, 9♣︎, A♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(KING, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, 9♣︎, A♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, A♠︎]", jacqueline.getCards().toString()); + assertEquals("[9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♦︎, A♠︎]", jacqueline.getCards().toString()); + assertEquals("[8♦︎, A♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, 8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, A♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, A♠︎, 9♥︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(ACE, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♦︎, A♠︎, 9♥︎]", jacqueline.getCards().toString()); + assertEquals("[8♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(ACE, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, 9♥︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(JACK, DIAMONDS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, 9♥︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseSuit(DIAMONDS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♦︎, 9♥︎]", jacqueline.getCards().toString()); + assertEquals("[8♦︎]", chantal.getCards().toString()); + assertEquals("[8♣︎, A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertEquals(DIAMONDS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, 8♣︎]", chantal.getCards().toString()); + assertEquals("[9♥︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, Q♦︎, J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + chantal.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, 8♣︎, A♦︎, Q♦︎]", chantal.getCards().toString()); + assertEquals("[9♥︎]", jacqueline.getCards().toString()); + assertEquals("[J♥︎, 10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(EIGHT, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♣︎, A♦︎, Q♦︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, J♥︎]", jacqueline.getCards().toString()); + assertEquals("[10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(ACE, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, J♥︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, Q♦︎]", chantal.getCards().toString()); + assertEquals("[10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(JACK, HEARTS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, Q♦︎]", chantal.getCards().toString()); + assertEquals("[10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseSuit(DIAMONDS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♣︎, Q♦︎]", chantal.getCards().toString()); + assertEquals("[9♥︎]", jacqueline.getCards().toString()); + assertEquals("[10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertEquals(DIAMONDS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♣︎, Q♦︎]", chantal.getCards().toString()); + assertEquals("[9♥︎]", jacqueline.getCards().toString()); + assertEquals("[10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertEquals(DIAMONDS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(QUEEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎]", chantal.getCards().toString()); + assertEquals("[10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎]", chantal.getCards().toString()); + assertEquals("[10♥︎, K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♣︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[K♥︎, K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, K♥︎]", chantal.getCards().toString()); + assertEquals("[K♦︎, J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♣︎, K♥︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, 10♥︎, K♦︎]", jacqueline.getCards().toString()); + assertEquals("[J♠︎, K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, 10♥︎, K♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, K♥︎, J♠︎]", chantal.getCards().toString()); + assertEquals("[K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(KING, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♣︎, K♥︎, J♠︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(KING, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, 10♥︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, J♠︎]", chantal.getCards().toString()); + assertEquals("[K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(TEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♣︎, J♠︎]", chantal.getCards().toString()); + assertEquals("[9♥︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(JACK, SPADES)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♣︎]", chantal.getCards().toString()); + assertEquals("[9♥︎]", jacqueline.getCards().toString()); + assertEquals("[K♠︎, 10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseSuit(CLUBS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, K♠︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎]", chantal.getCards().toString()); + assertEquals("[10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertEquals(CLUBS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, K♠︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎]", chantal.getCards().toString()); + assertEquals("[10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertEquals(CLUBS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(EIGHT, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, K♠︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎]", chantal.getCards().toString()); + assertEquals("[10♣︎, 9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertEquals(CLUBS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♣︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♠︎, 10♣︎]", jacqueline.getCards().toString()); + assertEquals("[9♠︎, J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertEquals(CLUBS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, K♠︎, 10♣︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertEquals(CLUBS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(TEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♣︎, 9♠︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♠︎]", jacqueline.getCards().toString()); + assertEquals("[J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[10♣︎, J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(EIGHT, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♠︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♠︎]", jacqueline.getCards().toString()); + assertEquals("[J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[8♣︎, 10♣︎, J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♠︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♠︎]", jacqueline.getCards().toString()); + assertEquals("[J♣︎, 7♣︎, A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[8♣︎, 10♣︎, J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, K♠︎]", jacqueline.getCards().toString()); + assertEquals("[9♠︎, J♣︎, 7♣︎]", chantal.getCards().toString()); + assertEquals("[A♥︎, 9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[8♣︎, 10♣︎, J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♠︎, J♣︎, 7♣︎]", chantal.getCards().toString()); + assertEquals("[9♥︎, K♠︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[8♣︎, 10♣︎, J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(SEVEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, K♠︎, A♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♠︎, J♣︎]", chantal.getCards().toString()); + assertEquals("[9♦︎, 10♦︎, 7♥︎]", game.getDrawPile().toString()); + assertEquals("[7♣︎, 8♣︎, 10♣︎, J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + jacqueline.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, K♠︎, A♥︎, 9♦︎, 10♦︎]", jacqueline.getCards().toString()); + assertEquals("[9♠︎, J♣︎]", chantal.getCards().toString()); + assertEquals("[7♥︎]", game.getDrawPile().toString()); + assertEquals("[7♣︎, 8♣︎, 10♣︎, J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(JACK, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, K♠︎, A♥︎, 9♦︎, 10♦︎]", jacqueline.getCards().toString()); + assertEquals("[9♠︎, J♣︎]", chantal.getCards().toString()); + assertEquals("[7♥︎]", game.getDrawPile().toString()); + assertEquals("[7♣︎, 8♣︎, 10♣︎, J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseSuit(SPADES); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, K♠︎, A♥︎, 9♦︎, 10♦︎]", jacqueline.getCards().toString()); + assertEquals("[9♠︎, J♣︎]", chantal.getCards().toString()); + assertEquals("[7♥︎]", game.getDrawPile().toString()); + assertEquals("[7♣︎, 8♣︎, 10♣︎, J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(KING, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♥︎, K♠︎, A♥︎, 9♦︎, 10♦︎]", jacqueline.getCards().toString()); + assertEquals("[9♠︎, J♣︎]", chantal.getCards().toString()); + assertEquals("[7♥︎]", game.getDrawPile().toString()); + assertEquals("[7♣︎, 8♣︎, 10♣︎, J♠︎, 10♥︎, K♥︎, K♦︎, Q♦︎, J♥︎, A♦︎, 8♦︎, 7♦︎, J♦︎, A♠︎, A♣︎, 9♣︎, K♣︎, Q♣︎, Q♥︎, Q♠︎, 10♠︎, 7♠︎, 8♠︎, 8♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + } +} \ No newline at end of file diff --git a/test/cards/maumau/model/MauMau7Test.java b/test/cards/maumau/model/MauMau7Test.java new file mode 100644 index 0000000..ccd90d5 --- /dev/null +++ b/test/cards/maumau/model/MauMau7Test.java @@ -0,0 +1,302 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Rank; +import cards.Suit; +import org.junit.Test; + +import java.util.List; + +import static cards.Rank.ACE; +import static cards.Rank.EIGHT; +import static cards.Rank.JACK; +import static cards.Rank.KING; +import static cards.Rank.NINE; +import static cards.Rank.QUEEN; +import static cards.Rank.SEVEN; +import static cards.Rank.TEN; +import static cards.Suit.CLUBS; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static cards.maumau.model.GameState.CHOOSE_SUIT; +import static cards.maumau.model.GameState.GAME_INITIALIZED; +import static cards.maumau.model.GameState.GAME_OVER; +import static cards.maumau.model.GameState.PLAY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class MauMau7Test { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void game() { + final List deck = List.of(c(EIGHT, DIAMONDS), c(JACK, DIAMONDS), c(ACE, DIAMONDS), c(NINE, CLUBS), c(TEN, HEARTS), c(TEN, DIAMONDS), c(NINE, SPADES), c(SEVEN, HEARTS), c(QUEEN, CLUBS), c(ACE, SPADES), c(JACK, SPADES), c(JACK, CLUBS), c(SEVEN, DIAMONDS), c(JACK, HEARTS), c(TEN, SPADES), c(QUEEN, DIAMONDS), c(EIGHT, SPADES), c(QUEEN, SPADES), c(NINE, DIAMONDS), c(QUEEN, HEARTS), c(KING, CLUBS), c(KING, HEARTS), c(NINE, HEARTS), c(KING, DIAMONDS), c(EIGHT, HEARTS), c(EIGHT, CLUBS), c(TEN, CLUBS), c(SEVEN, CLUBS), c(SEVEN, SPADES), c(ACE, HEARTS), c(KING, SPADES), c(ACE, CLUBS)); + final MauMau game = new MauMau(5, deck); + final Player jacqueline = game.addPlayer("Jacqueline"); + final Player chantal = game.addPlayer("Chantal"); + + assertEquals(GAME_INITIALIZED, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[8♦︎, J♦︎, A♦︎, 9♣︎, 10♥︎, 10♦︎, 9♠︎, 7♥︎, Q♣︎, A♠︎, J♠︎, J♣︎, 7♦︎, J♥︎, 10♠︎, Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + game.startGame(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, A♦︎, 10♥︎, 9♠︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎, 9♣︎, 10♦︎, 7♥︎, A♠︎]", chantal.getCards().toString()); + assertEquals("[J♣︎, 7♦︎, J♥︎, 10♠︎, Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(NINE, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♦︎, 9♣︎, 10♦︎, 7♥︎, A♠︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, A♦︎, 10♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♣︎, 7♦︎, J♥︎, 10♠︎, Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(ACE, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, A♦︎, 10♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎, 9♣︎, 10♦︎, 7♥︎]", chantal.getCards().toString()); + assertEquals("[J♣︎, 7♦︎, J♥︎, 10♠︎, Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(ACE, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♦︎, 9♣︎, 10♦︎, 7♥︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 10♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♣︎, 7♦︎, J♥︎, 10♠︎, Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(TEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, 10♥︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎, 9♣︎, 7♥︎]", chantal.getCards().toString()); + assertEquals("[J♣︎, 7♦︎, J♥︎, 10♠︎, Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(TEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♦︎, 9♣︎, 7♥︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♣︎, 7♦︎, J♥︎, 10♠︎, Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(SEVEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, Q♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎, 9♣︎]", chantal.getCards().toString()); + assertEquals("[J♣︎, 7♦︎, J♥︎, 10♠︎, Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + jacqueline.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, Q♣︎, J♣︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎, 9♣︎]", chantal.getCards().toString()); + assertEquals("[J♥︎, 10♠︎, Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♦︎, 9♣︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, Q♣︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♥︎, 10♠︎, Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + chantal.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♦︎, 9♣︎, J♥︎, 10♠︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, Q♣︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(JACK, DIAMONDS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♣︎, J♥︎, 10♠︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, Q♣︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseSuit(CLUBS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, Q♣︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[9♣︎, J♥︎, 10♠︎]", chantal.getCards().toString()); + assertEquals("[Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertEquals(CLUBS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(QUEEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♣︎, J♥︎, 10♠︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[Q♣︎, J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[J♥︎, 10♠︎]", chantal.getCards().toString()); + assertEquals("[Q♦︎, 8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[9♣︎, Q♣︎, J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♥︎, 10♠︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, J♣︎, Q♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♠︎, Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[9♣︎, Q♣︎, J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, J♣︎, Q♦︎]", jacqueline.getCards().toString()); + assertEquals("[J♥︎, 10♠︎, 8♠︎]", chantal.getCards().toString()); + assertEquals("[Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[9♣︎, Q♣︎, J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(JACK, CLUBS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, Q♦︎]", jacqueline.getCards().toString()); + assertEquals("[J♥︎, 10♠︎, 8♠︎]", chantal.getCards().toString()); + assertEquals("[Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, 9♣︎, Q♣︎, J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseSuit(DIAMONDS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♥︎, 10♠︎, 8♠︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, Q♦︎]", jacqueline.getCards().toString()); + assertEquals("[Q♠︎, 9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, 9♣︎, Q♣︎, J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertEquals(DIAMONDS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, Q♦︎]", jacqueline.getCards().toString()); + assertEquals("[J♥︎, 10♠︎, 8♠︎, Q♠︎]", chantal.getCards().toString()); + assertEquals("[9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, 9♣︎, Q♣︎, J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertEquals(DIAMONDS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(EIGHT, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♦︎]", jacqueline.getCards().toString()); + assertEquals("[J♥︎, 10♠︎, 8♠︎, Q♠︎]", chantal.getCards().toString()); + assertEquals("[9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[8♦︎, J♣︎, 9♣︎, Q♣︎, J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♦︎]", jacqueline.getCards().toString()); + assertEquals("[J♥︎, 10♠︎, 8♠︎, Q♠︎]", chantal.getCards().toString()); + assertEquals("[9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[8♦︎, J♣︎, 9♣︎, Q♣︎, J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(QUEEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♥︎, 10♠︎, 8♠︎, Q♠︎]", chantal.getCards().toString()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, 8♦︎, J♣︎, 9♣︎, Q♣︎, J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.maumau(); + assertEquals(GAME_OVER, game.getGameState()); + assertEquals(List.of(), game.getPlayers()); + assertEquals(List.of(jacqueline, chantal), game.getRanking()); + assertEquals("[9♦︎, Q♥︎, K♣︎, K♥︎, 9♥︎, K♦︎, 8♥︎, 8♣︎, 10♣︎, 7♣︎, 7♠︎, A♥︎, K♠︎, A♣︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, 8♦︎, J♣︎, 9♣︎, Q♣︎, J♦︎, 7♦︎, 7♥︎, 10♥︎, 10♦︎, A♦︎, A♠︎, 9♠︎, J♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + } +} \ No newline at end of file diff --git a/test/cards/maumau/model/MauMau8Test.java b/test/cards/maumau/model/MauMau8Test.java new file mode 100644 index 0000000..533d385 --- /dev/null +++ b/test/cards/maumau/model/MauMau8Test.java @@ -0,0 +1,463 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Rank; +import cards.Suit; +import org.junit.Test; + +import java.util.List; + +import static cards.Rank.ACE; +import static cards.Rank.EIGHT; +import static cards.Rank.JACK; +import static cards.Rank.KING; +import static cards.Rank.NINE; +import static cards.Rank.QUEEN; +import static cards.Rank.SEVEN; +import static cards.Rank.TEN; +import static cards.Suit.CLUBS; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static cards.maumau.model.GameState.CHOOSE_SUIT; +import static cards.maumau.model.GameState.GAME_INITIALIZED; +import static cards.maumau.model.GameState.GAME_OVER; +import static cards.maumau.model.GameState.PLAY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class MauMau8Test { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void game() { + final List deck = List.of(c(NINE, DIAMONDS), c(QUEEN, SPADES), c(EIGHT, SPADES), c(TEN, CLUBS), c(ACE, DIAMONDS), c(JACK, CLUBS), c(NINE, SPADES), c(QUEEN, DIAMONDS), c(EIGHT, HEARTS), c(TEN, SPADES), c(TEN, DIAMONDS), c(SEVEN, HEARTS), c(KING, HEARTS), c(SEVEN, CLUBS), c(NINE, HEARTS), c(SEVEN, SPADES), c(NINE, CLUBS), c(ACE, HEARTS), c(JACK, DIAMONDS), c(KING, DIAMONDS), c(EIGHT, DIAMONDS), c(JACK, SPADES), c(QUEEN, CLUBS), c(SEVEN, DIAMONDS), c(EIGHT, CLUBS), c(ACE, CLUBS), c(QUEEN, HEARTS), c(KING, CLUBS), c(TEN, HEARTS), c(ACE, SPADES), c(KING, SPADES), c(JACK, HEARTS)); + final MauMau game = new MauMau(4, deck); + final Player jacqueline = game.addPlayer("Jacqueline"); + final Player chantal = game.addPlayer("Chantal"); + final Player cheyenne = game.addPlayer("Cheyenne"); + + assertEquals(GAME_INITIALIZED, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, Q♠︎, 8♠︎, 10♣︎, A♦︎, J♣︎, 9♠︎, Q♦︎, 8♥︎, 10♠︎, 10♦︎, 7♥︎, K♥︎, 7♣︎, 9♥︎, 7♠︎, 9♣︎, A♥︎, J♦︎, K♦︎, 8♦︎, J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + game.startGame(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[Q♠︎, A♦︎, Q♦︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[8♠︎, J♣︎, 8♥︎, 7♥︎]", cheyenne.getCards().toString()); + assertEquals("[7♣︎, 9♥︎, 7♠︎, 9♣︎, A♥︎, J♦︎, K♦︎, 8♦︎, J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, A♦︎, Q♦︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[8♠︎, J♣︎, 8♥︎, 7♥︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎, 7♣︎]", jacqueline.getCards().toString()); + assertEquals("[9♥︎, 7♠︎, 9♣︎, A♥︎, J♦︎, K♦︎, 8♦︎, J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♠︎, J♣︎, 8♥︎, 7♥︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎, 7♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♠︎, A♦︎, Q♦︎, 10♦︎, 9♥︎]", chantal.getCards().toString()); + assertEquals("[7♠︎, 9♣︎, A♥︎, J♦︎, K♦︎, 8♦︎, J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(SEVEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎, 7♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♠︎, A♦︎, Q♦︎, 10♦︎, 9♥︎]", chantal.getCards().toString()); + assertEquals("[8♠︎, J♣︎, 8♥︎]", cheyenne.getCards().toString()); + assertEquals("[7♠︎, 9♣︎, A♥︎, J♦︎, K♦︎, 8♦︎, J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, A♦︎, Q♦︎, 10♦︎, 9♥︎]", chantal.getCards().toString()); + assertEquals("[8♠︎, J♣︎, 8♥︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[7♠︎, 9♣︎, A♥︎, J♦︎, K♦︎, 8♦︎, J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(2, game.get7Counter()); + + chantal.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, A♦︎, Q♦︎, 10♦︎, 9♥︎, 7♠︎, 9♣︎, A♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[8♠︎, J♣︎, 8♥︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[K♦︎, 8♦︎, J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(SEVEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♠︎, J♣︎, 8♥︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[Q♠︎, A♦︎, Q♦︎, 10♦︎, 9♥︎, 9♣︎, A♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[K♦︎, 8♦︎, J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + cheyenne.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♠︎, J♣︎, 8♥︎, K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[Q♠︎, A♦︎, Q♦︎, 10♦︎, 9♥︎, 9♣︎, A♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(EIGHT, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♠︎, A♦︎, Q♦︎, 10♦︎, 9♥︎, 9♣︎, A♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[J♣︎, 8♥︎, K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(QUEEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[J♣︎, 8♥︎, K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, 9♥︎, 9♣︎, A♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(JACK, CLUBS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♥︎, K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, 9♥︎, 9♣︎, A♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseSuit(HEARTS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, 9♥︎, 9♣︎, A♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[8♥︎, K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[J♠︎, Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertEquals(HEARTS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, 9♥︎, 9♣︎, A♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[8♥︎, K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎, J♠︎]", jacqueline.getCards().toString()); + assertEquals("[Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertEquals(HEARTS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♥︎, K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎, J♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, 9♣︎, A♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(EIGHT, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, 9♣︎, A♥︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎, J♠︎]", jacqueline.getCards().toString()); + assertEquals("[Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(ACE, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎, J♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, 9♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[Q♣︎, 7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎, J♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, 9♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[K♦︎, 8♦︎, Q♣︎]", cheyenne.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(JACK, SPADES)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, 9♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[K♦︎, 8♦︎, Q♣︎]", cheyenne.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseSuit(CLUBS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, 9♣︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[K♦︎, 8♦︎, Q♣︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertEquals(CLUBS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♦︎, 8♦︎, Q♣︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(QUEEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♦︎, 10♣︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(TEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, Q♦︎, 10♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(TEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♦︎, 8♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, Q♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(EIGHT, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, Q♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[K♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♦︎, Q♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[K♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(QUEEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[K♦︎]", cheyenne.getCards().toString()); + assertEquals("[9♦︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[Q♦︎, 8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(KING, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♦︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[]", cheyenne.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[K♦︎, Q♦︎, 8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.maumau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(cheyenne), game.getRanking()); + assertEquals("[9♦︎, 9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[A♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[K♦︎, Q♦︎, 8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(NINE, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(cheyenne), game.getRanking()); + assertEquals("[A♦︎, J♦︎]", chantal.getCards().toString()); + assertEquals("[9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[9♦︎, K♦︎, Q♦︎, 8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(ACE, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(cheyenne), game.getRanking()); + assertEquals("[9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[A♦︎, 9♦︎, K♦︎, Q♦︎, 8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(cheyenne), game.getRanking()); + assertEquals("[9♠︎, 10♠︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎]", chantal.getCards().toString()); + assertEquals("[7♦︎, 8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[A♦︎, 9♦︎, K♦︎, Q♦︎, 8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(cheyenne), game.getRanking()); + assertEquals("[J♦︎]", chantal.getCards().toString()); + assertEquals("[9♠︎, 10♠︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[A♦︎, 9♦︎, K♦︎, Q♦︎, 8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(JACK, DIAMONDS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(chantal, jacqueline), game.getPlayers()); + assertEquals(List.of(cheyenne), game.getRanking()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[9♠︎, 10♠︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, A♦︎, 9♦︎, K♦︎, Q♦︎, 8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseSuit(DIAMONDS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(cheyenne), game.getRanking()); + assertEquals("[9♠︎, 10♠︎, 7♦︎]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, A♦︎, 9♦︎, K♦︎, Q♦︎, 8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertEquals(DIAMONDS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.maumau(); + assertEquals(GAME_OVER, game.getGameState()); + assertEquals(List.of(), game.getPlayers()); + assertEquals(List.of(cheyenne, chantal, jacqueline), game.getRanking()); + assertEquals("[8♣︎, A♣︎, Q♥︎, K♣︎, 10♥︎, A♠︎, K♠︎, J♥︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, A♦︎, 9♦︎, K♦︎, Q♦︎, 8♦︎, 10♦︎, 10♣︎, Q♣︎, 9♣︎, J♠︎, A♥︎, 8♥︎, 9♥︎, J♣︎, Q♠︎, 8♠︎, 7♠︎, 7♣︎, 7♥︎, K♥︎]", game.getDiscardPile().toString()); + assertEquals(DIAMONDS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + } +} \ No newline at end of file diff --git a/test/cards/maumau/model/MauMau9Test.java b/test/cards/maumau/model/MauMau9Test.java new file mode 100644 index 0000000..0de4807 --- /dev/null +++ b/test/cards/maumau/model/MauMau9Test.java @@ -0,0 +1,403 @@ +package cards.maumau.model; + +import cards.Card; +import cards.Rank; +import cards.Suit; +import org.junit.Test; + +import java.util.List; + +import static cards.Rank.ACE; +import static cards.Rank.EIGHT; +import static cards.Rank.JACK; +import static cards.Rank.KING; +import static cards.Rank.NINE; +import static cards.Rank.QUEEN; +import static cards.Rank.SEVEN; +import static cards.Rank.TEN; +import static cards.Suit.CLUBS; +import static cards.Suit.DIAMONDS; +import static cards.Suit.HEARTS; +import static cards.Suit.SPADES; +import static cards.maumau.model.GameState.CHOOSE_SUIT; +import static cards.maumau.model.GameState.GAME_INITIALIZED; +import static cards.maumau.model.GameState.GAME_OVER; +import static cards.maumau.model.GameState.PLAY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class MauMau9Test { + private static Card c(Rank r, Suit s) { + return new Card(r, s); + } + + @Test + public void game() { + final List deck = List.of(c(ACE, HEARTS), c(SEVEN, CLUBS), c(EIGHT, DIAMONDS), c(TEN, CLUBS), c(QUEEN, HEARTS), c(TEN, SPADES), c(SEVEN, DIAMONDS), c(SEVEN, HEARTS), c(KING, DIAMONDS), c(JACK, CLUBS), c(NINE, DIAMONDS), c(TEN, HEARTS), c(SEVEN, SPADES), c(KING, CLUBS), c(KING, HEARTS), c(QUEEN, DIAMONDS), c(NINE, CLUBS), c(ACE, SPADES), c(EIGHT, HEARTS), c(TEN, DIAMONDS), c(JACK, DIAMONDS), c(ACE, CLUBS), c(QUEEN, CLUBS), c(JACK, HEARTS), c(NINE, SPADES), c(EIGHT, SPADES), c(QUEEN, SPADES), c(JACK, SPADES), c(ACE, DIAMONDS), c(NINE, HEARTS), c(KING, SPADES), c(EIGHT, CLUBS)); + final MauMau game = new MauMau(4, deck); + final Player jacqueline = game.addPlayer("Jacqueline"); + final Player chantal = game.addPlayer("Chantal"); + final Player cheyenne = game.addPlayer("Cheyenne"); + + assertEquals(GAME_INITIALIZED, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[]", cheyenne.getCards().toString()); + assertEquals("[A♥︎, 7♣︎, 8♦︎, 10♣︎, Q♥︎, 10♠︎, 7♦︎, 7♥︎, K♦︎, J♣︎, 9♦︎, 10♥︎, 7♠︎, K♣︎, K♥︎, Q♦︎, 9♣︎, A♠︎, 8♥︎, 10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + game.startGame(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♥︎, 10♣︎, 7♦︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[7♣︎, Q♥︎, 7♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 10♠︎, K♦︎, 10♥︎]", cheyenne.getCards().toString()); + assertEquals("[K♣︎, K♥︎, Q♦︎, 9♣︎, A♠︎, 8♥︎, 10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(SEVEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♣︎, Q♥︎, 7♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 10♠︎, K♦︎, 10♥︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎, 10♣︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[K♣︎, K♥︎, Q♦︎, 9♣︎, A♠︎, 8♥︎, 10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + chantal.chooseCard(c(SEVEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, 10♠︎, K♦︎, 10♥︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎, 10♣︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[7♣︎, Q♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[K♣︎, K♥︎, Q♦︎, 9♣︎, A♠︎, 8♥︎, 10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(2, game.get7Counter()); + + cheyenne.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, 10♠︎, K♦︎, 10♥︎, K♣︎, K♥︎, Q♦︎, 9♣︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎, 10♣︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[7♣︎, Q♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[A♠︎, 8♥︎, 10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(TEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♥︎, 10♣︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[7♣︎, Q♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♣︎, K♥︎, Q♦︎, 9♣︎]", cheyenne.getCards().toString()); + assertEquals("[A♠︎, 8♥︎, 10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(TEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[7♣︎, Q♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♣︎, K♥︎, Q♦︎, 9♣︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[A♠︎, 8♥︎, 10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(SEVEN, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♣︎, K♥︎, Q♦︎, 9♣︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[A♠︎, 8♥︎, 10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(1, game.get7Counter()); + + cheyenne.no7(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♣︎, K♥︎, Q♦︎, 9♣︎, A♠︎, 8♥︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(KING, CLUBS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♥︎, J♣︎]", jacqueline.getCards().toString()); + assertEquals("[Q♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♥︎, Q♦︎, 9♣︎, A♠︎, 8♥︎]", cheyenne.getCards().toString()); + assertEquals("[10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(JACK, CLUBS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[Q♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♥︎, Q♦︎, 9♣︎, A♠︎, 8♥︎]", cheyenne.getCards().toString()); + assertEquals("[10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseSuit(HEARTS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♥︎, Q♦︎, 9♣︎, A♠︎, 8♥︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertEquals(HEARTS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[Q♥︎, 9♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♥︎, Q♦︎, 9♣︎, A♠︎, 8♥︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertEquals(HEARTS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(QUEEN, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♥︎, Q♦︎, 9♣︎, A♠︎, 8♥︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♦︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♥︎, Q♦︎, 9♣︎, A♠︎, 8♥︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♦︎]", chantal.getCards().toString()); + assertEquals("[10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(EIGHT, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♦︎]", chantal.getCards().toString()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[10♦︎, J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[8♦︎, 10♠︎, K♦︎, K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[9♦︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(EIGHT, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[9♦︎, 10♦︎]", chantal.getCards().toString()); + assertEquals("[10♠︎, K♦︎, K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(NINE, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♠︎, K♦︎, K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[10♦︎]", chantal.getCards().toString()); + assertEquals("[J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♠︎, K♦︎, K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[10♦︎]", chantal.getCards().toString()); + assertEquals("[J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(KING, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, chantal, cheyenne), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[10♦︎]", chantal.getCards().toString()); + assertEquals("[10♠︎, K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[J♦︎, A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[K♦︎, 9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.skip(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(chantal, cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♦︎]", chantal.getCards().toString()); + assertEquals("[10♠︎, K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎, J♦︎]", jacqueline.getCards().toString()); + assertEquals("[A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[K♦︎, 9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.chooseCard(c(TEN, DIAMONDS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline, chantal), game.getPlayers()); + assertEquals(List.of(), game.getRanking()); + assertEquals("[10♠︎, K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎, J♦︎]", jacqueline.getCards().toString()); + assertEquals("[]", chantal.getCards().toString()); + assertEquals("[A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[10♦︎, K♦︎, 9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + chantal.maumau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(chantal), game.getRanking()); + assertEquals("[10♠︎, K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎, J♦︎]", jacqueline.getCards().toString()); + assertEquals("[A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[10♦︎, K♦︎, 9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(TEN, SPADES)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, cheyenne), game.getPlayers()); + assertEquals(List.of(chantal), game.getRanking()); + assertEquals("[A♥︎, J♦︎]", jacqueline.getCards().toString()); + assertEquals("[K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[10♠︎, 10♦︎, K♦︎, 9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(JACK, DIAMONDS)); + assertEquals(CHOOSE_SUIT, game.getGameState()); + assertEquals(List.of(jacqueline, cheyenne), game.getPlayers()); + assertEquals(List.of(chantal), game.getRanking()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, 10♠︎, 10♦︎, K♦︎, 9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseSuit(HEARTS); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(chantal), game.getRanking()); + assertEquals("[K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, 10♠︎, 10♦︎, K♦︎, 9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertEquals(HEARTS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.mau(); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(chantal), game.getRanking()); + assertEquals("[K♥︎, Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[J♦︎, 10♠︎, 10♦︎, K♦︎, 9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertEquals(HEARTS, game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + cheyenne.chooseCard(c(KING, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(jacqueline, cheyenne), game.getPlayers()); + assertEquals(List.of(chantal), game.getRanking()); + assertEquals("[A♥︎]", jacqueline.getCards().toString()); + assertEquals("[Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[K♥︎, J♦︎, 10♠︎, 10♦︎, K♦︎, 9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.chooseCard(c(ACE, HEARTS)); + assertEquals(PLAY, game.getGameState()); + assertEquals(List.of(cheyenne, jacqueline), game.getPlayers()); + assertEquals(List.of(chantal), game.getRanking()); + assertEquals("[Q♦︎, 9♣︎, A♠︎]", cheyenne.getCards().toString()); + assertEquals("[]", jacqueline.getCards().toString()); + assertEquals("[A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[A♥︎, K♥︎, J♦︎, 10♠︎, 10♦︎, K♦︎, 9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + + jacqueline.maumau(); + assertEquals(GAME_OVER, game.getGameState()); + assertEquals(List.of(), game.getPlayers()); + assertEquals(List.of(chantal, jacqueline, cheyenne), game.getRanking()); + assertEquals("[A♣︎, Q♣︎, J♥︎, 9♠︎, 8♠︎, Q♠︎, J♠︎, A♦︎, 9♥︎, K♠︎, 8♣︎]", game.getDrawPile().toString()); + assertEquals("[A♥︎, K♥︎, J♦︎, 10♠︎, 10♦︎, K♦︎, 9♦︎, 8♦︎, 8♥︎, Q♥︎, J♣︎, K♣︎, 7♣︎, 10♣︎, 10♥︎, 7♥︎, 7♦︎, 7♠︎]", game.getDiscardPile().toString()); + assertNull(game.getChosenSuit()); + assertEquals(0, game.get7Counter()); + } +}