Package megamek.common.alphaStrike
Class ASSpecialAbilityCollection
java.lang.Object
megamek.common.alphaStrike.ASSpecialAbilityCollection
- All Implemented Interfaces:
Serializable,ASSpecialAbilityCollector
- Direct Known Subclasses:
ASArcSummary,ASTurretSummary
public class ASSpecialAbilityCollection
extends Object
implements Serializable, ASSpecialAbilityCollector
This class encapsulates a block of AlphaStrike or BattleForce or SBF special abilities. Most AlphaStrike elements or
BF or SBF formations have a single such block of special abilities which may be empty or contain one or many SPAs.
AlphaStrike elements that use arcs have an additional special ability block per arc. Units with turret(s) have one or
more such blocks as part of the ASTurretSummary representing the turret(s).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final EnumMap<BattleForceSUA, Object> The map holding all the Special Unit Abilities and their associated objects (or null). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetSpecialsDisplayString(String delimiter, BattleForceSUAFormatter element) Returns a formatted SUA string suitable for gameplay display such as on an AS Card.getSUA(BattleForceSUA spa) booleanhasSUA(BattleForceSUA sua) Returns true when the element, turret or arc has the given Special Unit Ability.booleanisEmpty()voidmergeSUA(BattleForceSUA sua, double doubleValue) Adds a Special Unit Ability associated with a possibly non-integer number such as CT1.5.voidmergeSUA(BattleForceSUA sua, int intAbilityValue) Adds a Special Unit Ability associated with an integer number such as C3M#.voidremoveSUA(BattleForceSUA sua) Removes the given Special Unit Ability if it is present.voidreplaceSUA(BattleForceSUA sua, Object newValue) Replaces the value associated with a Special Unit Ability with the given Object.voidsetSUA(BattleForceSUA sua) Adds a Special Unit Ability that is not associated with any additional information or number, e.g.voidsetSUA(BattleForceSUA sua, ASDamage damage) Adds a Special Unit Ability associated with a single damage value such as IF2.voidsetSUA(BattleForceSUA sua, ASDamageVector damage) Adds a Special Unit Ability associated with a full damage vector such as LRM1/2/2.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface megamek.common.alphaStrike.ASSpecialAbilityCollector
getAC, getBIM, getCAP, getCAR, getCT, getFLK, getFUEL, getHT, getIATM, getIF, getIT, getJMPS, getLAM, getLRM, getMHQ, getMSL, getREAR, getSCAP, getSpecialsDisplayString, getSRM, getStdDamage, getSUBS, getTOR, getTUR, hasAnySUAOf
-
Field Details
-
specialAbilities
The map holding all the Special Unit Abilities and their associated objects (or null).
-
-
Constructor Details
-
ASSpecialAbilityCollection
public ASSpecialAbilityCollection()
-
-
Method Details
-
isEmpty
public boolean isEmpty()- Returns:
- True when there is no special ability present. Note that for arcs and turrets this includes Standard damage which is stored as STD with an ASDamageVector, so TUR is only empty when there is nothing in the turret (and the TUR ability isn't present) and an arc is only empty when it has no damage at all and no abilities. For AlphaStrikeElements, the standard damage is stored separately and their special abilities may be empty even though there is standard damage. Note however, that most units have abilities such as SEAL or SRCH that are present but not shown on the card. E.g., the special abilities of a BM element is never empty, as it has at least SRCH, SOA and SEAL.
-
getInternalRepr
-
toString
-
getSpecialsDisplayString
Description copied from interface:ASSpecialAbilityCollectorReturns a formatted SUA string suitable for gameplay display such as on an AS Card. The given delimiter is inserted between SUAs.- Specified by:
getSpecialsDisplayStringin interfaceASSpecialAbilityCollector- Returns:
- A formatted Special Unit Ability string
-
getSUA
- Specified by:
getSUAin interfaceASSpecialAbilityCollector- Returns:
- The value associated with the given Special Unit Ability. Depending on the given sua, this value can be null or of different types. Preferably use the type-safe specific methods such as getLRM() instead of this method.
-
setSUA
Adds a Special Unit Ability that is not associated with any additional information or number, e.g. RCN. Has no effect when the SUA is already present. -
mergeSUA
Adds a Special Unit Ability associated with an integer number such as C3M#. If that SPA is already present, the given number is added to the one already present. If the present number is a Double type value, that type is preserved. -
mergeSUA
Adds a Special Unit Ability associated with a possibly non-integer number such as CT1.5. If that SUA is already present, the given number is added to the one already present. If the previously present number was an integer, it will be converted to a Double type value. If the resulting value would be 0, the SUA is removed. -
replaceSUA
Replaces the value associated with a Special Unit Ability with the given Object. The previously associated Object, if any, is discarded. If the ability was not present, it is added. -
setSUA
Adds a Special Unit Ability associated with a single damage value such as IF2. If that SUA is already present, the new damage value replaces the former. -
setSUA
Adds a Special Unit Ability associated with a full damage vector such as LRM1/2/2. If that SUA is already present, the new damage value replaces the former. -
hasSUA
Description copied from interface:ASSpecialAbilityCollectorReturns true when the element, turret or arc has the given Special Unit Ability. When it has and the SUA is associated with some value, this value can be assumed to be non-empty or greater than zero. For example, if an element has MHQ, then MHQ >= 1. If it has IF, then the IF damage is at least 0*.- Specified by:
hasSUAin interfaceASSpecialAbilityCollector- Parameters:
sua- The Special Unit Ability to check- Returns:
- True when the given Special Unit Ability is present
-
removeSUA
Removes the given Special Unit Ability if it is present.
-