games.strategy.triplea.delegate
Class DiceRoll
java.lang.Object
games.strategy.triplea.delegate.DiceRoll
- All Implemented Interfaces:
- java.io.Externalizable, java.io.Serializable
public class DiceRoll
- extends java.lang.Object
- implements java.io.Externalizable
Used to store information about a dice roll.
# of rolls at 5, at 4, etc.
Externalizble so we can efficiently write out our dice as ints
rather than as full objects.
- See Also:
- Serialized Form
|
Constructor Summary |
DiceRoll()
|
DiceRoll(int[] dice,
int hits,
int rollAt,
boolean hitOnlyIfEquals)
|
|
Method Summary |
static java.lang.String |
getAnnotation(java.util.List<Unit> units,
PlayerID player,
games.strategy.triplea.delegate.Battle battle)
|
Die |
getDie(int index)
|
int |
getHits()
|
java.util.List<Die> |
getRolls(int rollAt)
|
static boolean |
isAmphibious(java.util.Collection<Unit> m_units)
|
static boolean |
isAmphibiousMarine(UnitAttachment ua,
GameData data)
|
static boolean |
isFirstTurnLimitedRoll(PlayerID player)
|
void |
readExternal(java.io.ObjectInput in)
|
static DiceRoll |
rollAA(java.util.Collection<Unit> attackingUnits,
IDelegateBridge bridge,
Territory location,
GameData data)
|
static DiceRoll |
rollDice(java.util.List<Unit> units,
boolean defending,
PlayerID player,
IDelegateBridge bridge,
GameData data,
games.strategy.triplea.delegate.Battle battle,
java.lang.String annotation)
Roll dice for units. |
int |
size()
|
java.lang.String |
toString()
|
void |
writeExternal(java.io.ObjectOutput out)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
DiceRoll
public DiceRoll(int[] dice,
int hits,
int rollAt,
boolean hitOnlyIfEquals)
- Parameters:
dice - int[] the dice, 0 basedhits - int - the number of hitsrollAt - int - what we roll at, [0,Constants.MAX_DICE]hitOnlyIfEquals - boolean - do we get a hit only if we are equals, or do we hit
when we are equal or less than for example a 5 is a hit when
rolling at 6 for equal and less than, but is not for equals
DiceRoll
public DiceRoll()
rollAA
public static DiceRoll rollAA(java.util.Collection<Unit> attackingUnits,
IDelegateBridge bridge,
Territory location,
GameData data)
rollDice
public static DiceRoll rollDice(java.util.List<Unit> units,
boolean defending,
PlayerID player,
IDelegateBridge bridge,
GameData data,
games.strategy.triplea.delegate.Battle battle,
java.lang.String annotation)
- Roll dice for units.
- Parameters:
annotation - TODO
isFirstTurnLimitedRoll
public static boolean isFirstTurnLimitedRoll(PlayerID player)
isAmphibious
public static boolean isAmphibious(java.util.Collection<Unit> m_units)
isAmphibiousMarine
public static boolean isAmphibiousMarine(UnitAttachment ua,
GameData data)
getAnnotation
public static java.lang.String getAnnotation(java.util.List<Unit> units,
PlayerID player,
games.strategy.triplea.delegate.Battle battle)
- Parameters:
units - player - battle -
- Returns:
getHits
public int getHits()
getRolls
public java.util.List<Die> getRolls(int rollAt)
- Parameters:
rollAt - the strength of the roll, eg infantry roll at 2, expecting a
number in [1,6]
- Returns:
- in int[] which shouldnt be modifed, the int[] is 0 based, ie
0..MAX_DICE
size
public int size()
getDie
public Die getDie(int index)
writeExternal
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
- Specified by:
writeExternal in interface java.io.Externalizable
- Throws:
java.io.IOException
readExternal
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
- Specified by:
readExternal in interface java.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object