T
- Your implementation of AbstractPlayerpublic final class GameManager<T extends AbstractPlayer>
extends java.lang.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.Constructor and Description |
---|
GameManager() |
Modifier and Type | Method and Description |
---|---|
void |
addToGameSummary(java.lang.String summary)
Add a new line to the game summary for the current turn.
|
void |
addTooltip(AbstractPlayer player,
java.lang.String message)
Adds a tooltip for the current turn.
|
void |
addTooltip(Tooltip tooltip)
Adds a tooltip for the current turn.
|
void |
endGame()
Set game end.
|
static java.lang.String |
formatErrorMessage(java.lang.String message)
Helper function to display a colored message.
|
static java.lang.String |
formatSuccessMessage(java.lang.String message)
Helper function to display a colored message.
|
java.util.List<T> |
getActivePlayers()
Get all the active players.
|
int |
getFrameDuration()
Returns the duration in milliseconds for the frame currently being computed.
|
int |
getLeagueLevel()
Get current league level.
|
int |
getMaxTurns()
Get the maximum amount of turns.
|
T |
getPlayer(int i)
Get player with index i
|
int |
getPlayerCount()
Get initial number of players.
|
java.util.List<T> |
getPlayers()
Get all the players.
|
int |
getTurnMaxTime()
Get the timeout delay for every players.
|
boolean |
isGameEnd()
Check if the game has been terminated by the referee.
|
void |
registerModule(Module m)
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(java.lang.Object data)
Set data for use by the viewer, for the current frame.
|
void |
setViewData(java.lang.String moduleName,
java.lang.Object data)
Set data for use by the viewer, for the current frame, for a specific module.
|
void |
setViewGlobalData(java.lang.String moduleName,
java.lang.Object data)
Set data for use by the viewer and not related to a specific frame.
|
public int getPlayerCount()
public java.util.List<T> getPlayers()
public java.util.List<T> getActivePlayers()
public T getPlayer(int i) throws java.lang.IndexOutOfBoundsException
i
- Player indexjava.lang.IndexOutOfBoundsException
public void setFrameDuration(int frameDuration)
frameDuration
- The frame duration in milliseconds.public int getFrameDuration()
public void endGame()
public boolean isGameEnd()
public void setMaxTurns(int maxTurns) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
maxTurns
- the number of turns for a game.java.lang.IllegalStateException
java.lang.IllegalArgumentException
public int getMaxTurns()
public void setTurnMaxTime(int turnMaxTime) throws java.lang.IllegalArgumentException
turnMaxTime
- Duration in milliseconds.java.lang.IllegalArgumentException
public int getTurnMaxTime()
public void setViewData(java.lang.Object data)
data
- any object that can be serialized in JSON using gson.public void setViewData(java.lang.String moduleName, java.lang.Object data)
moduleName
- the name of the moduledata
- any object that can be serialized in JSON using gson.public void setViewGlobalData(java.lang.String moduleName, java.lang.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, java.lang.String message)
player
- The player the tooltip information is about.message
- Tooltip message.public void addToGameSummary(java.lang.String summary)
summary
- summary line to add to the current summary.public void registerModule(Module m)
m
- public int getLeagueLevel()
public static java.lang.String formatSuccessMessage(java.lang.String message)
message
- The message to display.public static java.lang.String formatErrorMessage(java.lang.String message)
message
- The message to display.