Package megamek.server.scriptedEvents
Record Class VictoryTriggeredEvent
java.lang.Object
java.lang.Record
megamek.server.scriptedEvents.VictoryTriggeredEvent
- Record Components:
trigger- The trigger that decides if victory has occurredendsGame- When true, ends the game when it happens, when false, is only checked when the game has endedplayerName- The name of the player who wins by this triggered event
- All Implemented Interfaces:
TriggeredEvent,VictoryCondition
public record VictoryTriggeredEvent(Trigger trigger, boolean endsGame, String playerName)
extends Record
implements TriggeredEvent, VictoryCondition
This class represents victory events that can be added programmatically or from MM scenarios to check for victory of
a team. There are two ways these victory events can be used, depending on the isGameEnding parameter: When
isGameEnding is true, this victory condition is checked at the end of game rounds and if it is met, the game ends.
When isGameEnding is false, this victory condition is only checked after the game has already ended through another
condition (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
ConstructorsConstructorDescriptionVictoryTriggeredEvent(Trigger trigger, boolean endsGame, String playerName) Creates an instance of aVictoryTriggeredEventrecord 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.booleanReturns the value of theplayerNamerecord component.toString()Returns a string representation of this record class.trigger()Returns the value of thetriggerrecord component.
-
Constructor Details
-
VictoryTriggeredEvent
Creates an instance of aVictoryTriggeredEventrecord class.- Parameters:
trigger- the value for thetriggerrecord componentendsGame- the value for theendsGamerecord componentplayerName- the value for theplayerNamerecord component
-
-
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
-
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. -
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
-
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
-
playerName
Returns the value of theplayerNamerecord component.- Returns:
- the value of the
playerNamerecord component
-