Package megamek.server.scriptedEvents
Record Class GameEndTriggeredEvent
java.lang.Object
java.lang.Record
megamek.server.scriptedEvents.GameEndTriggeredEvent
- Record Components:
trigger
- The trigger that decides if victory has occurred
- All Implemented Interfaces:
TriggeredEvent
This class represents events that can be added programmatically or from MM scenarios to check for game end. When the
game ends and no victory conditions are met, the game is a draw. Note: The Trigger must *not* be a one-time trigger.
Some examples for game end triggers:
To end the game after the 10th round:
game.addScriptedEvent(new GameEndTriggeredEvent(new SpecificRoundEndTrigger(10)));
To end the game after after the unit with ID 102 has been killed:
game.addScriptedEvent(new GameEndTriggeredEvent(new UnitKilledTrigger(102)));
To end the game after after the units with IDs 10 and 18 have both fled:
game.addScriptedEvent(new GameEndTriggeredEvent(new FledUnitsTrigger(null, 2, List.of(10,
18))));
Adding multiple conditions to the game is equivalent to OR-ing them. Conditions can be ANDed or NOTed as well using the AndTrigger and NotTrigger:
game.addScriptedEvent(new GameEndTriggeredEvent(
new AndTrigger( new UnitKilledTrigger(2), new FledUnitsTrigger(null, 1))));
-
Constructor Summary
ConstructorsConstructorDescriptionGameEndTriggeredEvent
(Trigger trigger) Creates an instance of aGameEndTriggeredEvent
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.boolean
toString()
Returns a string representation of this record class.trigger()
Returns the value of thetrigger
record component.
-
Constructor Details
-
GameEndTriggeredEvent
Creates an instance of aGameEndTriggeredEvent
record class.- Parameters:
trigger
- the value for thetrigger
record component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
isGameEnding
public boolean isGameEnding()- Specified by:
isGameEnding
in interfaceTriggeredEvent
-
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
trigger
Returns the value of thetrigger
record component.- Specified by:
trigger
in interfaceTriggeredEvent
- Returns:
- the value of the
trigger
record component
-