diff options
| author | Ben Culkin <scorpress@gmail.com> | 2021-03-13 09:11:12 -0500 |
|---|---|---|
| committer | Ben Culkin <scorpress@gmail.com> | 2021-03-13 09:11:12 -0500 |
| commit | 7efb7b9e997e0977c8343718cd8b5149805ea57b (patch) | |
| tree | 869ba045f07a6c5aa8a9c6d388941cc5a4862192 /dice/src/main/java/bjc/dicelang/neodice/Die.java | |
| parent | c7c7503bd4a31e88924514d8e6fd4885fcfac042 (diff) | |
Add more documentation
Also, changed my mind on the way DiePool and its implementations should
be structured. The implementations go in the die pool file as internal
classes, because nobody should particularly care the specifics about
their die pool, only that it does what it says it should
Diffstat (limited to 'dice/src/main/java/bjc/dicelang/neodice/Die.java')
| -rw-r--r-- | dice/src/main/java/bjc/dicelang/neodice/Die.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/dice/src/main/java/bjc/dicelang/neodice/Die.java b/dice/src/main/java/bjc/dicelang/neodice/Die.java index 910d173..9d1ac4b 100644 --- a/dice/src/main/java/bjc/dicelang/neodice/Die.java +++ b/dice/src/main/java/bjc/dicelang/neodice/Die.java @@ -5,11 +5,12 @@ import java.util.function.*; import java.util.stream.*; import bjc.dicelang.neodice.die.*; -import bjc.dicelang.neodice.diepool.*; /** * Represents a single polyhedral die. * @author Ben Culkin + * + * @param <SideType> The type of value represented by this die. * */ @FunctionalInterface @@ -40,6 +41,7 @@ public interface Die<SideType> { /** * Returns a die which will reroll this die as long as the provided condition is true. * + * @param comparer The thing to use to compare die values. * @param condition The condition to reroll the die on. * * @return A die that rerolls when the given condition is met. @@ -55,6 +57,7 @@ public interface Die<SideType> { * Returns a die which will reroll this die up to a specified number of times, * as long as the provided condition is true. * + * @param comparer The thing to use to compare die values. * @param condition The condition to reroll the die on. * @param limit The maximum number of times to reroll the die. * @@ -79,6 +82,15 @@ public interface Die<SideType> { return Stream.generate(() -> this.roll(rng)); } + /** + * Create a new transforming die. + * + * @param <NewType> The new type of the die. + * + * @param mapper The function to use for mapping. + * + * @return A die that transforms with the given mapping. + */ default <NewType> Die<NewType> transform(Function<SideType, NewType> mapper) { return (rng) -> mapper.apply(this.roll(rng)); } |
