Class AbstractGameManager

java.lang.Object
megamek.server.AbstractGameManager
All Implemented Interfaces:
IGameManager
Direct Known Subclasses:
SBFGameManager, SimulationManager, TWGameManager

public abstract class AbstractGameManager extends Object implements IGameManager
  • Field Details

  • Constructor Details

    • AbstractGameManager

      public AbstractGameManager()
  • Method Details

    • send

      public void send(Packet packet)
      Sends the given packet to all connections (all connected Clients = players).
      Specified by:
      send in interface IGameManager
      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
      See Also:
    • 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
      Parameters:
      connId - The connection ID = player ID the packet came from
      packet - 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

      public final void changePhase(GamePhase newPhase)
      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

      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.
      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

      public void saveGame(String fileName, boolean sendChat)
      Description copied from interface: IGameManager
      Saves the game server-side. Will announce the save (or error) in chat if the given sendChat is true.
      Specified by:
      saveGame in interface IGameManager
      Parameters:
      fileName - The filename to use
      sendChat - When true, the saving (or error) is announced in chat
    • sendSaveGame

      public void sendSaveGame(int connId, String sFile, String sLocalPath)
      Description copied from interface: IGameManager
      save the game and send it to the specified connection
      Specified by:
      sendSaveGame in interface IGameManager
      Parameters:
      connId - The connection id to send to
      sFile - The filename to use
      sLocalPath - The path to the file to be used on the client
    • sendChat

      public void sendChat(String origin, String message)
    • sendChat

      public void sendChat(int connId, String origin, String message)
    • sendServerChat

      public void sendServerChat(String message)
    • sendServerChat

      public void sendServerChat(int connId, String message)
    • 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

      public GameManagerPacketHelper getPacketHelper()
    • getAutoSaveService

      public AutosaveService getAutoSaveService()
    • sendGhostSkipMessage

      protected void sendGhostSkipMessage(Player ghost)
      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.