Class MultiplayerGameManager<T extends AbstractMultiplayerPlayer>
- Type Parameters:
T- Your implementation of AbstractMultiplayerPlayer
AbstractMultiplayerPlayer takes care of running each turn of a multiplayer game and computing each visual frame of the replay. It
provides many utility methods that handle instances of your implementation of AbstractMultiplayerPlayer.-
Field Summary
Fields inherited from class com.codingame.gameengine.core.GameManager
log, out, players -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected voidvoidendGame()Set game end.Get all the active players.The game parameters are used to get additional information from the Game Runner.protected com.codingame.gameengine.core.OutputCommandgetPlayer(int i) Get player with index iintGet initial number of players.Get all the players.The random generator is used to generated parameters such as width and height.
The provided random generator is a SecureRandom using the SHAPRNG algorithm.longgetSeed()The seed is used to initialize the Random number generator.
If a seed is present in the given input, the input value should override the generated values.
The seed should NOT be used directly in referee but through the random number generator provided by @method getRandomprotected voidreadGameProperties(com.codingame.gameengine.core.InputCommand iCmd, Scanner s) Methods inherited from class com.codingame.gameengine.core.GameManager
addToGameSummary, addTooltip, addTooltip, execute, formatErrorMessage, formatSuccessMessage, getFirstTurnMaxTime, getFrameDuration, getLeagueLevel, getMaxTurns, getTurnMaxTime, isGameEnd, putMetadata, registerModule, setFirstTurnMaxTime, setFrameDuration, setMaxTurns, setTurnMaxTime, setViewData, setViewData, setViewGlobalData
-
Constructor Details
-
MultiplayerGameManager
public MultiplayerGameManager()
-
-
Method Details
-
readGameProperties
- Specified by:
readGamePropertiesin classGameManager<T extends AbstractMultiplayerPlayer>
-
dumpGameProperties
protected void dumpGameProperties()- Overrides:
dumpGamePropertiesin classGameManager<T extends AbstractMultiplayerPlayer>
-
getPlayerCount
public int getPlayerCount()Get initial number of players.- Returns:
- the number of players.
-
getSeed
public long getSeed()The seed is used to initialize the Random number generator.
If a seed is present in the given input, the input value should override the generated values.
The seed should NOT be used directly in referee but through the random number generator provided by @method getRandom- Returns:
- an
longcontaining a given or generated seed.
-
getRandom
The random generator is used to generated parameters such as width and height.
The provided random generator is a SecureRandom using the SHAPRNG algorithm.
- Returns:
- an
Randomcontaining a given or generated seed.
-
getGameParameters
The game parameters are used to get additional information from the Game Runner.
When running the game in the CodinGame IDE, this instance will be populated with data entered by the user in the Options section.
When the game is over, any modification made to this instance will be written back to the Options section, including the
seedproperty.- Returns:
- a
Propertiescontaining the given parameters.
-
getPlayers
Get all the players.- Returns:
- the list of players.
-
getActivePlayers
Get all the active players.- Returns:
- the list of active players.
-
getPlayer
Get player with index i- Parameters:
i- Player index- Returns:
- player with index i
- Throws:
IndexOutOfBoundsException- if there is no player at that index
-
endGame
public void endGame()Set game end.- Overrides:
endGamein classGameManager<T extends AbstractMultiplayerPlayer>
-
allPlayersInactive
protected boolean allPlayersInactive()- Specified by:
allPlayersInactivein classGameManager<T extends AbstractMultiplayerPlayer>
-
getGameSummaryOutputCommand
protected com.codingame.gameengine.core.OutputCommand getGameSummaryOutputCommand()- Specified by:
getGameSummaryOutputCommandin classGameManager<T extends AbstractMultiplayerPlayer>
-