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 Details

    • specialAbilities

      protected final EnumMap<BattleForceSUA,Object> 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

      public EnumMap<BattleForceSUA,Object> getInternalRepr()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSpecialsDisplayString

      public String getSpecialsDisplayString(String delimiter, BattleForceSUAFormatter element)
      Description copied from interface: ASSpecialAbilityCollector
      Returns a formatted SUA string suitable for gameplay display such as on an AS Card. The given delimiter is inserted between SUAs.
      Specified by:
      getSpecialsDisplayString in interface ASSpecialAbilityCollector
      Returns:
      A formatted Special Unit Ability string
    • getSUA

      public Object getSUA(BattleForceSUA spa)
      Specified by:
      getSUA in interface ASSpecialAbilityCollector
      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

      public void setSUA(BattleForceSUA sua)
      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

      public void mergeSUA(BattleForceSUA sua, int intAbilityValue)
      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

      public void mergeSUA(BattleForceSUA sua, double doubleValue)
      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

      public void replaceSUA(BattleForceSUA sua, Object newValue)
      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

      public void setSUA(BattleForceSUA sua, ASDamage damage)
      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

      public void setSUA(BattleForceSUA sua, ASDamageVector damage)
      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

      public boolean hasSUA(BattleForceSUA sua)
      Description copied from interface: ASSpecialAbilityCollector
      Returns 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:
      hasSUA in interface ASSpecialAbilityCollector
      Parameters:
      sua - The Special Unit Ability to check
      Returns:
      True when the given Special Unit Ability is present
    • removeSUA

      public void removeSUA(BattleForceSUA sua)
      Removes the given Special Unit Ability if it is present.