Package megamek.server
Class AbstractGameManager
java.lang.Object
megamek.server.AbstractGameManager
- All Implemented Interfaces:
IGameManager
- Direct Known Subclasses:
SBFGameManager,SimulationManager,TWGameManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AutosaveServiceprotected final GameManagerPacketHelperprotected final GameManagerSaveHelperprotected final GameManagerScriptedEventHelper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidautoSave()Performs an automatic save (does not check the autosave settings - the autosave will simply be done).final voidchangePhase(GamePhase newPhase) Switches to the given new Phase and preforms preparation, checks if it should be skipped and executes it.protected voidCalled when a player declares that they are "done".protected abstract voidEnds this phase and moves on to the next.protected abstract voidDo anything we need to work through the current phase, such as give a turn to the first player to play.voidhandlePacket(int connId, Packet packet) Handles all incoming packets.voidIncrement's the server's game round and send it to all the clientsprotected booleanprotected abstract voidPrepares for the game's current phase.voidSaves the game server-side.voidSends the given packet to the given connection (= player ID).voidSends the given packet to all connections (all connected Clients = players).voidvoidvoidSends the current list of player turns as stored in the game's turn list to the Clients.protected voidsendGhostSkipMessage(Player ghost) Sends out a notification message indicating that a ghost player's turn may be skipped with the /skip command.protected voidvoidsendSaveGame(int connId, String sFile, String sLocalPath) save the game and send it to the specified connectionvoidsendServerChat(int connId, String message) voidsendServerChat(String message) protected voidSends out the player ready stats for all players to all connectionsvoidShares all player objects with all players.protected voidtransmitPlayerUpdate(Player player) Sends out the player object to all players.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface megamek.server.IGameManager
addReport, calculatePlayerInitialCounts, disconnect, getCommandList, getGame, handleCfrPacket, removeAllEntitiesOwnedBy, requestGameMaster, requestTeamChangeForPlayer, resetGame, saveGame, sendCurrentInfo, setGame
-
Field Details
-
packetHelper
-
saveHandler
-
autoSaveService
-
scriptedEventHelper
-
-
Constructor Details
-
AbstractGameManager
public AbstractGameManager()
-
-
Method Details
-
send
Sends the given packet to all connections (all connected Clients = players).- Specified by:
sendin interfaceIGameManager- See Also:
-
send
Sends the given packet to the given connection (= player ID).- Specified by:
sendin interfaceIGameManager- See Also:
-
handlePacket
Description copied from interface:IGameManagerHandles all incoming packets. When overriding this, super() should normally be called to have the base implementation of AbstractGameManager handle packets.- Specified by:
handlePacketin interfaceIGameManager- Parameters:
connId- The connection ID = player ID the packet came frompacket- The packet to process
-
endCurrentPhase
protected abstract void endCurrentPhase()Ends this phase and moves on to the next. -
executeCurrentPhase
protected abstract void executeCurrentPhase()Do anything we need to work through the current phase, such as give a turn to the first player to play. -
prepareForCurrentPhase
protected abstract void prepareForCurrentPhase()Prepares for the game's current phase. This typically involves resetting the states of units in the game and making sure the clients have the information they need for the new phase. -
changePhase
Switches to the given new Phase and preforms preparation, checks if it should be skipped and executes it. -
sendPhaseChange
protected void sendPhaseChange() -
checkReady
protected void checkReady()Called when a player declares that they are "done". By default, this method advances to the next phase, if
- all non-ghost, non-observer players are done,
- the present phase does not use turns (e.g. if it's a report phase), and
- we are not in an empty lobby (= no units at all).
In other circumstances, ending the current phase is triggered elsewhere. Note that specifically, ghost players are not checked for their status here so the game can advance through non-turn (report) phases even with ghost players. -
transmitAllPlayerDones
protected void transmitAllPlayerDones()Sends out the player ready stats for all players to all connections -
isEmptyLobby
protected boolean isEmptyLobby()- Returns:
- True when the game is in the lobby phase and is empty (no units present).
-
transmitPlayerUpdate
Sends out the player object to all players. Private info of the given player is redacted before being sent to other players.- Parameters:
player- The player whose information is to be shared- See Also:
-
transmitAllPlayerUpdates
public void transmitAllPlayerUpdates()Shares all player objects with all players. Private info is redacted before being sent to other players.- See Also:
-
autoSave
public void autoSave()Performs an automatic save (does not check the autosave settings - the autosave will simply be done). Depending on the settings, the "autosave" filename is appended with a timestamp and/or a chat message is sent announcing the autosave. -
saveGame
Description copied from interface:IGameManagerSaves the game server-side. Will announce the save (or error) in chat if the given sendChat is true.- Specified by:
saveGamein interfaceIGameManager- Parameters:
fileName- The filename to usesendChat- When true, the saving (or error) is announced in chat
-
sendSaveGame
Description copied from interface:IGameManagersave the game and send it to the specified connection- Specified by:
sendSaveGamein interfaceIGameManager- Parameters:
connId- The connection id to send tosFile- The filename to usesLocalPath- The path to the file to be used on the client
-
sendChat
-
sendChat
-
sendServerChat
-
sendServerChat
-
sendCurrentTurns
public void sendCurrentTurns()Sends the current list of player turns as stored in the game's turn list to the Clients.- See Also:
-
incrementAndSendGameRound
public void incrementAndSendGameRound()Increment's the server's game round and send it to all the clients -
getPacketHelper
-
getAutoSaveService
-
sendGhostSkipMessage
Sends out a notification message indicating that a ghost player's turn may be skipped with the /skip command.- Parameters:
ghost- the Player who is ghosted. This value must not be null.
-