1 package net.sourceforge.rpgee.dice; 2 3 import java.util.List; 4 5 import net.sourceforge.rpgee.Describable; 6 import net.sourceforge.rpgee.dice.exceptions.InvalidParameterException; 7 import net.sourceforge.rpgee.dice.exceptions.RandomValueException; 8 9 public interface RandomValueGenerator extends Describable { 10 11 /** 12 * The setting (see setSetting below) that is potentially used in the generateRandomness call. 13 */ 14 public final static String DICE_MAPPING_CLASS = "paramMappingClass"; 15 public final static String DIE_HANDLING_CLASS = "paramDieHandlingClass"; 16 17 /** 18 * Returns the internal map of settings used by the "roll" call 19 * 20 * @return 21 */ 22 public Object getSetting(String key); 23 24 /** 25 * Get a list of available settings 26 * 27 * @return 28 */ 29 public String[] getSettings(); 30 31 /** 32 * Sets a setting in the internal settings map to the given value. 33 * 34 * @param setting String name of the setting 35 * @param value Object value to set the setting to 36 */ 37 public void setSetting(String setting, Object value) throws InvalidParameterException; 38 39 /** 40 * Produces a DiceEvaluation 41 * 42 * @param d 43 * @return 44 */ 45 public GeneratedRandomValue produceGeneratedRandomValue(String d) throws RandomValueException; 46 47 /** 48 * Reset the "randomness" factor for a RandomValueGenerator. For instance, getting a new Random object with a new seed or 49 * shuffling a deck of cards. 50 */ 51 public void generateRandomness() throws RandomValueException; 52 53 /** 54 * Set the code that maps values in die rolls to result strings. 55 * 56 * @param mapper The RandomValueResultMapper to map to, or null to use the basic RandomValue's output 57 */ 58 public void setRandomValueResultMapper(RandomValueResultMapper mapper); 59 60 /** 61 * GameMapModel the dice rolls in roll with a mapper if available 62 * 63 * @param GeneratedRandomValue 64 * @return String representation of the dice rolled 65 * @throws MappingException 66 */ 67 public String getRandomValuesAsString(List<RandomValue> roll) throws RandomValueException; 68 69 /** 70 * Returns the local result mapper 71 * 72 * @return Result mapper 73 */ 74 public RandomValueResultMapper getRandomValueResultMapper(); 75 76 public List<RandomValueHandler> getRandomValueHandlers(); 77 78 /** 79 * Set the DieHandlers for this Roller. Die handlers manage the effect of an individual die and are allowed to transform the 80 * value rolled by the randomizer into a new value before display. 81 * 82 * @param handler The RandomValueHandler to use for this randmizer 83 */ 84 public void setRandomValueHandlers(List<RandomValueHandler> handlers); 85 86 /** 87 * Add A new RandomValueHandler to the list of handlers for this roller 88 * 89 * @param handler RandomValueHandler to add 90 */ 91 public void addRandomValueHandler(RandomValueHandler handler); 92 93 /** 94 * Submit some value that is required before a roll can continue. For a deck, this is probably the "minimum number of cards 95 * remaining". For some other randomizer, it might be a "minumum randomness". 96 * 97 * This is purely implementation dependent. For randomizers that don't need this, like dice rollers, an empty implementation is 98 * fine. 99 * 100 * @param requirement Some object passed to this function to determine a randomness factor 101 */ 102 public void require(Object requirement) throws RandomValueException; 103 104 public void setRandomnessFactor(Object o); 105 106 }