Class InitiativeRoll

java.lang.Object
megamek.common.game.InitiativeRoll
All Implemented Interfaces:
Serializable, Comparable<InitiativeRoll>

public class InitiativeRoll extends Object implements Comparable<InitiativeRoll>, Serializable
A roll, or sequence of rolls, made by the player to determine initiative order. Also contains some methods for ordering players by initiative.
Since:
April 25, 2002, 12:21 PM
See Also:
  • Constructor Details

    • InitiativeRoll

      public InitiativeRoll()
    • InitiativeRoll

      public InitiativeRoll(InitiativeRoll other)
      Copy constructor. Produces an independent InitiativeRoll with its own backing vectors, so mutating the copy (e.g. appending tiebreak rolls) does not affect the source. This is important because several call sites carry initiative state over between game/team/entity instances; sharing the same instance by reference lets two distinct candidates compare equal forever, which causes unbounded tie-break recursion.
      Parameters:
      other - The initiative roll to copy; must not be null
  • Method Details

    • clear

      public void clear()
    • addRoll

      public void addRoll(InitiativeBonusBreakdown breakdown, String initiativeAptitudeSPA)
      Adds a new initiative roll with a detailed bonus breakdown.
      Parameters:
      breakdown - The breakdown of all bonus components
      initiativeAptitudeSPA - The initiative aptitude SPA (Combat Sense or Combat Paralysis), or empty string
    • addRoll

      public void addRoll(int bonus, String initiativeAptitudeSPA)
      Adds a new initiative roll with a single bonus value (for backwards compatibility).
      Parameters:
      bonus - The total bonus value
      initiativeAptitudeSPA - The initiative aptitude SPA (Combat Sense or Combat Paralysis), or empty string
    • observerRoll

      public void observerRoll()
      Set observers to -1, and don't ever let them be anything else!
    • replaceRoll

      public void replaceRoll(InitiativeBonusBreakdown breakdown, String initiativeAptitudeSPA)
      Replace the previous init roll with a new one, and make a note that it was replaced. Used for Tactical Genius special pilot ability (lvl 3).
      Parameters:
      breakdown - The breakdown of all bonus components
      initiativeAptitudeSPA - The initiative aptitude SPA (Combat Sense or Combat Paralysis), or empty string
    • replaceRoll

      @Deprecated(since="0.51.0", forRemoval=true) public void replaceRoll(int bonus, String initiativeAptitudeSPA)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Replace the previous init roll with a new one (for backwards compatibility).
      Parameters:
      bonus - The total bonus value
      initiativeAptitudeSPA - The initiative aptitude SPA (Combat Sense or Combat Paralysis), or empty string
    • size

      public int size()
    • getRoll

      public int getRoll(int index)
    • equals

      public boolean equals(Object possibleOther)
      Two initiative rolls are equal if they match, roll by roll
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(InitiativeRoll other)
      Specified by:
      compareTo in interface Comparable<InitiativeRoll>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object