20 package net.sf.gridarta.model.treasurelist;
22 import java.io.Serializable;
23 import org.jetbrains.annotations.NotNull;
42 public static final int UNSET = -1;
92 protected TreasureObj(@NotNull
final String name,
final boolean isTreasureList,
final boolean isRealChild) {
105 final StringBuilder sb =
new StringBuilder();
107 sb.append(nrof).append(
" ");
111 if (magic != UNSET) {
112 sb.append(
" +").append(magic);
114 if (chance != UNSET) {
115 sb.append(
" (").append(chance).append(
" %)");
117 return sb.toString();
125 protected abstract void appendToString(@NotNull StringBuilder sb);
148 if (chance == UNSET) {
159 chance = (int) Math.round((
double) chance * corrector);
int chance
The chance attribute.
static final long serialVersionUID
The serial version UID.
boolean hasLoop
Set if thi list contains itself.
void setNrof(final int nrof)
Sets the maximum number of generated items.
String getName()
Returns the name of this treasure object.
boolean isRealChild()
Returns whether this node is no a yes or no node.
final String name
The name of this treasure object.
void setHasLoop(final boolean hasLoop)
Sets whether this treasure object contains itself.
int magic
The maximum magic bonus.
boolean isTreasureList()
Returns whether this treasure object is a "treasure" or "treasureone" object.
abstract void appendToString(@NotNull StringBuilder sb)
Appends a description of this treasure object to a StringBuilder.
boolean hasLoop()
Returns whether this treasure object contains itself.
final boolean isTreasureList
Whether this treasure object is a "treasure" or "treasureone" object.
abstract void visit(@NotNull TreasureObjVisitor visitor)
Calls the TreasureObjVisitor callback function appropriate for this instance.
TreasureObj(@NotNull final String name, final boolean isTreasureList, final boolean isRealChild)
Creates a new instance.
final boolean isRealChild
Set for all except yes or no nodes.
static final int UNSET
Unset values.
void correctChance(final double corrector)
Updates the chance attribute by a corrector factor.
Subclass: UserObject (= content object) for nodes in the CFTreasureListTree These can be either treas...
int getMagic()
Returns the magic attribute.
abstract void copyListType(@NotNull TreasureObj treasureObj)
Copes the list type of a treasureone list.
void setChance(final int value)
Sets the chance attribute.
int getChance()
Returns the chance attribute.
Interface for visitors of TreasureObj instances.
int initChance()
Initializes the chance attribute.
int nrof
The maximum number of generated items.
void setMagic(final int magic)
Sets the magic attribute.