Record Class DrawTriggeredEvent

java.lang.Object
java.lang.Record
megamek.server.scriptedEvents.DrawTriggeredEvent
Record Components:
trigger - The trigger that decides if a draw has occurred
endsGame - 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 Details

    • DrawTriggeredEvent

      public DrawTriggeredEvent(Trigger trigger, boolean endsGame)
      Creates an instance of a DrawTriggeredEvent record class.
      Parameters:
      trigger - the value for the trigger record component
      endsGame - the value for the endsGame record component
  • Method Details

    • checkVictory

      public VictoryResult checkVictory(Game game, Map<String,Object> context)
      Description copied from interface: VictoryCondition
      Tests if a victory (or draw) has occurred and returns a properly filled in VictoryResult. Should return VictoryResult.noResult() if this victory condition has not been met.
      Specified by:
      checkVictory in interface VictoryCondition
      Parameters:
      game - The current Game
      context - The context to consider, see VictoryCondition (currently unused)
      Returns:
      The result of the victory condition test
    • trigger

      public Trigger trigger()
      Returns the value of the trigger record component.
      Specified by:
      trigger in interface TriggeredEvent
      Returns:
      the value of the trigger record component
    • isGameEnding

      public boolean isGameEnding()
      Specified by:
      isGameEnding in interface TriggeredEvent
    • toString

      @Nonnull public String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • endsGame

      public boolean endsGame()
      Returns the value of the endsGame record component.
      Returns:
      the value of the endsGame record component