Additional tests and features as per Request.

This commit is contained in:
Oliver Rümpelein 2020-12-31 02:27:21 +01:00
parent bf39f35504
commit 6b18e720a1
3 changed files with 27 additions and 2 deletions

View file

@ -244,3 +244,27 @@ describe("DS4 Rools with multiple dice and min/max modifiers.", () => {
); );
}); });
}); });
describe("DS4 Rools with multiple dice and fail 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, { minCritFail: 19 } as RollOptions, rollProvider)).toEqual(
new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [19, 15, 6]),
);
});
});
describe("DS4 Rools with multiple dice and success modifiers.", () => {
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 } as RollOptions, rollProvider)).toEqual(
new RollResult(48, RollResultStatus.SUCCESS, [2, 2, 1]),
);
});
});

View file

@ -83,7 +83,8 @@ export function rollCheckMultipleDice(
} }
export class RollOptions { export class RollOptions {
constructor(public maxCritSucc: number = 1, public minCritFail: number = 20) {} public maxCritSucc = 1;
public minCritFail = 20;
} }
export class RollResult { export class RollResult {

View file

@ -12,5 +12,5 @@ export class DS4RollProvider {
export interface RollProvider { export interface RollProvider {
getNextRoll(): number; getNextRoll(): number;
getNextRolls(number): Array<number>; getNextRolls(number: number): Array<number>;
} }