MCPcopy Create free account
hub / github.com/PCGen/pcgen / HitDieFormula

Class HitDieFormula

code/src/java/pcgen/cdom/processor/HitDieFormula.java:28–106  ·  view source on GitHub ↗

A HitDieFormula represents a modified HitDie that changes relative to a ReferenceFormula

Source from the content-addressed store, hash-verified

26 * ReferenceFormula
27 */
28public class HitDieFormula implements Processor<HitDie>
29{
30
31 /**
32 * The ReferenceFormula used by this HitDieFormula to modify an incoming
33 * HitDie.
34 */
35 private final ReferenceFormula<Integer> formula;
36
37 /**
38 * Constructs a new HitDieFormula object with the given ReferenceFormula to
39 * modify HitDie objects.
40 *
41 * @param refFormula
42 * A ReferenceFormula to modify a HitDie when this HitDieFormula
43 * acts on a given HitDie
44 */
45 public HitDieFormula(ReferenceFormula<Integer> refFormula)
46 {
47 formula = refFormula;
48 }
49
50 /**
51 * Applies this Processor to the given input HitDie, which modifies the given
52 * input HitDie with the formula provided at construction of the
53 * HitDieFormula.
54 *
55 * Since HitDieFormula is universal, the given context is ignored.
56 *
57 * @param origHD
58 * The input HitDie this HitDieFormula will act upon.
59 * @param context
60 * The context, ignored by HitDieFormula.
61 * @return The modified HitDie
62 * @throws NullPointerException
63 * if the given HitDie is null
64 */
65 @Override
66 public HitDie applyProcessor(HitDie origHD, Object context)
67 {
68 return new HitDie(formula.resolve(origHD.getDie()));
69 }
70
71 /**
72 * Returns a representation of this HitDieFormula, suitable for storing in
73 * an LST file.
74 *
75 * @return A representation of this HitDieFormula, suitable for storing in
76 * an LST file.
77 */
78 @Override
79 public String getLSTformat()
80 {
81 return '%' + formula.toString();
82 }
83
84 /**
85 * The class of object this Processor acts upon (HitDie).

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected