Package megamek.common.game
Class InitiativeRoll
java.lang.Object
megamek.common.game.InitiativeRoll
- All Implemented Interfaces:
Serializable,Comparable<InitiativeRoll>
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new initiative roll with a single bonus value (for backwards compatibility).voidaddRoll(InitiativeBonusBreakdown breakdown, String initiativeAptitudeSPA) Adds a new initiative roll with a detailed bonus breakdown.voidclear()intcompareTo(InitiativeRoll other) booleanTwo initiative rolls are equal if they match, roll by rollintgetRoll(int index) inthashCode()voidSet observers to -1, and don't ever let them be anything else!voidreplaceRoll(int bonus, String initiativeAptitudeSPA) Deprecated, for removal: This API element is subject to removal in a future version.voidreplaceRoll(InitiativeBonusBreakdown breakdown, String initiativeAptitudeSPA) Replace the previous init roll with a new one, and make a note that it was replaced.intsize()toString()
-
Constructor Details
-
InitiativeRoll
public InitiativeRoll() -
InitiativeRoll
Copy constructor. Produces an independentInitiativeRollwith 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 benull
-
-
Method Details
-
clear
public void clear() -
addRoll
Adds a new initiative roll with a detailed bonus breakdown.- Parameters:
breakdown- The breakdown of all bonus componentsinitiativeAptitudeSPA- The initiative aptitude SPA (Combat Sense or Combat Paralysis), or empty string
-
addRoll
Adds a new initiative roll with a single bonus value (for backwards compatibility).- Parameters:
bonus- The total bonus valueinitiativeAptitudeSPA- 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
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 componentsinitiativeAptitudeSPA- 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 valueinitiativeAptitudeSPA- The initiative aptitude SPA (Combat Sense or Combat Paralysis), or empty string
-
size
public int size() -
getRoll
public int getRoll(int index) -
equals
Two initiative rolls are equal if they match, roll by roll -
compareTo
- Specified by:
compareToin interfaceComparable<InitiativeRoll>
-
toString
-
hashCode
public int hashCode()
-