CMObject
, Tickable
, CMLibrary
, DiceLibrary
, java.lang.Cloneable
, java.lang.Comparable<CMObject>
public class Dice extends StdLibrary implements DiceLibrary
Modifier and Type | Field | Description |
---|---|---|
protected CMath.CompiledFormula |
baseNpcHitpointsFormula |
idConverter
isDebugging, name, serviceClient, tickStatus
STATUS_AFFECT, STATUS_ALIVE, STATUS_BEHAVIOR, STATUS_CLASS, STATUS_DEAD, STATUS_END, STATUS_FIGHT, STATUS_MISC, STATUS_MISC2, STATUS_MISC3, STATUS_MISC4, STATUS_MISC5, STATUS_MISC6, STATUS_MISC7, STATUS_NOT, STATUS_OTHER, STATUS_RACE, STATUS_REBIRTH, STATUS_SCRIPT, STATUS_START, STATUS_WEATHER, TICKID_AREA, TICKID_BALLISTICK, TICKID_CLAN, TICKID_CLANITEM, TICKID_DEADBODY_DECAY, TICKID_ELECTRONICS, TICKID_EMAIL, TICKID_EVENT, TICKID_EXIT_BEHAVIOR, TICKID_EXIT_REOPEN, TICKID_ITEM_BEHAVIOR, TICKID_ITEM_BOUNCEBACK, TICKID_LIGHT_FLICKERS, TICKID_LIVEAUCTION, TICKID_LONGERMASK, TICKID_MISCELLANEOUS, TICKID_MOB, TICKID_PROPERTY_SPECIAL, TICKID_QUEST, TICKID_READYTOSTOP, TICKID_ROOM_BEHAVIOR, TICKID_ROOM_ITEM_REJUV, TICKID_SHORTERMASK, TICKID_SOLITARYMASK, TICKID_SPECIALCOMBAT, TICKID_SPECIALMANEUVER, TICKID_SPELL_AFFECT, TICKID_SUPPORT, TICKID_TIMEAUCTION, TICKID_TRAP_DESTRUCTION, TICKID_TRAP_RESET
Constructor | Description |
---|---|
Dice() |
Modifier and Type | Method | Description |
---|---|---|
boolean |
activate() |
Activates the library.
|
java.lang.Object |
doublePick(java.lang.Object[][] set) |
Selects and returns one of the objects from
the one of the object lists in the set.
|
int[] |
getHPBreakup(int level,
int code) |
Generates the die roll parts for an encoded hit
point bitmap when the code is > 32768,
or according to another formula otherwise.
|
int |
getHPCode(int roll,
int dice,
int plus) |
This function generates an encoded 32 bit
bitmap to represent a die roll for a mob
hitpoints.
|
int |
getHPCode(java.lang.String str) |
This function takes a friendly-ish hit point
die roll formula and generates a bitmap
that can be given to the rollHP method.
|
java.util.Random |
getRandomizer() |
Returns the seeded randomizer used by this lib.
|
java.lang.String |
ID() |
The CoffeeMud Java Class ID shared by all instances of
this object.
|
boolean |
normalizeAndRollLess(int score) |
Takes a score from 0-100, normalizes it to
between 5 and 95, and then rolls a random
number between 0 and 100.
|
int |
normalizeBy5(int score) |
Takes a score from 0-100, normalizes it to
between 5 and 95.
|
int |
pick(int[] set) |
Selects and returns one of the ints from
the set.
|
int |
pick(int[] set,
int not) |
Selects and returns one of the ints from
the set, except for the "not" one given
|
java.lang.Object |
pick(java.lang.Object[] set) |
Selects and returns one of the objects from
the set.
|
java.lang.Object |
pick(java.lang.Object[] set,
java.lang.Object not) |
Selects and returns one of the objects from
the set, except for the "not" one given
|
java.lang.Object |
pick(java.util.List<? extends java.lang.Object> set) |
Selects and returns one of the objects from
the list.
|
double |
plusOrMinus(double range) |
Returns a double from -(range) to (range)
|
float |
plusOrMinus(float range) |
Returns a float from -(range) to (range)
|
int |
plusOrMinus(int range) |
Returns an int from -(range-1) to (range-1)
|
long |
plusOrMinus(long range) |
Returns a long from -(range-1) to (range-1)
|
void |
propertiesLoaded() |
This method is called whenever system properties are altered by the user.
|
int |
roll(int number,
int die,
int modifier) |
The great workhorse that rolls dice.
|
int |
rollHP(int level,
int code) |
Generates hit points for an NPC based on bizarre
rules.
|
int |
rollInRange(int min,
int max) |
Returns a random number within the given
min and max range.
|
long |
rollInRange(long min,
long max) |
Returns a random number within the given
min and max range.
|
int |
rollLowBiased(int number,
int die,
int modifier) |
Rolls dice to generate a random number, but
in a way that biases the lower numbers.
|
int |
rollNormalDistribution(int number,
int die,
int modifier) |
Rolls dice to generate a random number, but
in a way that ensures a more balanced distribution.
|
int |
rollPercentage() |
Returns a random number from 1-100
|
void |
scramble(int[] objs) |
Randomizes the contents of the set
|
void |
scramble(java.lang.Object[] objs) |
Randomizes the contents of the set
|
void |
scramble(java.util.List<?> objs) |
Randomizes the contents of the list.
|
getServiceClient, L, shutdown
copyOf, initializeClass, name, newInstance
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkDatabase, compareTo, copyOf, getServiceClient, getTickStatus, initializeClass, L, name, newInstance, setThreadStatus, shutdown, tick
protected CMath.CompiledFormula baseNpcHitpointsFormula
public java.lang.String ID()
CMObject
ID
in interface CMObject
ID
in class StdLibrary
public java.util.Random getRandomizer()
DiceLibrary
getRandomizer
in interface DiceLibrary
public boolean activate()
CMLibrary
activate
in interface CMLibrary
activate
in class StdLibrary
CMLibrary.shutdown()
public void propertiesLoaded()
CMLibrary
propertiesLoaded
in interface CMLibrary
propertiesLoaded
in class StdLibrary
public boolean normalizeAndRollLess(int score)
DiceLibrary
normalizeAndRollLess
in interface DiceLibrary
score
- the number from 0-100public int normalizeBy5(int score)
DiceLibrary
normalizeBy5
in interface DiceLibrary
score
- the number from 0-100public int rollHP(int level, int code)
DiceLibrary
rollHP
in interface DiceLibrary
level
- the level of the npccode
- the die type, or a bitmapDiceLibrary.getHPCode(String)
,
DiceLibrary.getHPCode(int, int, int)
,
DiceLibrary.getHPBreakup(int, int)
public void scramble(java.util.List<?> objs)
DiceLibrary
scramble
in interface DiceLibrary
objs
- the list to scrambleDiceLibrary.scramble(int[])
public void scramble(int[] objs)
DiceLibrary
scramble
in interface DiceLibrary
objs
- the set to randomizeDiceLibrary.scramble(List)
public void scramble(java.lang.Object[] objs)
DiceLibrary
scramble
in interface DiceLibrary
objs
- the set to randomizeDiceLibrary.scramble(List)
public long plusOrMinus(long range)
DiceLibrary
plusOrMinus
in interface DiceLibrary
range
- the range of the random longDiceLibrary.plusOrMinus(int)
public int plusOrMinus(int range)
DiceLibrary
plusOrMinus
in interface DiceLibrary
range
- the range of the random intDiceLibrary.plusOrMinus(long)
public double plusOrMinus(double range)
DiceLibrary
plusOrMinus
in interface DiceLibrary
range
- the range of the random doubleDiceLibrary.plusOrMinus(long)
public float plusOrMinus(float range)
DiceLibrary
plusOrMinus
in interface DiceLibrary
range
- the range of the random floatDiceLibrary.plusOrMinus(long)
public int rollInRange(int min, int max)
DiceLibrary
rollInRange
in interface DiceLibrary
min
- the minimum of the rangemax
- the maximum of the rangeDiceLibrary.rollInRange(long, long)
,
DiceLibrary.roll(int, int, int)
,
DiceLibrary.rollLowBiased(int, int, int)
,
DiceLibrary.rollNormalDistribution(int, int, int)
public long rollInRange(long min, long max)
DiceLibrary
rollInRange
in interface DiceLibrary
min
- the minimum of the rangemax
- the maximum of the rangeDiceLibrary.rollInRange(int, int)
,
DiceLibrary.roll(int, int, int)
,
DiceLibrary.rollLowBiased(int, int, int)
,
DiceLibrary.rollNormalDistribution(int, int, int)
public java.lang.Object doublePick(java.lang.Object[][] set)
DiceLibrary
doublePick
in interface DiceLibrary
set
- the sets to choose fromDiceLibrary.pick(Object[], Object)
,
DiceLibrary.pick(Object[])
,
DiceLibrary.pick(int[])
,
DiceLibrary.pick(List)
,
DiceLibrary.pick(int[], int)
public java.lang.Object pick(java.lang.Object[] set, java.lang.Object not)
DiceLibrary
pick
in interface DiceLibrary
set
- the set to choose fromnot
- null, or a member to not selectDiceLibrary.pick(Object[])
,
DiceLibrary.pick(int[])
,
DiceLibrary.pick(List)
,
DiceLibrary.pick(int[], int)
,
DiceLibrary.doublePick(Object[][])
public java.lang.Object pick(java.lang.Object[] set)
DiceLibrary
pick
in interface DiceLibrary
set
- the set to choose fromDiceLibrary.pick(Object[], Object)
,
DiceLibrary.pick(int[])
,
DiceLibrary.pick(List)
,
DiceLibrary.pick(int[], int)
,
DiceLibrary.doublePick(Object[][])
public int pick(int[] set, int not)
DiceLibrary
pick
in interface DiceLibrary
set
- the set to choose fromnot
- null, or a member to not selectDiceLibrary.pick(Object[])
,
DiceLibrary.pick(Object[], Object)
,
DiceLibrary.pick(int[])
,
DiceLibrary.pick(List)
,
DiceLibrary.doublePick(Object[][])
public int rollNormalDistribution(int number, int die, int modifier)
DiceLibrary
rollNormalDistribution
in interface DiceLibrary
number
- the number of times to rolldie
- the sides of the diemodifier
- the amount to addDiceLibrary.roll(int, int, int)
,
DiceLibrary.rollLowBiased(int, int, int)
,
DiceLibrary.rollInRange(int, int)
,
DiceLibrary.rollInRange(long, long)
public int rollLowBiased(int number, int die, int modifier)
DiceLibrary
rollLowBiased
in interface DiceLibrary
number
- the number of times to rolldie
- the sides of the diemodifier
- the amount to addDiceLibrary.roll(int, int, int)
,
DiceLibrary.rollNormalDistribution(int, int, int)
,
DiceLibrary.rollInRange(int, int)
,
DiceLibrary.rollInRange(long, long)
public int pick(int[] set)
DiceLibrary
pick
in interface DiceLibrary
set
- the set to choose fromDiceLibrary.pick(Object[], Object)
,
DiceLibrary.pick(Object[])
,
DiceLibrary.pick(List)
,
DiceLibrary.pick(int[], int)
,
DiceLibrary.doublePick(Object[][])
public java.lang.Object pick(java.util.List<? extends java.lang.Object> set)
DiceLibrary
pick
in interface DiceLibrary
set
- the list to choose fromDiceLibrary.pick(Object[], Object)
,
DiceLibrary.pick(Object[])
,
DiceLibrary.pick(int[])
,
DiceLibrary.pick(int[], int)
,
DiceLibrary.doublePick(Object[][])
public int getHPCode(java.lang.String str)
DiceLibrary
getHPCode
in interface DiceLibrary
str
- the string to evaluateDiceLibrary.getHPCode(int, int, int)
,
DiceLibrary.rollHP(int, int)
,
DiceLibrary.getHPBreakup(int, int)
public int getHPCode(int roll, int dice, int plus)
DiceLibrary
getHPCode
in interface DiceLibrary
roll
- the number of die rollsdice
- the sides on the dieplus
- the amount to add to the resultDiceLibrary.getHPCode(String)
,
DiceLibrary.rollHP(int, int)
,
DiceLibrary.getHPBreakup(int, int)
public int[] getHPBreakup(int level, int code)
DiceLibrary
getHPBreakup
in interface DiceLibrary
level
- the level of the npccode
- the die type, or a bitmapDiceLibrary.getHPCode(String)
,
DiceLibrary.getHPCode(int, int, int)
,
DiceLibrary.rollHP(int, int)
public int roll(int number, int die, int modifier)
DiceLibrary
roll
in interface DiceLibrary
number
- the number of times to rolldie
- the sides of the diemodifier
- the amount to addDiceLibrary.rollNormalDistribution(int, int, int)
,
DiceLibrary.rollLowBiased(int, int, int)
,
DiceLibrary.rollInRange(long, long)
,
DiceLibrary.rollInRange(int, int)
public int rollPercentage()
DiceLibrary
rollPercentage
in interface DiceLibrary