Class TurnManager

java.lang.Object
model.logic.host.TurnManager
All Implemented Interfaces:
Serializable

public class TurnManager extends Object implements Serializable
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    The TurnManager function is responsible for keeping track of the order in which players take their turns.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The getCurrentPlayerTurn function returns the current player's turn.
    The getPlayersTurn function returns the list of players who have not yet had their turn.
    int
    The getTurnManagerIndex function returns the index of the current player in turn.
    void
    The nextTurn function is used to change the current player turn.
    void
    removePlayer(int playerId)
    The removePlayer function removes a player from the game.
    void
    setCurrentPlayerTurn(int newTurn)
    The setCurrentPlayerTurn function sets the current player turn to a new value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TurnManager

      public TurnManager(Map<Integer,Player> players)
      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

      public List<Integer> 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