Add: JavaDoc for Game getters and fields

This commit is contained in:
MatteoPellegrino05
2026-04-19 17:44:43 +02:00
parent 1413dc2c5f
commit f83a979519
@@ -18,41 +18,107 @@ import java.io.Serializable;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; 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 { public class Game implements Serializable {
/**
* The list of players participating in the game.
*/
private ArrayList<Player> playersList; private ArrayList<Player> playersList;
/**
* The current state of the game.
*/
private CurrentState currentState; private CurrentState currentState;
/**
* The mapping between slots and the players assigned to them.
*/
private HashMap<Slot,Player> slotMap; private HashMap<Slot,Player> slotMap;
/**
* The configured number of players for this game.
*/
private int nPlayers; private int nPlayers;
/**
* The queue of players involved in optional card resolution.
*/
private Queue<Player> OptionalCardQueue; private Queue<Player> OptionalCardQueue;
/**
* The order logic card associated with this game.
*/
private OrderLogicCard orderLogicCard; private OrderLogicCard orderLogicCard;
/**
* The board associated with this game.
*/
private Board board; 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 List<TribeCard>getUpperListTribeCards() { public List<TribeCard>getUpperListTribeCards() {
List<TribeCard> cards = new ArrayList<>(); List<TribeCard> cards = new ArrayList<>();
board.upperListTribe.forEach(x->cards.add(x.clone())); board.upperListTribe.forEach(x->cards.add(x.clone()));
return cards; 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 List<TribeCard>getLowerListTribeCards() { public List<TribeCard>getLowerListTribeCards() {
List<TribeCard> cards = new ArrayList<>(); List<TribeCard> cards = new ArrayList<>();
board.lowerListTribe.forEach(x->cards.add(x.clone())); board.lowerListTribe.forEach(x->cards.add(x.clone()));
return cards; 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 List<BuildingCard>getUpperListBuilding() { public List<BuildingCard>getUpperListBuilding() {
List<BuildingCard> cards = new ArrayList<>(); List<BuildingCard> cards = new ArrayList<>();
board.upperListBuilding.forEach(x->cards.add(x.clone())); board.upperListBuilding.forEach(x->cards.add(x.clone()));
return cards; 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 List<BuildingCard>getLowerListBuilding() { public List<BuildingCard>getLowerListBuilding() {
List<BuildingCard> cards = new ArrayList<>(); List<BuildingCard> cards = new ArrayList<>();
board.lowerListBuilding.forEach(x->cards.add(x.clone())); board.lowerListBuilding.forEach(x->cards.add(x.clone()));
return cards; return cards;
} }
/**
* Returns the current state of the game.
*
* @return the current state of the game.
*/
public CurrentState getCurrentState() { public CurrentState getCurrentState() {
return currentState; 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 { public Player getPlayerByUsername(String Username) throws IndexOutOfBoundsException {
return playersList.stream().filter(x->x.getUserName().equals(Username)).findFirst().orElse(null); return playersList.stream().filter(x->x.getUserName().equals(Username)).findFirst().orElse(null);
} }