Package megamek.server
Record Class GameManagerPacketHelper
java.lang.Object
java.lang.Record
megamek.server.GameManagerPacketHelper
This is a helper class used by GameManagers (not Clients) to create packets to send to the Clients.
-
Constructor Summary
ConstructorsConstructorDescriptionGameManagerPacketHelper(AbstractGameManager gameManager) Creates an instance of aGameManagerPacketHelperrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncreateAttackPacket(List<? extends EntityAction> actions, boolean isChargeAttacks) createChargeAttackPacket(EntityAction action) createPlayerDonePacket(int playerId) createTurnIndexPacket(int previousPlayerId) final booleanIndicates whether some other object is "equal to" this one.Returns the value of thegameManagerrecord component.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
GameManagerPacketHelper
Creates an instance of aGameManagerPacketHelperrecord class.- Parameters:
gameManager- the value for thegameManagerrecord component
-
-
Method Details
-
createAttackPacket
- Returns:
- A Packet containing information about a list of actions (not limited to Entity!).
-
createChargeAttackPacket
- Returns:
- A Packet containing information about a single unit action (not limited to Entity!).
-
createPlayerDonePacket
- Returns:
- A Packet containing the player's current done status.
-
createCurrentRoundNumberPacket
- Returns:
- A Packet instructing the Client to set the round number to the GameManager's game's current round.
-
createPhaseChangePacket
- Returns:
- A Packet informing the Client of a phase change to the GameManager's game's current phase.
-
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
- Returns:
- A Packet containing the complete Map of boards and IDs to send from Server to Client.
-
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
- Returns:
- A packet containing the current list of player turns.
-
createTurnIndexPacket
- 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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
gameManager
Returns the value of thegameManagerrecord component.- Returns:
- the value of the
gameManagerrecord component
-