games.strategy.engine.random
Class ScriptedRandomSource

java.lang.Object
  extended by games.strategy.engine.random.ScriptedRandomSource
All Implemented Interfaces:
IRandomSource

public class ScriptedRandomSource
extends java.lang.Object
implements IRandomSource

A random source for use while debugging.

Returns the random numbers designated in the system property triplea.scriptedRandom

for example, to roll 1,2,3 use -Dtriplea.scriptedRandom=1,2,3

When scripted random runs out of numbers, the numbers will repeat.

Special characters are also allowed in the sequence. e - the random source will throw an error p - the random source will pause and never return.

Author:
Sean Bridges

Field Summary
static int ERROR
           
static int PAUSE
           
 
Constructor Summary
ScriptedRandomSource()
          Create a scripted random source from the system property triplea.scriptedRandom.
ScriptedRandomSource(int[] numbers)
          Create a scripted random from the given numbers.
ScriptedRandomSource(java.lang.Integer... numbers)
           
 
Method Summary
 int[] getRandom(int max, int count, java.lang.String annotation)
           
 int getRandom(int max, java.lang.String annotation)
           
 int getTotalRolled()
           
static boolean useScriptedRandom()
          Should we use a scripted random sourcce.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAUSE

public static final int PAUSE
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values
Constructor Detail

ScriptedRandomSource

public ScriptedRandomSource()
Create a scripted random source from the system property triplea.scriptedRandom.


ScriptedRandomSource

public ScriptedRandomSource(int[] numbers)
Create a scripted random from the given numbers. The scripted random will return the numbers supplied in order. When the scripted source runs out of random numbers, it starts returning elements from the beginning.


ScriptedRandomSource

public ScriptedRandomSource(java.lang.Integer... numbers)
Method Detail

useScriptedRandom

public static boolean useScriptedRandom()
Should we use a scripted random sourcce.


getRandom

public int getRandom(int max,
                     java.lang.String annotation)
Specified by:
getRandom in interface IRandomSource

getRandom

public int[] getRandom(int max,
                       int count,
                       java.lang.String annotation)
Specified by:
getRandom in interface IRandomSource

getTotalRolled

public int getTotalRolled()