Class Game


  • public class Game
    extends Object
    This is the Game Class, it is used to manage the data of the game.
    • 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 mode
        players - 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
      • getColors

        public List<Color> getColors()
        Get available colors to pick
        Returns:
        current free color
      • 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