Record Class GameManagerPacketHelper

java.lang.Object
java.lang.Record
megamek.server.GameManagerPacketHelper

public record GameManagerPacketHelper(AbstractGameManager gameManager) extends Record
This is a helper class used by GameManagers (not Clients) to create packets to send to the Clients.
  • Constructor Details

    • GameManagerPacketHelper

      public GameManagerPacketHelper(AbstractGameManager gameManager)
      Creates an instance of a GameManagerPacketHelper record class.
      Parameters:
      gameManager - the value for the gameManager record component
  • Method Details

    • createAttackPacket

      public Packet createAttackPacket(List<? extends EntityAction> actions, boolean isChargeAttacks)
      Returns:
      A Packet containing information about a list of actions (not limited to Entity!).
    • createChargeAttackPacket

      public Packet createChargeAttackPacket(EntityAction action)
      Returns:
      A Packet containing information about a single unit action (not limited to Entity!).
    • createPlayerDonePacket

      public Packet createPlayerDonePacket(int playerId)
      Returns:
      A Packet containing the player's current done status.
    • createCurrentRoundNumberPacket

      public Packet createCurrentRoundNumberPacket()
      Returns:
      A Packet instructing the Client to set the round number to the GameManager's game's current round.
    • createPhaseChangePacket

      public Packet createPhaseChangePacket()
      Returns:
      A Packet informing the Client of a phase change to the GameManager's game's current phase.
    • createPlanetaryConditionsPacket

      public Packet createPlanetaryConditionsPacket()
      Returns:
      A Packet containing the game's planetary conditions, if it uses them, a newly created PlC otherwise.

      This method avoids throwing an IllegalArgumentException if the game doesn't use PlC as, in that case, the sent packet is likely going to be ignored anyway and not cause the game to break.

    • createBoardsPacket

      public Packet createBoardsPacket()
      Returns:
      A Packet containing the complete Map of boards and IDs to send from Server to Client.
    • createGameSettingsPacket

      public Packet createGameSettingsPacket()
      Returns:
      A packet containing the game settings. Note that this packet differs from the one sent by the Client in that the Client's packet will also contain a password
    • createTurnListPacket

      public Packet createTurnListPacket()
      Returns:
      A packet containing the current list of player turns.
    • createTurnIndexPacket

      public Packet createTurnIndexPacket(int previousPlayerId)
      Parameters:
      previousPlayerId - The ID of the player who triggered the turn change
      Returns:
      A packet containing the current player turn index. The ID of the previous player may be Player.PLAYER_NONE.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • gameManager

      public AbstractGameManager gameManager()
      Returns the value of the gameManager record component.
      Returns:
      the value of the gameManager record component