Add test for multiple rolls with min/max modifiers
This commit is contained in:
parent
c315742412
commit
b569e5488e
2 changed files with 62 additions and 6 deletions
|
@ -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]),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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<number> = critSuccesses.concat(otherRolls);
|
||||
|
||||
const evaluationResult = sortedRollResults
|
||||
|
|
Loading…
Reference in a new issue