Package megamek.server
Interface IGameManager
- All Known Implementing Classes:
AbstractGameManager,SBFGameManager,SimulationManager,TWGameManager
public interface IGameManager
Provides common interface for the server to interact with different types of games. Currently only used for Total
Warfare scale, but allows expansion to BattleFore or Alpha Strike.
-
Method Summary
Modifier and TypeMethodDescriptionvoidvoidCalculates and sets any initial unit counts and BV/PV for all players, and thus should only be called at the start of a game.voiddisconnect(Player player) Handles housekeeping for a disconnected player.getCommandList(Server server) getGame()voidHandle CFR packets.voidhandlePacket(int connId, Packet packet) Handles all incoming packets.voidremoveAllEntitiesOwnedBy(Player player) voidrequestGameMaster(Player player) voidrequestTeamChangeForPlayer(int teamID, Player player) Requests a team change for a player.voidResets thegameinstance.default voidSaves the game server-side.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).voidsendCurrentInfo(int connId) Sends a player all information they need to update their Client game state to the GameManager's game state.voidsendSaveGame(int connId, String fileName, String localPath) save the game and send it to the specified connectionvoidSets the currentgameinstance.
-
Method Details
-
getGame
IGame getGame()- Returns:
- The current
gameinstance.
-
setGame
Sets the currentgameinstance. -
resetGame
void resetGame()Resets thegameinstance. Resetting the game removes all content and returns to the lobby but keeps connected players. -
disconnect
Handles housekeeping for a disconnected player. Removes player from the game in the lounge or victory phase, or during other phases if the player has no units. Otherwise, the player becomes a ghost.- Parameters:
player- The player that disconnected.
-
sendCurrentInfo
void sendCurrentInfo(int connId) Sends a player all information they need to update their Client game state to the GameManager's game state. This should always include units, forces, map info, active attacks, round reports, among others. This is triggered when a player first connects to the server. When the game is past the lobby phase, this also triggers generating and sending a current player turn or advancing the phase if there are no remaining turns; in other words, this sets the game in motion when the first player connects. A game starts past the lobby phase when it is loaded from a save.- Parameters:
connId- The id of the player to update
-
send
Sends the given packet to all connections (all connected Clients = players). -
send
Sends the given packet to the given connection (= player ID). -
saveGame
Saves the game server-side. Will announce the save (or error) in chat.- Parameters:
fileName- The filename to use
-
saveGame
Saves the game server-side. Will announce the save (or error) in chat if the given sendChat is true.- Parameters:
fileName- The filename to usesendChat- When true, the saving (or error) is announced in chat
-
sendSaveGame
save the game and send it to the specified connection- Parameters:
connId- The connection id to send tofileName- The filename to uselocalPath- The path to the file to be used on the client
-
removeAllEntitiesOwnedBy
-
handlePacket
Handles all incoming packets. When overriding this, super() should normally be called to have the base implementation of AbstractGameManager handle packets.- Parameters:
connId- The connection ID = player ID the packet came frompacket- The packet to process
-
handleCfrPacket
Handle CFR packets. //TODO: This concerns multi-threaded code and should be centralized!- Parameters:
rp- the CFR packet returned from a client
-
requestGameMaster
-
getCommandList
-
addReport
-
calculatePlayerInitialCounts
void calculatePlayerInitialCounts()Calculates and sets any initial unit counts and BV/PV for all players, and thus should only be called at the start of a game. The initial values are supposed to be stored for later comparison so that BV or unit losses over the course of the game can be calculated. -
requestTeamChangeForPlayer
Requests a team change for a player.- Parameters:
teamID- ID of the team the player will be passed toplayer- player
-