Changes as per review.

Missing:
 - Open discussion on "test value" renames
 - docs
 - open discussion on last-die-handling
This commit is contained in:
Oliver Rümpelein 2021-01-03 15:08:38 +01:00
parent f98da0cd99
commit c26e4bab9f
2 changed files with 20 additions and 4 deletions

View file

@ -3,18 +3,18 @@ import { RollOptions } from "./roll-data";
export function isDiceSwapNecessary(
critSuccesses: Array<number>,
otherRolls: Array<number>,
finalRollValue: number,
lastTestValue: number,
): boolean {
if (critSuccesses.length == 0 || otherRolls.length == 0) {
return false;
}
const amountOfOtherRolls = otherRolls.length;
const lastDice = otherRolls[amountOfOtherRolls - 1];
if (lastDice <= finalRollValue) {
if (lastDice <= lastTestValue) {
return false;
}
return lastDice + finalRollValue > 20;
return lastDice + lastTestValue > 20;
}
export function isSlayingDiceRepetition(opts: RollOptions): boolean {