23 lines
632 B
TypeScript
23 lines
632 B
TypeScript
|
import { RollOptions } from "./roll-data";
|
||
|
|
||
|
export function isDiceSwapNecessary(
|
||
|
critSuccesses: Array<number>,
|
||
|
otherRolls: Array<number>,
|
||
|
finalRollValue: number,
|
||
|
): boolean {
|
||
|
if (critSuccesses.length == 0 || otherRolls.length == 0) {
|
||
|
return false;
|
||
|
}
|
||
|
const amountOfOtherRolls = otherRolls.length;
|
||
|
const lastDice = otherRolls[amountOfOtherRolls - 1];
|
||
|
if (lastDice <= finalRollValue) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return lastDice + finalRollValue > 20;
|
||
|
}
|
||
|
|
||
|
export function isSlayingDiceRepetition(opts: RollOptions): boolean {
|
||
|
return opts.useSlayingDice && opts.slayingDiceRepetition;
|
||
|
}
|