diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java index 98507e0..c03c38f 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java @@ -18,41 +18,107 @@ import java.io.Serializable; import java.util.*; import java.util.stream.Collectors; +/** + * Represents the main game model. + * A Game object stores the players, the current state of the match, + * the slot assignments, the board, and the logic required to manage the game flow. + */ public class Game implements Serializable { + /** + * The list of players participating in the game. + */ private ArrayList playersList; + + /** + * The current state of the game. + */ private CurrentState currentState; + + /** + * The mapping between slots and the players assigned to them. + */ private HashMap slotMap; + + /** + * The configured number of players for this game. + */ private int nPlayers; + + /** + * The queue of players involved in optional card resolution. + */ private Queue OptionalCardQueue; + + /** + * The order logic card associated with this game. + */ private OrderLogicCard orderLogicCard; + + /** + * The board associated with this game. + */ private Board board; - + /** + * Returns clones of the upper tribe cards currently available on the board. + * + * @return a list containing clones of the upper tribe cards currently available on the board. + */ public ListgetUpperListTribeCards() { List cards = new ArrayList<>(); board.upperListTribe.forEach(x->cards.add(x.clone())); return cards; } + + /** + * Returns clones of the lower tribe cards currently available on the board. + * + * @return a list containing clones of the lower tribe cards currently available on the board. + */ public ListgetLowerListTribeCards() { List cards = new ArrayList<>(); board.lowerListTribe.forEach(x->cards.add(x.clone())); return cards; } + + /** + * Returns clones of the upper building cards currently available on the board. + * + * @return a list containing clones of the upper building cards currently available on the board. + */ public ListgetUpperListBuilding() { List cards = new ArrayList<>(); board.upperListBuilding.forEach(x->cards.add(x.clone())); return cards; } + + /** + * Returns clones of the lower building cards currently available on the board. + * + * @return a list containing clones of the lower building cards currently available on the board. + */ public ListgetLowerListBuilding() { List cards = new ArrayList<>(); board.lowerListBuilding.forEach(x->cards.add(x.clone())); return cards; } + + /** + * Returns the current state of the game. + * + * @return the current state of the game. + */ public CurrentState getCurrentState() { return currentState; }; + /** + * Returns the player with the specified username, if present. + * + * @param Username the username of the player to search for. + * @return the player with the specified username, or {@code null} if no such player exists. + */ public Player getPlayerByUsername(String Username) throws IndexOutOfBoundsException { return playersList.stream().filter(x->x.getUserName().equals(Username)).findFirst().orElse(null); }