public abstract class VariableAmount extends Object implements DataSerializable
Modifier and Type | Class and Description |
---|---|
static class |
VariableAmount.BaseAndVariance
Represents a base amount with a variance, the final amount will be the
base amount plus or minus a random amount between zero (inclusive) and
the variance (exclusive).
|
static class |
VariableAmount.Fixed
Represents a fixed amount, calls to
VariableAmount.Fixed.getAmount(java.util.Random) will always return
the same fixed value. |
static class |
VariableAmount.OptionalAmount
Represents a variable amount which has a base and a chance of varying.
|
Constructor and Description |
---|
VariableAmount() |
Modifier and Type | Method and Description |
---|---|
static VariableAmount |
baseWithOptionalAddition(double base,
double addition,
double chance)
Creates a new variable about which has a base and a chance to apply a
random additional amount.
|
static VariableAmount |
baseWithOptionalVariance(double base,
double variance,
double chance)
Creates a new variable about which has a base and a chance to apply a
random variance.
|
static VariableAmount |
baseWithRandomAddition(double base,
double addition)
Creates a new variable amount which has a base and an additional amount.
|
static VariableAmount |
baseWithVariance(double base,
double variance)
Creates a new variable about which has a base and variance.
|
static VariableAmount |
fixed(double value)
Creates a new 'fixed' variable amount, calls to
getAmount(java.util.Random) will
always return the fixed value. |
abstract double |
getAmount(Random rand)
Gets an instance of the variable amount depending on the given random
object.
|
int |
getFlooredAmount(Random rand)
Gets the amount as if from
getAmount(Random) but floored to the
nearest integer equivalent. |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
toContainer
public static VariableAmount fixed(double value)
getAmount(java.util.Random)
will
always return the fixed value.value
- The fixed valuepublic static VariableAmount baseWithVariance(double base, double variance)
base
- The base valuevariance
- The variancepublic static VariableAmount baseWithRandomAddition(double base, double addition)
base
- The base valueaddition
- The additional amountpublic static VariableAmount baseWithOptionalVariance(double base, double variance, double chance)
base
- The base valuevariance
- The variancechance
- The chance to apply the variancepublic static VariableAmount baseWithOptionalAddition(double base, double addition, double chance)
base
- The base valueaddition
- The additional amountchance
- The chance to apply the additional amountpublic abstract double getAmount(Random rand)
rand
- The random objectpublic int getFlooredAmount(Random rand)
getAmount(Random)
but floored to the
nearest integer equivalent.rand
- The random object