Package it.polimi.ingsw.Server.Model
Class Game
java.lang.Object
it.polimi.ingsw.Server.Model.Game
This class contains general information about the current game, such as CommonGoalCards and number of Players.
-
Field Summary
Modifier and TypeFieldDescriptionprivate Board
board used in the gameprivate CommonGoalCard
It's the first CommonGoalCard drawn for the gameprivate CommonGoalCard
It's the second CommonGoalCard drawn for the gameprivate boolean
this attribute is true if a player has already filled his/her shelf, false otherwiseprivate final String
Identifier is the game id.final int
final attribute, which indicates the maximum number of players who can join a gameprivate final int
Number of players, chosen by the first player, when he/she creates a new gameprivate List<ObjectCard>
Object Cards extracted in the related gameprivate final List<PersonalGoalCard>
List of personalCards associated to each playerprivate int
number of players who have already joined the gameMap used to store Players, associated to an Integer key, which indicates their position in the gameprivate boolean
this attribute is true if the game has startedprivate Scoreboard
Game scoreboard -
Constructor Summary
ConstructorDescriptiongame constructorGame
(String identifier, Map<Integer, Player> players, int maxPlayers, List<PersonalGoalCard> personalCards, Scoreboard scoreboard, Board board, int playerCount, CommonGoalCard cgCard1, CommonGoalCard cgCard2, List<ObjectCard> objectCards, boolean gameEnded, boolean prepared) Related to Game's refresh strategy -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkEndGame
(Player activePlayer) This method checks if the active player has completely filled his/her shelfboolean
This method is used for endgame procedures, such as final scoring.getBoard()
Getter method for the boardthis method is a getter for CommonGoalCardsint
Getter method for the attribute, which indicates the maximum number of players, who can join the gamethis method is a getter of PersonalGoalCard obtained from nicknamegetPlayerFromNickname
(String nickname) getter method to recognize a player from nicknameGetter method for players.this method is a getter for attribute scoreboardgetScoreCardsFromNickname
(String nickname) this method is a getter for ScoreCards obtained from NicknamegetShelfFromNickname
(String nickname) this method is a getter for player's shelf obtained from nicknamegetShelfInterfaceFromNickname
(String nickname) this method is a getter for the shelf interface obtained from nicknameboolean
this method is a getter for attribute gameEndedboolean
This method indicates if the game is preparedThis method adds a new player to "players" Map.This method returns a list of nicknames of the players, who are playing a game (if game isn't null), null otherwisevoid
This method includes setup procedures, such as drawing personal goal cards and common goal cards, choosing randomly the first player and placing ObjectCards on the board.Objects refresh following a game reloaded from a persistency file
-
Field Details
-
MAX_PLAYERS
public final int MAX_PLAYERSfinal attribute, which indicates the maximum number of players who can join a game- See Also:
-
identifier
Identifier is the game id. It is chosen by the first player, who joins the game, and it can be used by other players to join a pre-existing game -
players
Map used to store Players, associated to an Integer key, which indicates their position in the game -
maxPlayers
private final int maxPlayersNumber of players, chosen by the first player, when he/she creates a new game -
personalCards
List of personalCards associated to each player -
scoreboard
Game scoreboard -
board
board used in the game -
playerCount
private int playerCountnumber of players who have already joined the game -
cgCard1
It's the first CommonGoalCard drawn for the game -
cgCard2
It's the second CommonGoalCard drawn for the game -
objectCards
Object Cards extracted in the related game -
gameEnded
private boolean gameEndedthis attribute is true if a player has already filled his/her shelf, false otherwise -
prepared
private boolean preparedthis attribute is true if the game has started
-
-
Constructor Details
-
Game
game constructor- Parameters:
identifier
- ID of the game, chosen by the Player who creates the gamemaxPlayers
- maximum number of players, who can join the game (chosen by the first player)- Throws:
Exception
- if the maximum number of players is higher than the MAX_PLAYERS number
-
Game
public Game(String identifier, Map<Integer, Player> players, int maxPlayers, List<PersonalGoalCard> personalCards, Scoreboard scoreboard, Board board, int playerCount, CommonGoalCard cgCard1, CommonGoalCard cgCard2, List<ObjectCard> objectCards, boolean gameEnded, boolean prepared) Related to Game's refresh strategy
-
-
Method Details
-
getBoard
Getter method for the board- Returns:
- Board
-
getMaxPlayers
public int getMaxPlayers()Getter method for the attribute, which indicates the maximum number of players, who can join the game- Returns:
- maxPlayers
-
getPlayers
Getter method for players. An integer is associated to each Player, who is playing the game- Returns:
- a map of Players
-
newPlayer
This method adds a new player to "players" Map.- Parameters:
newNickname
- player's nickname- Returns:
- Player who's been added to players
- Throws:
RemoteException
- if the new instance of class Player hasn't been created
-
getPlayerFromNickname
getter method to recognize a player from nickname- Parameters:
nickname
- player's nickname- Returns:
- players if nickname != null, null otherwise
-
getShelfInterfaceFromNickname
this method is a getter for the shelf interface obtained from nickname- Parameters:
nickname
- player's nickname- Returns:
- player's shelf interface
-
getPersonalGoalCardInterfaceFromNickname
this method is a getter of PersonalGoalCard obtained from nickname- Parameters:
nickname
- player's nickname- Returns:
- player's PersonalGoalCard
-
getCommonGoalCards
this method is a getter for CommonGoalCards- Returns:
- a list of CommonGoalCards
-
getShelfFromNickname
this method is a getter for player's shelf obtained from nickname- Parameters:
nickname
- player's nickname- Returns:
- player's shelf
-
getScoreCardsFromNickname
this method is a getter for ScoreCards obtained from Nickname- Parameters:
nickname
- player's nickname- Returns:
- a stack of player's ScoreCard
-
nicknames
This method returns a list of nicknames of the players, who are playing a game (if game isn't null), null otherwise- Returns:
- a list of player's nicknames
-
prepareGame
This method includes setup procedures, such as drawing personal goal cards and common goal cards, choosing randomly the first player and placing ObjectCards on the board.- Throws:
Exception
- if the number of drawn personal goal cards has exceeded the limit
-
isPrepared
public boolean isPrepared()This method indicates if the game is prepared- Returns:
- true if the game is prepared, false otherwise
-
checkEndGame
This method checks if the active player has completely filled his/her shelf- Parameters:
activePlayer
- represents the player who is playing in the current turn- Returns:
- true if the player has filled all the spaces, false otherwise
- Throws:
Exception
- If the coordinates are invalid
-
gameComplete
This method is used for endgame procedures, such as final scoring.- Returns:
- true if the game is completed, false otherwise
- Throws:
Exception
- if updateScore() throws an Exception
-
getScoreboard
this method is a getter for attribute scoreboard- Returns:
- scoreboard
-
isGameEnded
public boolean isGameEnded()this method is a getter for attribute gameEnded- Returns:
- true if game has ended, false otherwise
-
refreshEntities
Objects refresh following a game reloaded from a persistency file- Returns:
- the refreshed game
- Throws:
RemoteException
- Related to RMI
-