Additional tests and features as per Request.
This commit is contained in:
parent
bf39f35504
commit
6b18e720a1
3 changed files with 27 additions and 2 deletions
|
@ -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]),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -83,7 +83,8 @@ export function rollCheckMultipleDice(
|
|||
}
|
||||
|
||||
export class RollOptions {
|
||||
constructor(public maxCritSucc: number = 1, public minCritFail: number = 20) {}
|
||||
public maxCritSucc = 1;
|
||||
public minCritFail = 20;
|
||||
}
|
||||
|
||||
export class RollResult {
|
||||
|
|
|
@ -12,5 +12,5 @@ export class DS4RollProvider {
|
|||
|
||||
export interface RollProvider {
|
||||
getNextRoll(): number;
|
||||
getNextRolls(number): Array<number>;
|
||||
getNextRolls(number: number): Array<number>;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue