initial commit
This commit is contained in:
153
src/cards/maumau/model/ActionHandler.java
Normal file
153
src/cards/maumau/model/ActionHandler.java
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
96
src/cards/maumau/model/CardHandler.java
Normal file
96
src/cards/maumau/model/CardHandler.java
Normal file
@@ -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<Card> drawPile = new LinkedList<>();
|
||||
private final List<Card> 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<Card> deck, int numCardsPerPlayer) {
|
||||
this.game = game;
|
||||
this.numCardsPerPlayer = numCardsPerPlayer;
|
||||
drawPile.addAll(deck);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the draw pile containing remaining cards.
|
||||
*
|
||||
* @return The draw pile.
|
||||
*/
|
||||
List<Card> getDrawPile() {
|
||||
return drawPile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the discard pile containing played cards.
|
||||
*
|
||||
* @return The discard pile.
|
||||
*/
|
||||
List<Card> 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();
|
||||
}
|
||||
}
|
||||
29
src/cards/maumau/model/GameState.java
Normal file
29
src/cards/maumau/model/GameState.java
Normal file
@@ -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
|
||||
}
|
||||
18
src/cards/maumau/model/IObserver.java
Normal file
18
src/cards/maumau/model/IObserver.java
Normal file
@@ -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);
|
||||
}
|
||||
227
src/cards/maumau/model/MauMau.java
Normal file
227
src/cards/maumau/model/MauMau.java
Normal file
@@ -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<IObserver> 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<Card> 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 <A> Type of elements in the list.
|
||||
* @return Joined string representation of the list.
|
||||
*/
|
||||
static <A> String mkString(List<A> list, Function<? super A, String> 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 <A> Type of elements in the list.
|
||||
* @return Joined string representation of the list.
|
||||
*/
|
||||
static <A> String mkString(List<A> 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<Player> 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<Player> 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<Card> getDrawPile() {
|
||||
return cardHandler.getDrawPile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the discard pile containing played cards.
|
||||
*
|
||||
* @return The discard pile.
|
||||
*/
|
||||
public List<Card> getDiscardPile() {
|
||||
return cardHandler.getDiscardPile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current state of the game.
|
||||
*
|
||||
* @return The state of the game.
|
||||
*/
|
||||
public GameState getGameState() {
|
||||
return actionHandler.getGameState();
|
||||
}
|
||||
}
|
||||
174
src/cards/maumau/model/Player.java
Normal file
174
src/cards/maumau/model/Player.java
Normal file
@@ -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<Card> 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<Card> 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;
|
||||
}
|
||||
}
|
||||
106
src/cards/maumau/model/PlayerHandler.java
Normal file
106
src/cards/maumau/model/PlayerHandler.java
Normal file
@@ -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<Player> players = new LinkedList<>();
|
||||
private final List<Player> 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<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ranking of players based on the order they finished the game.
|
||||
*
|
||||
* @return The ranking of players.
|
||||
*/
|
||||
List<Player> 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user