Package megamek.server.scriptedEvents
Record Class DrawTriggeredEvent
java.lang.Object
java.lang.Record
megamek.server.scriptedEvents.DrawTriggeredEvent
- Record Components:
trigger- The trigger that decides if a draw has occurredendsGame- When true, ends the game when it happens, when false, is only checked when the game has ended
- All Implemented Interfaces:
TriggeredEvent,VictoryCondition
public record DrawTriggeredEvent(Trigger trigger, boolean endsGame)
extends Record
implements TriggeredEvent, VictoryCondition
This class represents "victory" events that are a draw that can be added programmatically or from MM scenarios to
check for a draw result. There are two ways these victory events can be used, depending on the endsGame parameter:
When endsGame is true, this victory condition is checked at the end of game rounds and if it is met, the game ends.
When endsGame is false, this victory condition is only checked after the game has already ended through another
condition (e.g. round limit or other event).
Note: Victory Triggers must *not* be one-time triggers. Victory is checked multiple times, even when victory is achieved and triggers must be able to react multiple times.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDrawTriggeredEvent(Trigger trigger, boolean endsGame) Creates an instance of aDrawTriggeredEventrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncheckVictory(Game game, Map<String, Object> context) Tests if a victory (or draw) has occurred and returns a properly filled in VictoryResult.booleanendsGame()Returns the value of theendsGamerecord component.final 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
-
Method Details
-
checkVictory
Description copied from interface:VictoryConditionTests if a victory (or draw) has occurred and returns a properly filled in VictoryResult. Should returnVictoryResult.noResult()if this victory condition has not been met.- Specified by:
checkVictoryin interfaceVictoryCondition- Parameters:
game- The currentGamecontext- The context to consider, seeVictoryCondition(currently unused)- Returns:
- The result of the victory condition test
-
trigger
Returns the value of thetriggerrecord component.- Specified by:
triggerin interfaceTriggeredEvent- Returns:
- the value of the
triggerrecord component
-
isGameEnding
public boolean isGameEnding()- Specified by:
isGameEndingin interfaceTriggeredEvent
-
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. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
endsGame
public boolean endsGame()Returns the value of theendsGamerecord component.- Returns:
- the value of the
endsGamerecord component
-