Package megamek.common.units
Class FortifyState
java.lang.Object
megamek.common.units.FortifyState
- All Implemented Interfaces:
Serializable
Tracks whether a unit performing multi-turn fieldwork - digging in (TO:AR p.106) or raising a fortified hex as
Trench/Fieldworks Engineers (TO:AUE p.153) - has been damaged between turns. Per those rules, taking damage during a
turn spent fortifying extends the effort by one turn (regardless of how many attacks were made), so the unit's dug-in
progress counter must not advance on any turn in which it was attacked.
This class is intentionally agnostic about the unit type. Callers supply a "health signature": any integer that only decreases when the unit takes damage (for example, total armor plus internal structure). A decrease in that signature between two consecutive turns means the unit was damaged and the effort is set back by one turn.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbegin(int healthSignature) Records the health signature at the moment fieldwork begins, establishing the baseline that the next turn's checkpoint compares against.booleancheckpointWasDamaged(int healthSignature) Compares the current health signature against the previous checkpoint and stores the new value for next turn.voidreset()Clears the in-progress baseline; call when the unit stops fortifying.boolean
-
Constructor Details
-
FortifyState
public FortifyState()
-
-
Method Details
-
begin
public void begin(int healthSignature) Records the health signature at the moment fieldwork begins, establishing the baseline that the next turn's checkpoint compares against.- Parameters:
healthSignature- the unit's current health signature (for example, total armor + internal)
-
checkpointWasDamaged
public boolean checkpointWasDamaged(int healthSignature) Compares the current health signature against the previous checkpoint and stores the new value for next turn. A decrease since the last checkpoint means the unit was damaged.- Parameters:
healthSignature- the unit's current health signature (for example, total armor + internal)- Returns:
trueif the unit has taken damage since the last checkpoint (so the effort should be extended by one turn);falseon the first checkpoint or when no damage was taken
-
wasExtendedAtLastCheckpoint
public boolean wasExtendedAtLastCheckpoint()- Returns:
trueif the most recentcheckpointWasDamaged(int)detected damage (i.e. the effort was extended). Used to report/notify the delay after the checkpoint has run.
-
reset
public void reset()Clears the in-progress baseline; call when the unit stops fortifying.
-