Package megamek.server.sbf
Class SBFGameManager
java.lang.Object
megamek.server.AbstractGameManager
megamek.server.sbf.SBFGameManager
- All Implemented Interfaces:
SBFRuleOptionsUser,IGameManager
This class manages an SBF game on the server side. As of 2024, this is under construction.
-
Field Summary
Fields inherited from class megamek.server.AbstractGameManager
autoSaveService, packetHelper, saveHandler, scriptedEventHelper -
Constructor Summary
Constructors -
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.voidvoiddisconnect(Player player) Handles housekeeping for a disconnected player.protected voidEnds this phase and moves on to the next.protected voidDo anything we need to work through the current phase, such as give a turn to the first player to play.getCommandList(Server server) getGame()This method must be implemented to provide access to the SBF options used in the present game so that the convenience methods of this interface work correctly.voidHandle CFR packets.voidhandlePacket(int connId, Packet packet) Handles all incoming packets.protected voidPrepares for the game's current phase.voidremoveAllEntitiesOwnedBy(Player player) voidrequestGameMaster(Player player) voidrequestTeamChangeForPlayer(int teamID, Player player) Requests a team change for a player.voidResets thegameinstance.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.voidSend the round report to all connected clients.voidSets the currentgameinstance.protected voidSends out the player ready stats for all players to all connectionsprotected voidtransmitPlayerUpdate(Player player) Sends out the player object to all players.Methods inherited from class megamek.server.AbstractGameManager
autoSave, changePhase, checkReady, getAutoSaveService, getPacketHelper, incrementAndSendGameRound, isEmptyLobby, saveGame, sendChat, sendChat, sendCurrentTurns, sendGhostSkipMessage, sendPhaseChange, sendSaveGame, sendServerChat, sendServerChat, transmitAllPlayerUpdatesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface megamek.server.IGameManager
saveGameMethods inherited from interface megamek.common.strategicBattleSystems.SBFRuleOptionsUser
usesAdjustingFormations, usesAdvancedInitiative, usesBattlefieldInt, usesDoubleBlind, usesSprintingMove, usesTeamVision
-
Constructor Details
-
SBFGameManager
public SBFGameManager()
-
-
Method Details
-
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- Overrides:
handlePacketin classAbstractGameManager- Parameters:
connId- The connection ID = player ID the packet came frompacket- The packet to process
-
getGame
- Specified by:
getGamein interfaceIGameManager- Returns:
- The current
gameinstance.
-
setGame
Description copied from interface:IGameManagerSets the currentgameinstance.- Specified by:
setGamein interfaceIGameManager
-
resetGame
public void resetGame()Description copied from interface:IGameManagerResets thegameinstance. Resetting the game removes all content and returns to the lobby but keeps connected players.- Specified by:
resetGamein interfaceIGameManager
-
disconnect
Description copied from interface:IGameManagerHandles 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.- Specified by:
disconnectin interfaceIGameManager- Parameters:
player- The player that disconnected.
-
removeAllEntitiesOwnedBy
- Specified by:
removeAllEntitiesOwnedByin interfaceIGameManager
-
handleCfrPacket
Description copied from interface:IGameManagerHandle CFR packets. //TODO: This concerns multi-threaded code and should be centralized!- Specified by:
handleCfrPacketin interfaceIGameManager- Parameters:
rp- the CFR packet returned from a client
-
requestGameMaster
- Specified by:
requestGameMasterin interfaceIGameManager
-
getCommandList
- Specified by:
getCommandListin interfaceIGameManager
-
addReport
- Specified by:
addReportin interfaceIGameManager
-
calculatePlayerInitialCounts
public void calculatePlayerInitialCounts()Description copied from interface:IGameManagerCalculates 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.- Specified by:
calculatePlayerInitialCountsin interfaceIGameManager
-
requestTeamChangeForPlayer
Description copied from interface:IGameManagerRequests a team change for a player.- Specified by:
requestTeamChangeForPlayerin interfaceIGameManager- Parameters:
teamID- ID of the team the player will be passed toplayer- player
-
sendCurrentInfo
public void sendCurrentInfo(int connId) Description copied from interface:IGameManagerSends 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.- Specified by:
sendCurrentInfoin interfaceIGameManager- Parameters:
connId- The id of the player to update
-
endCurrentPhase
protected void endCurrentPhase()Description copied from class:AbstractGameManagerEnds this phase and moves on to the next.- Specified by:
endCurrentPhasein classAbstractGameManager
-
prepareForCurrentPhase
protected void prepareForCurrentPhase()Description copied from class:AbstractGameManagerPrepares 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.- Specified by:
prepareForCurrentPhasein classAbstractGameManager
-
executeCurrentPhase
protected void executeCurrentPhase()Description copied from class:AbstractGameManagerDo anything we need to work through the current phase, such as give a turn to the first player to play.- Specified by:
executeCurrentPhasein classAbstractGameManager
-
clearPendingReports
public void clearPendingReports() -
sendReport
public void sendReport()Send the round report to all connected clients. -
getOptions
Description copied from interface:SBFRuleOptionsUserThis method must be implemented to provide access to the SBF options used in the present game so that the convenience methods of this interface work correctly.- Specified by:
getOptionsin interfaceSBFRuleOptionsUser- Returns:
- the SBFRuleOptions used by the present SBF game
-
transmitAllPlayerDones
protected void transmitAllPlayerDones()Description copied from class:AbstractGameManagerSends out the player ready stats for all players to all connections- Overrides:
transmitAllPlayerDonesin classAbstractGameManager
-
send
Description copied from class:AbstractGameManagerSends the given packet to all connections (all connected Clients = players).- Specified by:
sendin interfaceIGameManager- Overrides:
sendin classAbstractGameManager- See Also:
-
send
Sends the given packet to the given connection (= player ID).- Specified by:
sendin interfaceIGameManager- Overrides:
sendin classAbstractGameManager- See Also:
-
transmitPlayerUpdate
Sends out the player object to all players. Private info of the given player is redacted before being sent to other players.- Overrides:
transmitPlayerUpdatein classAbstractGameManager- Parameters:
player- The player whose information is to be shared- See Also:
-