diff --git a/spec/support/ds4rolls.spec.ts b/spec/support/ds4rolls.spec.ts index 6b8e3228..844ba622 100644 --- a/spec/support/ds4rolls.spec.ts +++ b/spec/support/ds4rolls.spec.ts @@ -182,3 +182,65 @@ describe("DS4 Rools with multiple dice and no modifiers.", () => { ); }); }); + +describe("DS4 Rools with multiple dice and min/max modifiers.", () => { + it("Should do a crit fail on `19` for first roll.", () => { + const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRolls"]); + + rollProvider.getNextRolls = jasmine.createSpy("getNextRolls").and.returnValue([19, 15, 6]); + + expect(rollCheckMultipleDice(48, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( + new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [19, 15, 6]), + ); + }); + + it("Should succeed with all rolls crit successes (1 and 2).", () => { + const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRolls"]); + + rollProvider.getNextRolls = jasmine.createSpy("getNextRolls").and.returnValue([2, 1, 2]); + + expect(rollCheckMultipleDice(48, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( + new RollResult(48, RollResultStatus.SUCCESS, [2, 2, 1]), + ); + }); + + it("Should succeed with the last roll not being suficient.", () => { + const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRolls"]); + + rollProvider.getNextRolls = jasmine.createSpy("getNextRolls").and.returnValue([15, 15, 15]); + + expect(rollCheckMultipleDice(48, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( + new RollResult(30, RollResultStatus.SUCCESS, [15, 15, 15]), + ); + }); + + it("Should succeed with the last roll a crit success `2`.", () => { + const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRolls"]); + + rollProvider.getNextRolls = jasmine.createSpy("getNextRolls").and.returnValue([15, 15, 2]); + + expect(rollCheckMultipleDice(48, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( + new RollResult(35, RollResultStatus.SUCCESS, [2, 15, 15]), + ); + }); + + it("Should succeed with the last roll being `20` and one crit success '2'.", () => { + const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRolls"]); + + rollProvider.getNextRolls = jasmine.createSpy("getNextRolls").and.returnValue([15, 2, 20]); + + expect(rollCheckMultipleDice(48, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( + new RollResult(40, RollResultStatus.SUCCESS, [2, 20, 15]), + ); + }); + + it("Should succeed with the last roll being `19` and one crit success '2'.", () => { + const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRolls"]); + + rollProvider.getNextRolls = jasmine.createSpy("getNextRolls").and.returnValue([15, 2, 19]); + + expect(rollCheckMultipleDice(48, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( + new RollResult(39, RollResultStatus.SUCCESS, [2, 19, 15]), + ); + }); +}); diff --git a/src/module/rolls/roll-executor.ts b/src/module/rolls/roll-executor.ts index 1c23d3f2..1d383a62 100644 --- a/src/module/rolls/roll-executor.ts +++ b/src/module/rolls/roll-executor.ts @@ -40,9 +40,6 @@ export function rollCheckMultipleDice( const dice = provider.getNextRolls(numberOfDice); - console.log(dice[0]); - console.log(rollOptions.minCritFail); - const firstResult = dice[0]; if (firstResult >= rollOptions.minCritFail) { @@ -62,9 +59,6 @@ export function rollCheckMultipleDice( .reduce(partitionCallback, [[], []]) .map((a) => a.sort((r1, r2) => r2 - r1)); - console.log(critSuccesses); - console.log(otherRolls); - const sortedRollResults: Array = critSuccesses.concat(otherRolls); const evaluationResult = sortedRollResults