2021-01-02 16:12:16 +01:00
|
|
|
import { RollOptions } from "./roll-data";
|
|
|
|
|
|
|
|
export function isDiceSwapNecessary(
|
|
|
|
critSuccesses: Array<number>,
|
|
|
|
otherRolls: Array<number>,
|
2021-01-03 15:08:38 +01:00
|
|
|
lastTestValue: number,
|
2021-01-02 16:12:16 +01:00
|
|
|
): boolean {
|
|
|
|
if (critSuccesses.length == 0 || otherRolls.length == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const amountOfOtherRolls = otherRolls.length;
|
|
|
|
const lastDice = otherRolls[amountOfOtherRolls - 1];
|
2021-01-03 15:08:38 +01:00
|
|
|
if (lastDice <= lastTestValue) {
|
2021-01-02 16:12:16 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-03 15:08:38 +01:00
|
|
|
return lastDice + lastTestValue > 20;
|
2021-01-02 16:12:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export function isSlayingDiceRepetition(opts: RollOptions): boolean {
|
|
|
|
return opts.useSlayingDice && opts.slayingDiceRepetition;
|
|
|
|
}
|