소스 검색

'Cancel out' reroll pairs when determining re-roll

tags/v0.1.3
bertieb 3 년 전
부모
커밋
0f1fb9ef3b
1개의 변경된 파일10개의 추가작업 그리고 7개의 파일을 삭제
  1. +10
    -7
      dice.ts

+ 10
- 7
dice.ts 파일 보기

@@ -306,15 +306,18 @@ export class Asphodice extends D10 {
* - all below cutoff
*/
rerollNeeded(resultDice: Array<number>): boolean{
// 'Cancel out' matching re-roll dice
let cancelledDice = this.cancelRerollDice(resultDice);

// 1. if no re-rolls we can finish here
if (!(resultDice.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;
}

// count successes and fails
let rerollGood = countOccurrencesOfNumber(resultDice, this.passCrit);
let rerollBad = countOccurrencesOfNumber(resultDice, this.failCrit);
let rerollGood = countOccurrencesOfNumber(cancelledDice, this.passCrit);
let rerollBad = countOccurrencesOfNumber(cancelledDice, this.failCrit);

// 2. only reroll if they don't cancel each other out
if (rerollGood == rerollBad) {
@@ -324,11 +327,11 @@ export class Asphodice extends D10 {
}

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



불러오는 중...
취소
저장