Class GameEngine

java.lang.Object
com.takenoko.engine.GameEngine

public class GameEngine extends Object
The game engine is responsible for the gameplay throughout the game.
  • Field Details

    • DEFAULT_NUMBER_OF_ROUNDS

      public static final int DEFAULT_NUMBER_OF_ROUNDS
      See Also:
    • DEFAULT_NUMBER_OF_OBJECTIVES_TO_WIN

      public static final Map<Integer,Integer> DEFAULT_NUMBER_OF_OBJECTIVES_TO_WIN
    • board

      private Board board
    • consoleUserInterface

      private final ConsoleUserInterface consoleUserInterface
    • gameState

      private GameState gameState
    • numberOfRounds

      private final int numberOfRounds
    • botManagers

      private final List<BotManager> botManagers
    • scoreboard

      private final Scoreboard scoreboard
    • botStatistics

      private final BotStatistics botStatistics
    • history

      private final History history
  • Constructor Details

    • GameEngine

      public GameEngine(int numberOfRounds, Board board, ConsoleUserInterface consoleUserInterface, GameState gameState, List<BotManager> botManagerList, Scoreboard scoreboard, BotStatistics botStatistics, History history)
    • GameEngine

      public GameEngine()
      Constructor for the GameEngine class. Instantiate the board and the console user interface used. It does not start the game ! It simply instantiates the objects needed for the game.
    • GameEngine

      public GameEngine(List<BotManager> botManagers)
  • Method Details

    • newGame

      public void newGame()
      This method creates a blank new game.
      1. Display the welcome message
      2. Change game state to READY
      3. Tell the user that the game is setup
    • startGame

      public void startGame()
      This method change the game state to playing and add the first tile to the board.
    • playGame

      public void playGame()
    • endGame

      public void endGame()
      This method is used to end the game correctly.
    • statSummary

      public String statSummary(int numberOfGames)
    • getWinner

      public org.apache.commons.lang3.tuple.Pair<List<BotManager>,EndGameState> getWinner()
      Return the winner of the game.

      If there is a tie, the reason of the end of the game is EndGameState.TIE. if there is only one BotManager with the maximum number of points, the reason of the win is EndGameState.WIN_WITH_OBJECTIVE_POINTS. if there is a tie between BotManager with the maximum number of points and if there is a BotManager with the maximum number of panda points, the reason of the win is EndGameState.WIN_WITH_PANDA_OBJECTIVE_POINTS.

      Returns:
      a pair of the winner and the reason of the win.
    • getBoard

      public Board getBoard()
      Returns the game board
      Returns:
      board object
    • getGameState

      public GameState getGameState()
      Return the current game state
      Returns:
      GameState object
    • setGameState

      public void setGameState(GameState gameState)
      Parameters:
      gameState - the game state to set
    • runGame

      public void runGame()
      Run a whole game from initialization to end.
    • runGame

      public void runGame(int numberOfGames)
    • runGame

      public void runGame(int numberOfGames, boolean logToCSV)