Class SimulationManager

java.lang.Object
megamek.server.AbstractGameManager
megamek.common.autoResolve.acar.SimulationManager
All Implemented Interfaces:
IGameManager

public class SimulationManager extends AbstractGameManager
  • Constructor Details

    • SimulationManager

      public SimulationManager(SimulationContext simulationContext, boolean suppressLog)
  • Method Details

    • execute

      public AutoResolveConcludedEvent execute()
    • addPhaseHandler

      public void addPhaseHandler(PhaseHandler phaseHandler)
    • getGameLogger

      public HtmlGameLogger getGameLogger()
    • getConclusionEvent

      public AutoResolveConcludedEvent getConclusionEvent()
    • setFormationAt

      public void setFormationAt(Formation formation, BoardLocation position)
    • 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

      public 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

      public 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
    • resetPlayersDone

      public void resetPlayersDone()
      Called at the beginning of certain phases to make every player ready.
    • resetFormationsDone

      public void resetFormationsDone()
    • resetFormations

      public void resetFormations()
    • rollInitiative

      public void rollInitiative()
      Rolls initiative for all teams.
    • resetInitiative

      public void resetInitiative()
    • getCurrentVictoryResult

      public VictoryResult getCurrentVictoryResult()
      Returns the victory result.
    • isVictory

      public boolean isVictory()
    • getGame

      public SimulationContext getGame()
      Returns:
      The current game instance.
    • setGame

      public void setGame(IGame game)
      Description copied from interface: IGameManager
      Sets the current game instance.
    • getInitiativeHelper

      public InitiativeHelper getInitiativeHelper()
    • getActionsProcessor

      public ActionsProcessor getActionsProcessor()
    • addMovement

      public void addMovement(MoveAction moveAction, Formation activeFormation)
    • addMoraleCheck

      public void addMoraleCheck(MoraleCheckAction acsMoraleCheckAction, Formation formation)
    • addAttack

      public void addAttack(List<Action> actions, Formation formation)
    • addNerveRecovery

      public void addNerveRecovery(RecoveringNerveAction recoveringNerveAction)
    • addWithdraw

      public void addWithdraw(WithdrawAction acsWithdrawAction)
    • flushPendingReports

      public void flushPendingReports()
    • sendPhaseChange

      protected void sendPhaseChange()
      Overrides:
      sendPhaseChange in class AbstractGameManager
    • getCommandList

      public List<ServerCommand> getCommandList(Server server)
    • addReport

      public void addReport(ReportEntry r)
    • 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.
    • isLogSuppressed

      public boolean isLogSuppressed()
    • requestTeamChangeForPlayer

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

      public void removeAllEntitiesOwnedBy(Player player)
    • 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.
    • 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.
      Parameters:
      player - The player that disconnected.
    • 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.
      Parameters:
      connId - The id of the player to update
    • 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!
      Parameters:
      rp - the CFR packet returned from a client
    • requestGameMaster

      public void requestGameMaster(Player player)
    • 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)
      Description copied from class: AbstractGameManager
      Sends the given packet to the given connection (= player ID).
      Specified by:
      send in interface IGameManager
      Overrides:
      send in class AbstractGameManager
      See Also: