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 SummaryConstructorsConstructorDescriptionGameEndTriggeredEvent(Trigger trigger) Creates an instance of aGameEndTriggeredEventrecord class.
- 
Method SummaryModifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleantoString()Returns a string representation of this record class.trigger()Returns the value of thetriggerrecord component.
- 
Constructor Details- 
GameEndTriggeredEventCreates an instance of aGameEndTriggeredEventrecord class.- Parameters:
- trigger- the value for the- triggerrecord component
 
 
- 
- 
Method Details- 
toStringReturns 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.
- 
isGameEndingpublic boolean isGameEnding()- Specified by:
- isGameEndingin interface- TriggeredEvent
 
- 
hashCodepublic 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.
- 
equalsIndicates 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).
- 
triggerReturns the value of thetriggerrecord component.- Specified by:
- triggerin interface- TriggeredEvent
- Returns:
- the value of the triggerrecord component
 
 
-