Record Class InfantryActionDeclaration

java.lang.Object
java.lang.Record
megamek.common.InfantryActionDeclaration
Record Components:
playerId - the declaring player
buildingId - the building the action is in, or would be in
committedUnitIds - the player's infantry units, by id, committed this turn; empty for none
committedCrew - crew the defending player commits this turn, on top of any already committed; 0 for an attacker
withdraw - true when the player withdraws their whole force this turn; a defender may only under the house rule that allows it
All Implemented Interfaces:
Serializable

public record InfantryActionDeclaration(int playerId, int buildingId, List<Integer> committedUnitIds, int committedCrew, boolean withdraw) extends Record implements Serializable
One player's declaration for an infantry vs. infantry action in one building, made in the Pre-End Declarations phase (TO:AR pp. 169 to 172). An attacker commits units, or withdraws the force; a defender commits units and a number of crew. It travels in a packet and is applied to unit state; it is never saved itself.
See Also:
  • Constructor Details

    • InfantryActionDeclaration

      public InfantryActionDeclaration(int playerId, int buildingId, List<Integer> committedUnitIds, int committedCrew, boolean withdraw)
      Creates an instance of a InfantryActionDeclaration record class.
      Parameters:
      playerId - the value for the playerId record component
      buildingId - the value for the buildingId record component
      committedUnitIds - the value for the committedUnitIds record component
      committedCrew - the value for the committedCrew record component
      withdraw - the value for the withdraw record component
  • Method Details

    • attacking

      public static InfantryActionDeclaration attacking(int playerId, int buildingId, List<Integer> committedUnitIds, boolean withdraw)
      An attacker's declaration.
      Parameters:
      playerId - the attacking player
      buildingId - the building
      committedUnitIds - the units committed
      withdraw - whether the force withdraws
      Returns:
      the declaration
    • defending

      public static InfantryActionDeclaration defending(int playerId, int buildingId, List<Integer> committedUnitIds, int committedCrew)
      A defender's declaration.
      Parameters:
      playerId - the defending player
      buildingId - the building
      committedUnitIds - the infantry committed
      committedCrew - the crew committed this turn
      Returns:
      the declaration
    • defending

      public static InfantryActionDeclaration defending(int playerId, int buildingId, List<Integer> committedUnitIds, int committedCrew, boolean withdraw)
      A defender's declaration that may withdraw the defending infantry, under the house rule that allows it.
      Parameters:
      playerId - the defending player
      buildingId - the building
      committedUnitIds - the infantry committed; ignored when withdrawing
      committedCrew - the crew committed this turn; ignored when withdrawing
      withdraw - true to withdraw every defending infantry unit of the player this turn
      Returns:
      the declaration
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • playerId

      public int playerId()
      Returns the value of the playerId record component.
      Returns:
      the value of the playerId record component
    • buildingId

      public int buildingId()
      Returns the value of the buildingId record component.
      Returns:
      the value of the buildingId record component
    • committedUnitIds

      public List<Integer> committedUnitIds()
      Returns the value of the committedUnitIds record component.
      Returns:
      the value of the committedUnitIds record component
    • committedCrew

      public int committedCrew()
      Returns the value of the committedCrew record component.
      Returns:
      the value of the committedCrew record component
    • withdraw

      public boolean withdraw()
      Returns the value of the withdraw record component.
      Returns:
      the value of the withdraw record component