Changes as per review.
Missing: - Open discussion on "test value" renames - docs - open discussion on last-die-handling
This commit is contained in:
parent
f98da0cd99
commit
c26e4bab9f
2 changed files with 20 additions and 4 deletions
|
@ -232,6 +232,14 @@ describe("DS4 Rolls with multiple dice and no modifiers.", () => {
|
||||||
new RollResult(37, RollResultStatus.SUCCESS, [19, 1]),
|
new RollResult(37, RollResultStatus.SUCCESS, [19, 1]),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Should maximize correctly when swapping with more than one crit success", () => {
|
||||||
|
const rollProvider = mockMultipleThrows([1, 1, 15]);
|
||||||
|
|
||||||
|
expect(rollCheckMultipleDice(48, {}, rollProvider)).toEqual(
|
||||||
|
new RollResult(43, RollResultStatus.SUCCESS, [1, 15, 1]),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("DS4 Rolls with multiple dice and min/max modifiers.", () => {
|
describe("DS4 Rolls with multiple dice and min/max modifiers.", () => {
|
||||||
|
@ -308,10 +316,18 @@ describe("DS4 Rolls with multiple and slaying dice, first throw", () => {
|
||||||
it("Should fail with the first roll being a `20`", () => {
|
it("Should fail with the first roll being a `20`", () => {
|
||||||
const rollProvider = mockMultipleThrows([20, 2, 19]);
|
const rollProvider = mockMultipleThrows([20, 2, 19]);
|
||||||
|
|
||||||
expect(rollCheckMultipleDice(48, {}, rollProvider)).toEqual(
|
expect(rollCheckMultipleDice(48, { useSlayingDice: true }, rollProvider)).toEqual(
|
||||||
new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [20, 2, 19]),
|
new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [20, 2, 19]),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Should issue a critical success, even with resorting dice", () => {
|
||||||
|
const rollProvider = mockMultipleThrows([2, 19, 15]);
|
||||||
|
|
||||||
|
expect(rollCheckMultipleDice(48, { useSlayingDice: true, maxCritSucc: 2 }, rollProvider)).toEqual(
|
||||||
|
new RollResult(42, RollResultStatus.CRITICAL_SUCCESS, [19, 15, 2]),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("DS4 Rolls with multiple and slaying dice, recurrent throw", () => {
|
describe("DS4 Rolls with multiple and slaying dice, recurrent throw", () => {
|
||||||
|
|
|
@ -3,18 +3,18 @@ import { RollOptions } from "./roll-data";
|
||||||
export function isDiceSwapNecessary(
|
export function isDiceSwapNecessary(
|
||||||
critSuccesses: Array<number>,
|
critSuccesses: Array<number>,
|
||||||
otherRolls: Array<number>,
|
otherRolls: Array<number>,
|
||||||
finalRollValue: number,
|
lastTestValue: number,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (critSuccesses.length == 0 || otherRolls.length == 0) {
|
if (critSuccesses.length == 0 || otherRolls.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const amountOfOtherRolls = otherRolls.length;
|
const amountOfOtherRolls = otherRolls.length;
|
||||||
const lastDice = otherRolls[amountOfOtherRolls - 1];
|
const lastDice = otherRolls[amountOfOtherRolls - 1];
|
||||||
if (lastDice <= finalRollValue) {
|
if (lastDice <= lastTestValue) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return lastDice + finalRollValue > 20;
|
return lastDice + lastTestValue > 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isSlayingDiceRepetition(opts: RollOptions): boolean {
|
export function isSlayingDiceRepetition(opts: RollOptions): boolean {
|
||||||
|
|
Loading…
Reference in a new issue