diff --git a/spec/support/ds4rolls.spec.ts b/spec/support/ds4rolls.spec.ts index 054f6818..ec899376 100644 --- a/spec/support/ds4rolls.spec.ts +++ b/spec/support/ds4rolls.spec.ts @@ -71,11 +71,55 @@ describe("DS4 Rolls with one die and no modifications.", () => { }); }); +describe("DS4 Rolls with one die and slaying dice, first throw.", () => { + it("Should do a crit success on `1`", () => { + const rollProvider = mockSingleThrow(1); + + expect(rollCheckSingleDie(4, { useSlayingDice: true } as RollOptions, rollProvider)).toEqual( + new RollResult(4, RollResultStatus.CRITICAL_SUCCESS, [1]), + ); + }); + + it("Should do a crit fail on `20`", () => { + const rollProvider = mockSingleThrow(20); + + expect(rollCheckSingleDie(4, { useSlayingDice: true } as RollOptions, rollProvider)).toEqual( + new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [20]), + ); + }); +}); + +describe("DS4 Rolls with one die and slaying dice, followup throw.", () => { + it("Should do a crit success on `1`", () => { + const rollProvider = mockSingleThrow(1); + + expect( + rollCheckSingleDie(4, { useSlayingDice: true, slayingDiceRepetition: true } as RollOptions, rollProvider), + ).toEqual(new RollResult(4, RollResultStatus.CRITICAL_SUCCESS, [1])); + }); + + it("Should do a regular fail on `20`", () => { + const rollProvider = mockSingleThrow(20); + + expect( + rollCheckSingleDie(4, { useSlayingDice: true, slayingDiceRepetition: true } as RollOptions, rollProvider), + ).toEqual(new RollResult(0, RollResultStatus.FAILURE, [20])); + }); + + it("Should do a regular success on `20` with a test value of 20", () => { + const rollProvider = mockSingleThrow(20); + + expect( + rollCheckSingleDie(20, { useSlayingDice: true, slayingDiceRepetition: true } as RollOptions, rollProvider), + ).toEqual(new RollResult(20, RollResultStatus.SUCCESS, [20])); + }); +}); + describe("DS4 Rolls with one die and crit roll modifications.", () => { it("Should do a crit success on `1`.", () => { const rollProvider = mockSingleThrow(1); - expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( + expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( new RollResult(4, RollResultStatus.CRITICAL_SUCCESS, [1]), ); }); @@ -83,7 +127,7 @@ describe("DS4 Rolls with one die and crit roll modifications.", () => { it("Should do a crit success on `maxCritSucc`.", () => { const rollProvider = mockSingleThrow(2); - expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( + expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( new RollResult(4, RollResultStatus.CRITICAL_SUCCESS, [2]), ); }); @@ -91,7 +135,7 @@ describe("DS4 Rolls with one die and crit roll modifications.", () => { it("Should do a success on lower edge case `3`.", () => { const rollProvider = mockSingleThrow(3); - expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( + expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( new RollResult(3, RollResultStatus.SUCCESS, [3]), ); }); @@ -99,7 +143,7 @@ describe("DS4 Rolls with one die and crit roll modifications.", () => { it("Should do a success on upper edge case `18`.", () => { const rollProvider = mockSingleThrow(18); - expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( + expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( new RollResult(0, RollResultStatus.FAILURE, [18]), ); }); @@ -107,7 +151,7 @@ describe("DS4 Rolls with one die and crit roll modifications.", () => { it("Should do a crit fail on `minCritFail`.", () => { const rollProvider = mockSingleThrow(19); - expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( + expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [19]), ); }); @@ -115,7 +159,7 @@ describe("DS4 Rolls with one die and crit roll modifications.", () => { it("Should do a crit fail on `20`", () => { const rollProvider = mockSingleThrow(20); - expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( + expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 } as RollOptions, rollProvider)).toEqual( new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [20]), ); }); diff --git a/src/module/rolls/roll-executor.ts b/src/module/rolls/roll-executor.ts index 204f5edc..102be1db 100644 --- a/src/module/rolls/roll-executor.ts +++ b/src/module/rolls/roll-executor.ts @@ -85,6 +85,8 @@ export function rollCheckMultipleDice( export class RollOptions { public maxCritSucc = 1; public minCritFail = 20; + public useSlayingDice = false; + public slayingDiceRepetition = false; } export class RollResult {