Class SBFGameManager

java.lang.Object
megamek.server.AbstractGameManager
megamek.server.sbf.SBFGameManager
All Implemented Interfaces:
SBFRuleOptionsUser, IGameManager

public final class SBFGameManager extends AbstractGameManager implements SBFRuleOptionsUser
This class manages an SBF game on the server side. As of 2024, this is under construction.
  • Constructor Details

    • SBFGameManager

      public SBFGameManager()
  • Method Details

    • handlePacket

      public void handlePacket(int connId, Packet packet)
      Description copied from interface: IGameManager
      Handles all incoming packets. When overriding this, super() should normally be called to have the base implementation of AbstractGameManager handle packets.
      Specified by:
      handlePacket in interface IGameManager
      Overrides:
      handlePacket in class AbstractGameManager
      Parameters:
      connId - The connection ID = player ID the packet came from
      packet - The packet to process
    • getGame

      public SBFGame getGame()
      Specified by:
      getGame in interface IGameManager
      Returns:
      The current game instance.
    • setGame

      public void setGame(IGame g)
      Description copied from interface: IGameManager
      Sets the current game instance.
      Specified by:
      setGame in interface IGameManager
    • resetGame

      public void resetGame()
      Description copied from interface: IGameManager
      Resets the game instance. Resetting the game removes all content and returns to the lobby but keeps connected players.
      Specified by:
      resetGame in interface IGameManager
    • disconnect

      public void disconnect(Player player)
      Description copied from interface: IGameManager
      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.
      Specified by:
      disconnect in interface IGameManager
      Parameters:
      player - The player that disconnected.
    • removeAllEntitiesOwnedBy

      public void removeAllEntitiesOwnedBy(Player player)
      Specified by:
      removeAllEntitiesOwnedBy in interface IGameManager
    • handleCfrPacket

      public void handleCfrPacket(Server.ReceivedPacket rp)
      Description copied from interface: IGameManager
      Handle CFR packets. //TODO: This concerns multi-threaded code and should be centralized!
      Specified by:
      handleCfrPacket in interface IGameManager
      Parameters:
      rp - the CFR packet returned from a client
    • requestGameMaster

      public void requestGameMaster(Player player)
      Specified by:
      requestGameMaster in interface IGameManager
    • getCommandList

      public List<ServerCommand> getCommandList(Server server)
      Specified by:
      getCommandList in interface IGameManager
    • addReport

      public void addReport(ReportEntry r)
      Specified by:
      addReport in interface IGameManager
    • calculatePlayerInitialCounts

      public void calculatePlayerInitialCounts()
      Description copied from interface: IGameManager
      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.
      Specified by:
      calculatePlayerInitialCounts in interface IGameManager
    • requestTeamChangeForPlayer

      public void requestTeamChangeForPlayer(int teamID, Player player)
      Description copied from interface: IGameManager
      Requests a team change for a player.
      Specified by:
      requestTeamChangeForPlayer in interface IGameManager
      Parameters:
      teamID - ID of the team the player will be passed to
      player - player
    • sendCurrentInfo

      public void sendCurrentInfo(int connId)
      Description copied from interface: IGameManager
      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.
      Specified by:
      sendCurrentInfo in interface IGameManager
      Parameters:
      connId - The id of the player to update
    • endCurrentPhase

      protected void endCurrentPhase()
      Description copied from class: AbstractGameManager
      Ends this phase and moves on to the next.
      Specified by:
      endCurrentPhase in class AbstractGameManager
    • prepareForCurrentPhase

      protected void prepareForCurrentPhase()
      Description copied from class: AbstractGameManager
      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.
      Specified by:
      prepareForCurrentPhase in class AbstractGameManager
    • executeCurrentPhase

      protected void executeCurrentPhase()
      Description copied from class: AbstractGameManager
      Do anything we need to work through the current phase, such as give a turn to the first player to play.
      Specified by:
      executeCurrentPhase in class AbstractGameManager
    • clearPendingReports

      public void clearPendingReports()
    • sendReport

      public void sendReport()
      Send the round report to all connected clients.
    • getOptions

      public SBFRuleOptions getOptions()
      Description copied from interface: SBFRuleOptionsUser
      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.
      Specified by:
      getOptions in interface SBFRuleOptionsUser
      Returns:
      the SBFRuleOptions used by the present SBF game
    • transmitAllPlayerDones

      protected void transmitAllPlayerDones()
      Description copied from class: AbstractGameManager
      Sends out the player ready stats for all players to all connections
      Overrides:
      transmitAllPlayerDones in class AbstractGameManager
    • send

      public void send(Packet packet)
      Description copied from class: AbstractGameManager
      Sends the given packet to all connections (all connected Clients = players).
      Specified by:
      send in interface IGameManager
      Overrides:
      send in class AbstractGameManager
      See Also:
      • Server.send(Packet)
    • send

      public void send(int connId, Packet p)
      Sends the given packet to the given connection (= player ID).
      Specified by:
      send in interface IGameManager
      Overrides:
      send in class AbstractGameManager
      See Also:
    • transmitPlayerUpdate

      protected void transmitPlayerUpdate(Player player)
      Sends out the player object to all players. Private info of the given player is redacted before being sent to other players.
      Overrides:
      transmitPlayerUpdate in class AbstractGameManager
      Parameters:
      player - The player whose information is to be shared
      See Also: