Package com.takenoko.engine
Class GameEngine
java.lang.Object
com.takenoko.engine.GameEngine
The game engine is responsible for the gameplay throughout the game.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Board
private final List<BotManager>
private final BotStatistics
private final ConsoleUserInterface
static final int
private GameState
private final History
private final int
private final Scoreboard
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for the GameEngine class.GameEngine
(int numberOfRounds, Board board, ConsoleUserInterface consoleUserInterface, GameState gameState, List<BotManager> botManagerList, Scoreboard scoreboard, BotStatistics botStatistics, History history) GameEngine
(List<BotManager> botManagers) -
Method Summary
Modifier and TypeMethodDescriptionvoid
endGame()
This method is used to end the game correctly.getBoard()
Returns the game boardReturn the current game stateorg.apache.commons.lang3.tuple.Pair<List<BotManager>,
EndGameState> Return the winner of the game.void
newGame()
This method creates a blank new game.void
playGame()
void
runGame()
Run a whole game from initialization to end.void
runGame
(int numberOfGames) void
runGame
(int numberOfGames, boolean logToCSV) void
setGameState
(GameState gameState) void
This method change the game state to playing and add the first tile to the board.statSummary
(int numberOfGames)
-
Field Details
-
DEFAULT_NUMBER_OF_ROUNDS
public static final int DEFAULT_NUMBER_OF_ROUNDS- See Also:
-
DEFAULT_NUMBER_OF_OBJECTIVES_TO_WIN
-
board
-
consoleUserInterface
-
gameState
-
numberOfRounds
private final int numberOfRounds -
botManagers
-
scoreboard
-
botStatistics
-
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
-
-
Method Details
-
newGame
public void newGame()This method creates a blank new game.- Display the welcome message
- Change game state to READY
- 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
-
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 oneBotManager
with the maximum number of points, the reason of the win isEndGameState.WIN_WITH_OBJECTIVE_POINTS
. if there is a tie betweenBotManager
with the maximum number of points and if there is aBotManager
with the maximum number of panda points, the reason of the win isEndGameState.WIN_WITH_PANDA_OBJECTIVE_POINTS
.- Returns:
- a pair of the winner and the reason of the win.
-
getBoard
Returns the game board- Returns:
- board object
-
getGameState
Return the current game state- Returns:
GameState
object
-
setGameState
- 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)
-