summaryrefslogtreecommitdiff
path: root/dice/src/main/java/bjc/dicelang/dicev2/CompoundDieMod.java
diff options
context:
space:
mode:
Diffstat (limited to 'dice/src/main/java/bjc/dicelang/dicev2/CompoundDieMod.java')
-rw-r--r--dice/src/main/java/bjc/dicelang/dicev2/CompoundDieMod.java35
1 files changed, 33 insertions, 2 deletions
diff --git a/dice/src/main/java/bjc/dicelang/dicev2/CompoundDieMod.java b/dice/src/main/java/bjc/dicelang/dicev2/CompoundDieMod.java
index 6b752f2..519170b 100644
--- a/dice/src/main/java/bjc/dicelang/dicev2/CompoundDieMod.java
+++ b/dice/src/main/java/bjc/dicelang/dicev2/CompoundDieMod.java
@@ -6,17 +6,44 @@ import java.util.ArrayList;
import java.util.List;
import java.util.function.LongPredicate;
+/**
+ * Create a compounding dice.
+ *
+ * Compounding dice are rolled more than once, if they pass a given predicate.
+ * @author Ben Culkin
+ *
+ */
public class CompoundDieMod extends Die {
+ /**
+ * The pool of dice that make up this compound die mod.
+ */
public final Die[] dice;
+ /**
+ * The compare point to determine when to compound.
+ */
public final LongPredicate compound;
+ /**
+ * Whether or not the compounding should 'penetrate' (subtract 1 before exploding)
+ */
public final boolean penetrate;
+ /**
+ * Create a new compound die.
+ * @param compound The predicate to compound on.
+ * @param dice The pool of dice to roll.
+ */
public CompoundDieMod(LongPredicate compound, Die... dice) {
this(compound, false, dice);
}
-
+
+ /**
+ * Create a new compound die.
+ * @param compound The predicate to compound on.
+ * @param penetrate Whether or not compounding should penetrate.
+ * @param dice The pool of dice to roll.
+ */
public CompoundDieMod(LongPredicate compound, boolean penetrate, Die... dice) {
super();
@@ -27,6 +54,7 @@ public class CompoundDieMod extends Die {
this.penetrate = penetrate;
}
+ @Override
public long[] roll() {
List<Long> lst = new ArrayList<>(5);
@@ -51,6 +79,7 @@ public class CompoundDieMod extends Die {
return ListUtils.toPrimitive(lst);
}
+ @Override
public long rollSingle() {
Die die = dice[0];
@@ -70,11 +99,13 @@ public class CompoundDieMod extends Die {
}
/* :UnoptimizableDice */
+ @Override
public boolean canOptimize() {
return false;
}
+ @Override
public long optimize() {
- throw new UnsupportedOperationException("Exploding dice can't be optimized");
+ throw new UnsupportedOperationException("Compounding dice can't be optimized");
}
}