This commit is contained in:
Johannes Loher 2021-02-07 16:32:06 +01:00
parent b1d514844e
commit 54323bd300
4 changed files with 47 additions and 1 deletions

View file

@ -1,6 +1,22 @@
# Risk Dice
An implementation of Risk Dice as found for example in the Splittermond game system.
An implementation of risk dice as found for example in the Splittermond game
system.
This module provides a new dice type which represents a risk die. Rolling a risk
die ist just rolling 4 10 sided dice. The total result is calculated by:
- If there are either two `1`s or a `1` and a `2` in the results, the total sum
is `1 + 1` or `1 + 2` respectively.
- Otherwise, the total result is the sum of the 2 highest results.
```
/roll dr # Roll a risk die.
```
![Risk Dice](./risk-dice.png)
## Installation

BIN
risk-dice.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

30
src/module/risk-dice.ts Normal file
View file

@ -0,0 +1,30 @@
class RiskDie extends DiceTerm {
constructor() {
super({ number: 4, faces: 10 });
}
get total() {
if (!this._evaluated) return null;
let total;
if (this.values.includes(1) && this.values.includes(2)) {
total = 3;
} else if (this.values.filter((res) => res === 1).length > 1) {
total = 2;
} else {
total = this.values
.sort((a, b) => b - a)
.slice(0, 2)
.reduce((acc, e) => acc + e, 0);
}
return total;
}
}
function registerRiskDie() {
CONFIG.Dice.types.push(RiskDie);
CONFIG.Dice.terms.r = RiskDie;
}
Hooks.once('init', () => {
registerRiskDie();
});

View file