|
@@ -13,6 +13,10 @@ class Dice {
|
|
}
|
|
}
|
|
|
|
|
|
public roll (stat : number) : Array<number> {
|
|
public roll (stat : number) : Array<number> {
|
|
|
|
+ if (stat == 0) {
|
|
|
|
+ return [this.minResult];
|
|
|
|
+ }
|
|
|
|
+
|
|
let rng = this.range.slice();
|
|
let rng = this.range.slice();
|
|
if (stat >= 10) {
|
|
if (stat >= 10) {
|
|
rng.push(2, 1);
|
|
rng.push(2, 1);
|
|
@@ -32,6 +36,10 @@ class Dice {
|
|
return results;
|
|
return results;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public rollAndSum (stat : number) : number {
|
|
|
|
+ return this.roll(stat).reduce(Dice.sum);
|
|
|
|
+ }
|
|
|
|
+
|
|
public static sum (a, b) {
|
|
public static sum (a, b) {
|
|
return a + b;
|
|
return a + b;
|
|
}
|
|
}
|