Fix problem with check target numbers <= 0

The fix has 2 components:
1. The logic for evaluating checks now supports check target numbers<= 0
   by still using a single die in this case
2.  The CheckFactory sets the check target number to 0 even if it would
   be < 0. This is necessary because negative numbers would interfer
   with foundry's math evaluation in rolls and would not be picked up
   correctly.
This commit is contained in:
Johannes Loher 2021-06-26 12:50:55 +02:00
parent ebdc0405d8
commit ff6427f5a9
3 changed files with 118 additions and 14 deletions

View file

@ -113,5 +113,5 @@ function evaluateDiceWithSubChecks(
}
export function getRequiredNumberOfDice(checkTargetNumber: number): number {
return Math.ceil(checkTargetNumber / 20);
return Math.max(Math.ceil(checkTargetNumber / 20), 1);
}

View file

@ -45,8 +45,8 @@ class CheckFactory {
);
}
createCheckTargetNumberModifier(): string | null {
return "v" + (this.checkTargetNumber + this.gmModifier);
createCheckTargetNumberModifier(): string {
return "v" + Math.max(this.checkTargetNumber + this.gmModifier, 0);
}
createCoupFumbleModifier(): string | null {