Browse Source

export Outcomes + simplify reroll abovebelow check

tags/v0.1.3
bertieb 3 years ago
parent
commit
ec315db5a4
1 changed files with 2 additions and 10 deletions
  1. +2
    -10
      dice.ts

+ 2
- 10
dice.ts View File

@@ -27,7 +27,7 @@ interface Dice {
readonly type: string; readonly type: string;
} }


enum Outcomes {
export enum Outcomes {
Success = "Success", Success = "Success",
Fail = "Failure", Fail = "Failure",
CritSuccess = "Critical Success", CritSuccess = "Critical Success",
@@ -311,7 +311,6 @@ export class Asphodice extends D10 {


// 1. if no re-rolls we can finish here // 1. if no re-rolls we can finish here
if (!(cancelledDice.includes(this.passCrit) || resultDice.includes(this.failCrit))) { if (!(cancelledDice.includes(this.passCrit) || resultDice.includes(this.failCrit))) {
// results.total = results.dice.reduce((acc: number, curr: number) => acc + curr);
return false; return false;
} }


@@ -321,21 +320,14 @@ export class Asphodice extends D10 {


// 2. only reroll if they don't cancel each other out // 2. only reroll if they don't cancel each other out
if (rerollGood == rerollBad) { if (rerollGood == rerollBad) {
// console.log("Good = Bad, no need to reroll");
return false; return false;
// results.total = results.dice.reduce((acc: number, curr: number) => acc + curr);
} }


// 3. If all dice are above/below cutoff we don't need to reroll // 3. If all dice are above/below cutoff we don't need to reroll
if (this.allAboveCutOff(cancelledDice)) {
console.log("All above cutoff, auto-success", cancelledDice);
return false;
} else if (this.allBelowCutOff(cancelledDice)) {
console.log("All below cutoff, auto-fail", cancelledDice);
if (this.allAboveCutOff(cancelledDice) || this.allBelowCutOff(cancelledDice)) {
return false; return false;
} }



// We should re-roll // We should re-roll
return true; return true;




Loading…
Cancel
Save