Package megamek.common
Record Class InfantryActionDeclaration
java.lang.Object
java.lang.Record
megamek.common.InfantryActionDeclaration
- Record Components:
playerId- the declaring playerbuildingId- the building the action is in, or would be incommittedUnitIds- the player's infantry units, by id, committed this turn; empty for nonecommittedCrew- crew the defending player commits this turn, on top of any already committed;0for an attackerwithdraw-truewhen 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 Summary
ConstructorsConstructorDescriptionInfantryActionDeclaration(int playerId, int buildingId, List<Integer> committedUnitIds, int committedCrew, boolean withdraw) Creates an instance of aInfantryActionDeclarationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic InfantryActionDeclarationAn attacker's declaration.intReturns the value of thebuildingIdrecord component.intReturns the value of thecommittedCrewrecord component.Returns the value of thecommittedUnitIdsrecord component.static InfantryActionDeclarationA defender's declaration.static InfantryActionDeclarationdefending(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.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intplayerId()Returns the value of theplayerIdrecord component.final StringtoString()Returns a string representation of this record class.booleanwithdraw()Returns the value of thewithdrawrecord component.
-
Constructor Details
-
InfantryActionDeclaration
public InfantryActionDeclaration(int playerId, int buildingId, List<Integer> committedUnitIds, int committedCrew, boolean withdraw) Creates an instance of aInfantryActionDeclarationrecord class.- Parameters:
playerId- the value for theplayerIdrecord componentbuildingId- the value for thebuildingIdrecord componentcommittedUnitIds- the value for thecommittedUnitIdsrecord componentcommittedCrew- the value for thecommittedCrewrecord componentwithdraw- the value for thewithdrawrecord 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 playerbuildingId- the buildingcommittedUnitIds- the units committedwithdraw- 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 playerbuildingId- the buildingcommittedUnitIds- the infantry committedcommittedCrew- 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 playerbuildingId- the buildingcommittedUnitIds- the infantry committed; ignored when withdrawingcommittedCrew- the crew committed this turn; ignored when withdrawingwithdraw-trueto withdraw every defending infantry unit of the player this turn- Returns:
- the declaration
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
playerId
public int playerId()Returns the value of theplayerIdrecord component.- Returns:
- the value of the
playerIdrecord component
-
buildingId
public int buildingId()Returns the value of thebuildingIdrecord component.- Returns:
- the value of the
buildingIdrecord component
-
committedUnitIds
Returns the value of thecommittedUnitIdsrecord component.- Returns:
- the value of the
committedUnitIdsrecord component
-
committedCrew
public int committedCrew()Returns the value of thecommittedCrewrecord component.- Returns:
- the value of the
committedCrewrecord component
-
withdraw
public boolean withdraw()Returns the value of thewithdrawrecord component.- Returns:
- the value of the
withdrawrecord component
-