import { rollCheckSingleDie, RollOptions, RollResult, RollResultStatus } from "../../src/module/rolls/roll-executor"; import { RollProvider } from "../../src/module/rolls/roll-provider"; describe("DS4 Rolls", () => { it("Should do a proper single success roll.", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(4); expect(rollCheckSingleDie(12, new RollOptions(), rollProvider)).toEqual( new RollResult(4, RollResultStatus.SUCCESS, [4]), ); }); it("Should do a proper single success roll on success edge case.", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(4); expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual( new RollResult(4, RollResultStatus.SUCCESS, [4]), ); }); it("Should do a proper single failure roll, lower bound", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(5); expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual( new RollResult(0, RollResultStatus.FAILURE, [5]), ); }); it("Should do a proper single failure roll, upper bound", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(19); expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual( new RollResult(0, RollResultStatus.FAILURE, [19]), ); }); it("Should do a proper single crit success roll.", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(1); expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual( new RollResult(4, RollResultStatus.CRITICAL_SUCCESS, [1]), ); }); it("Should do a proper single crit failure roll.", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(20); expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual( new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [20]), ); }); it("Should do a proper crit success with changed bounds, lower bound", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(1); expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( new RollResult(4, RollResultStatus.CRITICAL_SUCCESS, [1]), ); }); it("Should do a proper crit success with changed bounds, upper bound", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(2); expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( new RollResult(4, RollResultStatus.CRITICAL_SUCCESS, [2]), ); }); it("Should do a proper success with changed bounds, lower bound", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(3); expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( new RollResult(3, RollResultStatus.SUCCESS, [3]), ); }); it("Should do a proper success with changed bounds, lower bound", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(18); expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( new RollResult(0, RollResultStatus.FAILURE, [18]), ); }); it("Should do a proper crit fail with changed bounds, lower bound", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(19); expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [19]), ); }); it("Should do a proper crit fail with changed bounds, upper bound", () => { const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(20); expect(rollCheckSingleDie(4, { maxCritSucc: 2, minCritFail: 19 }, rollProvider)).toEqual( new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [20]), ); }); });