A HitDieStep represents a modified HitDie that changes along the path of Hit Dice defined in the Game Mode. A bound may be set in order to limit movement beyond a given point. Because the number of steps that this HitDieStep will apply is provided during construction, the object constructing this H
| 30 | * understand if it is setting an upper or lower bound. |
| 31 | */ |
| 32 | public class HitDieStep implements Processor<HitDie> |
| 33 | { |
| 34 | |
| 35 | /** |
| 36 | * The number of steps by which this HitDieStep object will modify the |
| 37 | * incoming HitDie. |
| 38 | */ |
| 39 | private final int numSteps; |
| 40 | |
| 41 | /** |
| 42 | * The bound beyond which this HitDieStep will not modify the incoming |
| 43 | * HitDie. This bound overrides the number of steps to be taken, if the |
| 44 | * bound is reached. |
| 45 | */ |
| 46 | private final HitDie dieLimit; |
| 47 | |
| 48 | /** |
| 49 | * Constructs a new HitDieStep object with the given number of steps and |
| 50 | * bound. |
| 51 | * |
| 52 | * Because the number of steps that this HitDieStep will apply is provided |
| 53 | * during construction, the object constructing this HitDieStep is expected |
| 54 | * to understand if it is setting an upper or lower bound. |
| 55 | * |
| 56 | * *NOTE* if the HitDie provided as a bound is not in the global sequence of |
| 57 | * HitDie objects (defined in the Game Mode), then this method will fail to |
| 58 | * stop at the bound. Matching on this bound is exact. |
| 59 | * |
| 60 | * @param steps |
| 61 | * The number of steps this HitDieStep will modify the incoming |
| 62 | * HitDie provided to applyProcessor |
| 63 | * @param stopAt |
| 64 | * The bound, indicating the HitDie at which the HitDitStep will |
| 65 | * not proceed. This bound overrides the number of steps to be |
| 66 | * taken, if the bound is reached. This bound may be null to |
| 67 | * indicate there is no bound. |
| 68 | * @throws IllegalArgumentException |
| 69 | * if the number of steps is zero (since that is effectively a |
| 70 | * pass-through, no Processor is required) |
| 71 | */ |
| 72 | public HitDieStep(int steps, HitDie stopAt) |
| 73 | { |
| 74 | if (steps == 0) |
| 75 | { |
| 76 | throw new IllegalArgumentException(); |
| 77 | } |
| 78 | numSteps = steps; |
| 79 | dieLimit = stopAt; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Applies this Processor to the given input object, in the context of the |
| 84 | * given context object. |
| 85 | * |
| 86 | * *NOTE* if the HitDie provided is not in the global sequence of HitDie |
| 87 | * objects (defined in the Game Mode), then this method will fail to step |
| 88 | * that HitDie, and the original, unmodified HitDie will be returned. |
| 89 | * |
nothing calls this directly
no outgoing calls
no test coverage detected