1 package net.sourceforge.rpgee.dice;
2
3 import net.sourceforge.rpgee.Describable;
4 import net.sourceforge.rpgee.Identified;
5 import net.sourceforge.rpgee.dice.exceptions.InvalidParameterException;
6 /**
7 * A mapper for GeneratedRandomValues. One such use would be to map a Hand of Cards to a poker hand. This could be represented by
8 * both a string ("Royal Flush", "2 Aces") or a number (150, 75). In that instance, it would be reasonable to compare the results of two
9 * different mappings to determine which was "better" or "bigger"
10 *
11 * An entirely different use might be to map all of a generated result's rolls against some arbitrary "target number" to see if
12 * a "success" was indicated.
13 *
14 * These classes are almost always specific to a particular type of GeneratedRandomValue. It might be best to keep them as private
15 * inner classes to the various GeneratedRandomValues and make them available only with a factory call on that value.
16 *
17 * @TODO Implement the GeneratedRandomValueMapper within the dice framework
18 * @author Mykel
19 *
20 */
21 public interface GeneratedRandomValueMapper extends Identified, Describable {
22 /**
23 * Generate a numeric value, usually ordinal according to weight, for the GeneratedRandomValue and any attendant data passed
24 * in as mapping data. MappingData could be a GameMapModel of parameters, or an Integer or some other thingie.
25 *
26 * @param v A GeneratedRandomValue
27 * @param mappingData An arbitrary, and optional, parameter for use by the call
28 * @return Some integer representation of the GeneratedRandomValue
29 * @throws InvalidParameterException if the Value or the Mapping data isnot of the correct type
30 */
31 public int getNumericValueForGeneratedRandomValue(GeneratedRandomValue v, Object mappingData) throws InvalidParameterException;
32 /**
33 * Generate a string value for the GeneratedRandomValue and any attendant data passed
34 * in as mapping data. MappingData could be a GameMapModel of parameters, or an Integer or some other thingie.
35 *
36 * @param v A GeneratedRandomValue
37 * @param mappingData An arbitrary, and optional, parameter for use by the call
38 * @return Some String representation of the GeneratedRandomValue
39 * @throws InvalidParameterException if the Value or the Mapping data isnot of the correct type
40 */
41 public int getStringValueForGeneratedRandomValue(GeneratedRandomValue v, Object mappingData) throws InvalidParameterException;
42 /**
43 * Returns true if this mapper supports the specified class
44 * @param c
45 * @return
46 */
47 public boolean supports(Class c);
48 /**
49 * @return true if the mappingData parameter is NOT optional
50 */
51 public boolean isMappingDataRequired();
52 }