Package megamek.server.trigger
Class KilledUnitsTrigger
java.lang.Object
megamek.server.trigger.KilledUnitsTrigger
- All Implemented Interfaces:
Trigger
This Trigger reacts when the count of units that were killed is in a given
range.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionKilledUnitsTrigger
(int unitId) Creates a Trigger that reacts when the given unit is killed.KilledUnitsTrigger
(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.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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isTriggered
(IGame game, TriggerSituation event) Returns true when this Trigger is triggered, i.e.toString()
-
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. UseOnceTrigger
to limit it to one-time-only.- Parameters:
playerName
- A player name to limit the checked units to; may be nullunitIds
- A list of Ids to limit the checked units to; when empty, all units are consideredminUnitCount
- the minimum unit count to react tomaxUnitCount
- 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. UseOnceTrigger
to limit it to one-time-only.- Parameters:
unitId
- The unit to look at
-
KilledUnitsTrigger
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. UseOnceTrigger
to limit it to one-time-only.- Parameters:
unitIds
- A list of Ids to limit the checked units to; when empty, all units are consideredkilledUnitCount
- The count of killed units to react to
-
-
Method Details
-
isTriggered
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 interfaceTrigger
- Parameters:
game
- The gameevent
- The type of event that caused the trigger to be called- Returns:
- True when this Trigger considers itself triggered, false otherwise
-
toString
-