View Javadoc
1   package net.sourceforge.rpgee.dice;
2   
3   import net.sourceforge.rpgee.Describable;
4   import net.sourceforge.rpgee.dice.exceptions.InvalidParameterException;
5   
6   /**
7    * As of my nearly 30 years of role-playing, I've seen exactly three kinds of random generation in a game
8    * <ol>
9    * <li>Random numbers get generated and added. My first experience? D&D. 3d4+4 means roll 3 four-siders, add them together and add
10   * 4</li>
11   * <li>Random numbers get generated and values mapped to some other value. This is like cards. The random number for a single deck
12   * of 52 cards is based on which cards have been drawn already. Basically, when you shuffle a deck, you randomize an ordered stack
13   * of 52 numbers and pop them off of the stack one at a time. Each number maps to some suite and card so the card for the value 1
14   * might be the Ace of Spades and for 3 might be the 3 of Spades and so on. Since the stack values were randomized at some point,
15   * the values are only relevant to what they're mapped to.<br/> Of course, you can also do math on these elements (arithmetic with
16   * simple values, rounding, etc) but it's not as common. A more common example of this type of randomizer would be something that
17   * mapped a draw of 5 cards to a poker hand. Complex but completely managable. Doing Texas Hold-'em for (n-players) would require
18   * 1+n draws from the deck, of course, which would overy complicate a poker-hand mapper. <br/>But I've never seen an RPG that used
19   * that sort of resolution system. </li>
20   * <li>Random numbers generated, mapped to some other value, and then the result tallied. The previous example is like drawing a
21   * single card from a deck. This example is more complex. For instance, if a mapper was mapping Fudge dice, it would roll some
22   * number of six-siders and map the results as follows : 1-2 = -1 , 3-4 = 0, 5-6 = +1. It would then add up the mapped values and
23   * make a result. Likewise with systems like WoD where there's some target number each die must hit to be counted. In the current
24   * (new) WoD rules, it's exactly like the Fudge example but maps as follows : 1-7 = 0, 8-10 = +1. The special case for WoD dice is
25   * that 10s get re-rolled and re-mapped, but that's a mechanic associated with that implementation. <br/> For instance, the Hero
26   * System mechanic for dice is fairly odd with regard to mapping a half-die of normal damage to BODY, and would require a parser
27   * that understands that a half-die is intrinsically different from a regular die. But the result is still the same effect (half-die
28   * maps STUN at half the roll, round down, and BODY at 1-5=0 and 6=+1) </li>
29   * </ol>
30   * I'm interested in knowing if there are systems that are somehow different from this. I have yet to find an RPG which uses a
31   * randomization system that can't be rendered down to something that fits into this formula. <br/> <br/> Note that the randomizer
32   * in a system is very different from a resolver, that takes specific game mechanics and generates success/failures against them.
33   * For instance, the OpenRPG1 Hero dice roller has a function that takes a roll and a combat value, determining the defensive CV
34   * that that particular roll will hit.<br/> I think that's neat, but I don't think it's part of the randomizer. We may introduce a
35   * Resolver that allows you to generate arbitrary results based on elements of the Game Tree, but the dice package just generates
36   * (psuedo)random results.
37   * 
38   * @author Mykel
39   * 
40   */
41  public interface RandomValue extends Describable {
42  
43      /**
44       * Shows the "rolled" values for random elements The mapped value is presented if this die has a value mapper
45       * 
46       * @return String of the produced value (generally a number)
47       */
48      public String getValueAsString();
49  
50      /**
51       * List of values rolled. This is the "result" of the roll, and can be either an Integer or a List<RandomValue>. Depending on the
52       * type of randomizer something is, a List<RandomValue> might be added together to produce the "valueAsString()" result before
53       * mapping, or it might be the case that each value in the List<RandomValue> gets mapped.
54       */
55      public int getValue();
56      
57      public void setValue(int value) throws InvalidParameterException;
58      
59      public int getSides();
60      
61      public RandomValueResultMapper  getMapper();
62      
63      public RandomValue  getOriginalValue();
64      
65      public boolean isOriginalValue();
66  }