java.lang.Object
model.logic.host.TurnManager
- All Implemented Interfaces:
Serializable
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTurnManager(Map<Integer, Player> players) The TurnManager function is responsible for keeping track of the order in which players take their turns. -
Method Summary
Modifier and TypeMethodDescriptionintThe getCurrentPlayerTurn function returns the current player's turn.The getPlayersTurn function returns the list of players who have not yet had their turn.intThe getTurnManagerIndex function returns the index of the current player in turn.voidnextTurn()The nextTurn function is used to change the current player turn.voidremovePlayer(int playerId) The removePlayer function removes a player from the game.voidsetCurrentPlayerTurn(int newTurn) The setCurrentPlayerTurn function sets the current player turn to a new value.
-
Constructor Details
-
TurnManager
The TurnManager function is responsible for keeping track of the order in which players take their turns. It does this by maintaining a list of player IDs, sorted from highest to lowest score. The TurnManager function also keeps track of whose turn it currently is, and can be used to determine who's next.- Parameters:
players- > players Get the players from the game
-
-
Method Details
-
nextTurn
public void nextTurn()The nextTurn function is used to change the current player turn. It does this by incrementing the currentPlayerTurn variable and then using modulo to ensure that it stays within bounds of 0-3. -
getCurrentPlayerTurn
public int getCurrentPlayerTurn()The getCurrentPlayerTurn function returns the current player's turn.- Returns:
- The current player's turn
-
getPlayersTurn
The getPlayersTurn function returns the list of players who have not yet had their turn.- Returns:
- The players turn variable, which is a list of integers
-
setCurrentPlayerTurn
public void setCurrentPlayerTurn(int newTurn) The setCurrentPlayerTurn function sets the current player turn to a new value.- Parameters:
newTurn- newTurn Set the current player turn variable to a new value
-
removePlayer
public void removePlayer(int playerId) The removePlayer function removes a player from the game.- Parameters:
playerId- playerId Remove the player from the players turn list
-
getTurnManagerIndex
public int getTurnManagerIndex()The getTurnManagerIndex function returns the index of the current player in turn.- Returns:
- The index of the player whose turn it currently is
-