diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-06 14:15:03 -0500 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-06 14:15:03 -0500 |
| commit | 9139064c95f6c9c4f7ba1d0aea21e2f5233ad188 (patch) | |
| tree | dd93017bff73e61fec20c58b7baa43d1662c0c5b /dice-lang/src/bjc/dicelang/dice/CompoundingDie.java | |
| parent | b11f8d2c92aaaf1160e69190559ffadc4774f138 (diff) | |
Formatting/Documentation
Diffstat (limited to 'dice-lang/src/bjc/dicelang/dice/CompoundingDie.java')
| -rw-r--r-- | dice-lang/src/bjc/dicelang/dice/CompoundingDie.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/dice-lang/src/bjc/dicelang/dice/CompoundingDie.java b/dice-lang/src/bjc/dicelang/dice/CompoundingDie.java index 9744650..3291b52 100644 --- a/dice-lang/src/bjc/dicelang/dice/CompoundingDie.java +++ b/dice-lang/src/bjc/dicelang/dice/CompoundingDie.java @@ -2,16 +2,37 @@ package bjc.dicelang.dice; import java.util.function.Predicate;
+/**
+ * Implements a compounding die.
+ *
+ * This means that the source will be rolled, and then more single rolls will be
+ * added while it meets a qualification.
+ *
+ * @author Ben Culkin
+ */
public class CompoundingDie implements Die {
private Die source;
private Predicate<Long> compoundOn;
private String compoundPattern;
+ /**
+ * Create a new compounding die with no pattern.
+ *
+ * @param src The die to compound from
+ * @param compound The conditions to compound on
+ */
public CompoundingDie(Die src, Predicate<Long> compound) {
this(src, compound, null);
}
+ /**
+ * Create a new compounding die with a specified pattern.
+ *
+ * @param src The die to compound from
+ * @param compound The conditions to compound on
+ * @param patt The string pattern the condition came from, for printing
+ */
public CompoundingDie(Die src, Predicate<Long> compound, String patt) {
source = src;
@@ -19,14 +40,17 @@ public class CompoundingDie implements Die { compoundPattern = patt;
}
+ @Override
public boolean canOptimize() {
return source.canOptimize() && source.optimize() == 0;
}
+ @Override
public long optimize() {
return 0;
}
+ @Override
public long roll() {
long res = source.roll();
long oldRes = res;
@@ -40,7 +64,11 @@ public class CompoundingDie implements Die { return res;
}
+ @Override
public long rollSingle() {
+ /*
+ * Just compound on a single roll
+ */
long res = source.rollSingle();
long oldRes = res;
@@ -53,6 +81,7 @@ public class CompoundingDie implements Die { return res;
}
+ @Override
public String toString() {
if(compoundPattern == null) {
return source + "!!";
@@ -60,4 +89,4 @@ public class CompoundingDie implements Die { return source + "!!" + compoundPattern;
}
}
-}
\ No newline at end of file +}
|
