Fix option parsing for rolls.

This commit is contained in:
Oliver Rümpelein 2021-01-02 13:54:59 +01:00
parent 75301b2c56
commit 00f7e30b41
2 changed files with 38 additions and 30 deletions

View file

@ -25,39 +25,31 @@ describe("DS4 Rolls with one die and no modifications.", () => {
it("Should do a regular success roll.", () => {
const rollProvider = mockSingleThrow(4);
expect(rollCheckSingleDie(12, new RollOptions(), rollProvider)).toEqual(
new RollResult(4, RollResultStatus.SUCCESS, [4]),
);
expect(rollCheckSingleDie(12, {}, rollProvider)).toEqual(new RollResult(4, RollResultStatus.SUCCESS, [4]));
});
it("Should do a single success roll on success upper edge case.", () => {
const rollProvider = mockSingleThrow(4);
expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual(
new RollResult(4, RollResultStatus.SUCCESS, [4]),
);
expect(rollCheckSingleDie(4, {}, rollProvider)).toEqual(new RollResult(4, RollResultStatus.SUCCESS, [4]));
});
it("Should do a single failure roll on lower edge case.", () => {
const rollProvider = mockSingleThrow(5);
expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual(
new RollResult(0, RollResultStatus.FAILURE, [5]),
);
expect(rollCheckSingleDie(4, {}, rollProvider)).toEqual(new RollResult(0, RollResultStatus.FAILURE, [5]));
});
it("Should do a single failure roll on upper edge case '19'.", () => {
const rollProvider = mockSingleThrow(19);
expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual(
new RollResult(0, RollResultStatus.FAILURE, [19]),
);
expect(rollCheckSingleDie(4, {}, rollProvider)).toEqual(new RollResult(0, RollResultStatus.FAILURE, [19]));
});
it("Should do a single crit success roll on '1'.", () => {
const rollProvider = mockSingleThrow(1);
expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual(
expect(rollCheckSingleDie(4, {}, rollProvider)).toEqual(
new RollResult(4, RollResultStatus.CRITICAL_SUCCESS, [1]),
);
});
@ -65,7 +57,7 @@ describe("DS4 Rolls with one die and no modifications.", () => {
it("Should do a single crit failure roll on '20'.", () => {
const rollProvider = mockSingleThrow(20);
expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual(
expect(rollCheckSingleDie(4, {}, rollProvider)).toEqual(
new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [20]),
);
});
@ -169,15 +161,15 @@ describe("DS4 Rools with multiple dice and no modifiers.", () => {
it("Should do a crit fail on `20` for first roll.", () => {
const rollProvider = mockMultipleThrows([20, 15, 6]);
expect(rollCheckMultipleDice(48, new RollOptions(), rollProvider)).toEqual(
expect(rollCheckMultipleDice(48, {}, rollProvider)).toEqual(
new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [20, 15, 6]),
);
});
it("Should succeed with all rolls crit successes.", () => {
it("Should succeed normally with all rolls crit successes.", () => {
const rollProvider = mockMultipleThrows([1, 1, 1]);
expect(rollCheckMultipleDice(48, new RollOptions(), rollProvider)).toEqual(
expect(rollCheckMultipleDice(48, {}, rollProvider)).toEqual(
new RollResult(48, RollResultStatus.SUCCESS, [1, 1, 1]),
);
});
@ -185,7 +177,7 @@ describe("DS4 Rools with multiple dice and no modifiers.", () => {
it("Should succeed with the last roll not being suficient.", () => {
const rollProvider = mockMultipleThrows([15, 15, 15]);
expect(rollCheckMultipleDice(48, new RollOptions(), rollProvider)).toEqual(
expect(rollCheckMultipleDice(48, {}, rollProvider)).toEqual(
new RollResult(30, RollResultStatus.SUCCESS, [15, 15, 15]),
);
});
@ -193,7 +185,7 @@ describe("DS4 Rools with multiple dice and no modifiers.", () => {
it("Should succeed with the last roll a crit success.", () => {
const rollProvider = mockMultipleThrows([15, 15, 1]);
expect(rollCheckMultipleDice(48, new RollOptions(), rollProvider)).toEqual(
expect(rollCheckMultipleDice(48, {}, rollProvider)).toEqual(
new RollResult(35, RollResultStatus.SUCCESS, [1, 15, 15]),
);
});
@ -201,7 +193,7 @@ describe("DS4 Rools with multiple dice and no modifiers.", () => {
it("Should succeed with the last roll being 20 and one crit success.", () => {
const rollProvider = mockMultipleThrows([15, 1, 20]);
expect(rollCheckMultipleDice(48, new RollOptions(), rollProvider)).toEqual(
expect(rollCheckMultipleDice(48, {}, rollProvider)).toEqual(
new RollResult(40, RollResultStatus.SUCCESS, [1, 20, 15]),
);
});