Package it.polimi.ingsw.model
Class Game
- java.lang.Object
-
- it.polimi.ingsw.model.Game
-
public class Game extends Object
This is the Game Class, it is used to manage the data of the game.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canEndTurn()
Check if the current player can end the turnvoid
chooseAction(int[] position)
Use an action for current playervoid
choosePlayer(String targetUsername)
Set start playervoid
chooseWorker(int position)
Choose a worker for current playerAction[][][]
getActions()
Get a copy of available actions for the player in this turnCell[][]
getBoard()
Get a copy of the Game BoardList<Color>
getColors()
Get available colors to pickString
getCurrentPlayer()
Get Current Player's usernameArrayList<God>
getGodList()
Get a copy of Gods used in this gameGamePhase
getPhase()
Get current Game PhaseArrayList<Player>
getPlayerList()
Get a copy of Game PlayerListvoid
quitPlayer()
End the current game.void
setColor(Color color)
Set color for current playervoid
setGod(God god)
Set the god for the current playervoid
setGodList(God god)
Set gods to use in this game (one god at the time)void
setWorkers(int position)
Set/Place a worker for current player
-
-
-
Field Detail
-
mode
public final GameMode mode
GameMode of this game
-
-
Constructor Detail
-
Game
public Game(GameMode mode, List<String> players)
Create a new game with the specified mode and players- Parameters:
mode
- the game modeplayers
- all players'username- Throws:
IllegalArgumentException
- if repeated username or wrong number of players
-
-
Method Detail
-
canEndTurn
public boolean canEndTurn()
Check if the current player can end the turn- Returns:
- True if can end turn, otherwise False
-
getPhase
public GamePhase getPhase()
Get current Game Phase- Returns:
- current GamePhase
-
getCurrentPlayer
public String getCurrentPlayer()
Get Current Player's username- Returns:
- current player's username
-
getPlayerList
public ArrayList<Player> getPlayerList()
Get a copy of Game PlayerList- Returns:
- a copy of current players list
-
getGodList
public ArrayList<God> getGodList()
Get a copy of Gods used in this game- Returns:
- a copy of current gods list for the game
-
getBoard
public Cell[][] getBoard()
Get a copy of the Game Board- Returns:
- a copy of current game board
-
getActions
public Action[][][] getActions()
Get a copy of available actions for the player in this turn- Returns:
- a copy of available actions for the player in this turn
-
quitPlayer
public void quitPlayer()
End the current game. It sets all players in IDLE mode if not WIN or LOSE
-
setGod
public void setGod(God god)
Set the god for the current player- Parameters:
god
- god to set
-
setGodList
public void setGodList(God god)
Set gods to use in this game (one god at the time)- Parameters:
god
- god to set
-
setColor
public void setColor(Color color)
Set color for current player- Parameters:
color
- chosen color
-
setWorkers
public void setWorkers(int position)
Set/Place a worker for current player- Parameters:
position
- worker position in ( row * 5 + col ) format, 0 <= position < 25
-
chooseWorker
public void chooseWorker(int position)
Choose a worker for current player- Parameters:
position
- worker position in (row * 5 + col) format, 0 <= position < 25
-
chooseAction
public void chooseAction(int[] position)
Use an action for current player- Parameters:
position
- action position in [(row * 5 + col), dim] format, 0 <= (row * 5 + col) < 25 and 0 <= dim < 3
-
choosePlayer
public void choosePlayer(String targetUsername)
Set start player- Parameters:
targetUsername
- start player username- Throws:
IndexOutOfBoundsException
- if username not exists
-
-