T - Your implementation of AbstractPlayerpublic abstract class GameManager<T extends AbstractPlayer> extends Object
GameManager takes care of running each turn of the game and computing each visual frame of the replay. It provides many utility
methods that handle instances of your implementation of AbstractPlayer.| Modifier and Type | Field and Description |
|---|---|
protected static org.apache.commons.logging.Log |
log |
protected PrintStream |
out |
protected List<T> |
players |
| Constructor and Description |
|---|
GameManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
addToGameSummary(String summary)
Add a new line to the game summary for the current turn.
|
void |
addTooltip(AbstractPlayer player,
String message)
Adds a tooltip for the current turn.
|
void |
addTooltip(Tooltip tooltip)
Adds a tooltip for the current turn.
|
protected abstract boolean |
allPlayersInactive() |
protected void |
dumpGameProperties() |
protected void |
endGame()
Set game end.
|
static String |
formatErrorMessage(String message)
Helper function to display a colored message.
|
static String |
formatSuccessMessage(String message)
Helper function to display a colored message.
|
int |
getFrameDuration()
Returns the duration in milliseconds for the frame currently being computed.
|
protected abstract com.codingame.gameengine.core.OutputCommand |
getGameSummaryOutputCommand() |
int |
getLeagueLevel()
Get current league level.
|
int |
getMaxTurns()
Get the maximum amount of turns.
|
int |
getTurnMaxTime()
Get the timeout delay for every players.
|
boolean |
isGameEnd()
Check if the game has been terminated by the referee.
|
void |
putMetadata(String key,
String value)
Puts a new metadata that will be sent to the CodinGame IDE.
|
protected abstract void |
readGameProperties(com.codingame.gameengine.core.InputCommand iCmd,
Scanner s) |
void |
registerModule(Module module)
Register a module to the gameManager.
|
void |
setFrameDuration(int frameDuration)
Specifies the frameDuration in milliseconds.
|
void |
setMaxTurns(int maxTurns)
Set the maximum amount of turns.
|
void |
setTurnMaxTime(int turnMaxTime)
Set the timeout delay for every players.
|
void |
setViewData(Object data)
Set data for use by the viewer, for the current frame.
|
void |
setViewData(String moduleName,
Object data)
Set data for use by the viewer, for the current frame, for a specific module.
|
void |
setViewGlobalData(String moduleName,
Object data)
Set data for use by the viewer and not related to a specific frame.
|
protected static org.apache.commons.logging.Log log
protected List<T extends AbstractPlayer> players
protected PrintStream out
protected abstract boolean allPlayersInactive()
protected abstract void readGameProperties(com.codingame.gameengine.core.InputCommand iCmd,
Scanner s)
protected void dumpGameProperties()
protected abstract com.codingame.gameengine.core.OutputCommand getGameSummaryOutputCommand()
public final void putMetadata(String key, String value)
key - the property to sendvalue - the property's valuepublic void setFrameDuration(int frameDuration)
frameDuration - The frame duration in milliseconds.public int getFrameDuration()
protected void endGame()
public boolean isGameEnd()
public void setMaxTurns(int maxTurns)
throws IllegalArgumentException
maxTurns - the number of turns for a game.IllegalArgumentException - if maxTurns ≤ 0public int getMaxTurns()
public void setTurnMaxTime(int turnMaxTime)
throws IllegalArgumentException
turnMaxTime - Duration in milliseconds.IllegalArgumentException - if turnMaxTime ≤ 0public int getTurnMaxTime()
public void setViewData(Object data)
data - any object that can be serialized in JSON using gson.public void setViewData(String moduleName, Object data)
moduleName - the name of the moduledata - any object that can be serialized in JSON using gson.public void setViewGlobalData(String moduleName, Object data)
moduleName - the name of the moduledata - any object that can be serialized in JSON using gson.public void addTooltip(Tooltip tooltip)
tooltip - A tooltip that will be shown in the player.public void addTooltip(AbstractPlayer player, String message)
player - The player the tooltip information is about.message - Tooltip message.public void addToGameSummary(String summary)
summary - summary line to add to the current summary.public void registerModule(Module module)
module - the module to registerpublic int getLeagueLevel()
public static String formatSuccessMessage(String message)
message - The message to display.Copyright © 2018. All rights reserved.