Class KilledUnitsTrigger

java.lang.Object
megamek.server.trigger.KilledUnitsTrigger
All Implemented Interfaces:
Trigger

public class KilledUnitsTrigger extends Object implements Trigger
This Trigger reacts when the count of units that were killed is in a given range.
See Also:
  • Constructor Details

    • KilledUnitsTrigger

      public KilledUnitsTrigger(@Nullable String playerName, List<Integer> unitIds, int minUnitCount, int maxUnitCount)
      Creates a Trigger that reacts when the count of units that were killed is between the given min and maxUnitCount. When the playerName is blank, units of all players are counted, otherwise only those of the given player. When a list of unit IDs is given, only those units will be considered. Note that destroyed units can spawn pilots, so providing an ID list to prevent counting the wrong units usually makes sense. Note that this trigger will react multiple times. Use OnceTrigger to limit it to one-time-only.
      Parameters:
      playerName - A player name to limit the checked units to; may be null
      unitIds - A list of Ids to limit the checked units to; when empty, all units are considered
      minUnitCount - the minimum unit count to react to
      maxUnitCount - the maximum unit count to react to
    • KilledUnitsTrigger

      public KilledUnitsTrigger(int unitId)
      Creates a Trigger that reacts when the given unit is killed. Note that this trigger will react multiple times. Use OnceTrigger to limit it to one-time-only.
      Parameters:
      unitId - The unit to look at
    • KilledUnitsTrigger

      public KilledUnitsTrigger(List<Integer> unitIds, int killedUnitCount)
      Creates a Trigger that reacts when the count of units that were killed is equal to the given count. When a list of unit IDs is given, only those units will be considered. Note that destroyed units can spawn pilots, so providing an ID list to prevent counting the wrong units usually makes sense. Note that this trigger will react multiple times. Use OnceTrigger to limit it to one-time-only.
      Parameters:
      unitIds - A list of Ids to limit the checked units to; when empty, all units are considered
      killedUnitCount - The count of killed units to react to
  • Method Details

    • isTriggered

      public boolean isTriggered(IGame game, TriggerSituation event)
      Description copied from interface: Trigger
      Returns true when this Trigger is triggered, i.e. if the prerequisites for its associated event are deemed to be satisfied. Note that the event is itself responsible for making sure that it only returns true once, if it should only trigger once. If it returns true on multiple occasions, the triggered event may happen multiple times. The given TriggerEvent specifies when at what moment of the game this method is called.
      Specified by:
      isTriggered in interface Trigger
      Parameters:
      game - The game
      event - The type of event that caused the trigger to be called
      Returns:
      True when this Trigger considers itself triggered, false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object