net.sourceforge.worldsaver.rp
Class RandomEncounter

java.lang.Object
  |
  +--net.sourceforge.worldsaver.rp.RpBase
        |
        +--net.sourceforge.worldsaver.rp.Action
              |
              +--net.sourceforge.worldsaver.rp.RandomEncounter
All Implemented Interfaces:
MiscUtils, Saveable

public class RandomEncounter
extends Action
implements MiscUtils

A Random Encounter can be understood as a table of things that can happen during the night/on the street or whatever.

Version:
Feb 16 2001
Author:
Andreas Schmitz

Fields inherited from interface net.sourceforge.worldsaver.util.MiscUtils
CONSOLE_WIDTH, NEWLINE, RANDOM
 
Constructor Summary
RandomEncounter(java.util.HashMap map)
          Standard constructor.
RandomEncounter(RpBase father, java.lang.String name, int number)
          Standard constructor.
 
Method Summary
 RpBase copy(boolean childs, boolean full)
          Returns a new object with the same values as this object.
 void createActionTree(ActionParticle ap)
          Sets the ActionTree that shall be used for the action.
 void execute()
          Prepares the action for execution.
 int getNumber()
           
 java.lang.String getSaveableString()
          Returns a saveable String.
 boolean isRunnable()
          Returns whether the action is prepared to be executed.
 void setAction(int i, RpBase val)
           
 void setNumber(int val)
           
 void step(int index)
          Causes the action to do a step in a specific direction.
 
Methods inherited from class net.sourceforge.worldsaver.rp.Action
getActionTree, getDecisionMessage, getLocation, getReferencesRight, getStartLocation, getText, isRunning, setStartLocation
 
Methods inherited from class net.sourceforge.worldsaver.rp.RpBase
addChild, addDescription, getChilds, getDescription, getFather, getID, getName, setDescription, setFather, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomEncounter

public RandomEncounter(RpBase father,
                       java.lang.String name,
                       int number)
Standard constructor.
See Also:
RpBase.RpBase(net.sourceforge.worldsaver.rp.RpBase, java.lang.String), Action.Action(net.sourceforge.worldsaver.rp.RpBase, java.lang.String)

RandomEncounter

public RandomEncounter(java.util.HashMap map)
Standard constructor.
See Also:
RpBase.RpBase(net.sourceforge.worldsaver.rp.RpBase, java.lang.String), Action.Action(net.sourceforge.worldsaver.rp.RpBase, java.lang.String)
Method Detail

getSaveableString

public java.lang.String getSaveableString()
                                   throws java.io.IOException
Returns a saveable String.
Overrides:
getSaveableString in class Action
Returns:
the String

copy

public RpBase copy(boolean childs,
                   boolean full)
Description copied from class: RpBase
Returns a new object with the same values as this object. This method copies the fields of the object and all childs, but not the father. Also, every object is created new and a new IDGenerator is created (there are also made new IDs for every object). Note that only every non-abstract subclass should write this method. Like the getDescription method, you can choose whether and how the childs are treated.
Overrides:
copy in class RpBase
Following copied from class: net.sourceforge.worldsaver.rp.RpBase
Parameters:
childs - true means copy the childs, too
full - true means copy the childs of the childs etc., too
Returns:
the new object (the father of all childs)

setNumber

public void setNumber(int val)

setAction

public void setAction(int i,
                      RpBase val)

getNumber

public int getNumber()

execute

public void execute()
Description copied from class: Action
Prepares the action for execution. The first situation (the first step) is executed in this method.
Overrides:
execute in class Action

isRunnable

public boolean isRunnable()
Description copied from class: Action
Returns whether the action is prepared to be executed.
Overrides:
isRunnable in class Action
Following copied from class: net.sourceforge.worldsaver.rp.Action
Returns:
true when ready to be executed

createActionTree

public void createActionTree(ActionParticle ap)
Description copied from class: Action
Sets the ActionTree that shall be used for the action. The action tree should be ready before you insert it here. Depending of its correctness, the action becomes runnable or not.
Overrides:
createActionTree in class Action
Following copied from class: net.sourceforge.worldsaver.rp.Action
Parameters:
top - the ActionParticle that builds the top of the tree

step

public void step(int index)
Description copied from class: Action
Causes the action to do a step in a specific direction. The index is the index of the step the party has chosen.
Overrides:
step in class Action
Following copied from class: net.sourceforge.worldsaver.rp.Action
Parameters:
index - the index