m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/dice.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/dice.js')
-rw-r--r--src/dice.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/dice.js b/src/dice.js
index becf7dc..58467c4 100644
--- a/src/dice.js
+++ b/src/dice.js
@@ -102,6 +102,15 @@ const bonusAdd = (die1, die2) => {
}
}
+const bonusSubtract = (die1, die2) => {
+ const negative2 = negative(die2)
+ return () => {
+ return die1().map(die => {
+ return () => die() + roll(negative2)
+ })
+ }
+}
+
exports.pool = pool
exports.roll = roll
exports.constant = constant
@@ -113,3 +122,4 @@ exports.explode = explode
exports.keepHigh = keepHigh
exports.keepLow = keepLow
exports.bonusAdd = bonusAdd
+exports.bonusSubtract = bonusSubtract