Fix issue with CheckFactory parsing empty strings as NaN for check related values
This commit is contained in:
parent
ff6427f5a9
commit
1f6d13c49d
1 changed files with 16 additions and 7 deletions
|
@ -46,7 +46,8 @@ class CheckFactory {
|
|||
}
|
||||
|
||||
createCheckTargetNumberModifier(): string {
|
||||
return "v" + Math.max(this.checkTargetNumber + this.gmModifier, 0);
|
||||
const totalCheckTargetNumber = Math.max(this.checkTargetNumber + this.gmModifier, 0);
|
||||
return `v${totalCheckTargetNumber}`;
|
||||
}
|
||||
|
||||
createCoupFumbleModifier(): string | null {
|
||||
|
@ -55,7 +56,7 @@ class CheckFactory {
|
|||
const isMaximumCoupResultRequired = this.options.maximumCoupResult !== defaultCheckOptions.maximumCoupResult;
|
||||
|
||||
if (isMinimumFumbleResultRequired || isMaximumCoupResultRequired) {
|
||||
return "c" + (this.options.maximumCoupResult ?? "") + ":" + (this.options.minimumFumbleResult ?? "");
|
||||
return `c${this.options.maximumCoupResult ?? ""}:${this.options.minimumFumbleResult ?? ""}`;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -162,12 +163,20 @@ async function askGmModifier(
|
|||
* @param formData - The filed dialog
|
||||
*/
|
||||
function parseDialogFormData(formData: HTMLFormElement): Partial<IntermediateGmModifierData> {
|
||||
const chosenCheckTargetNumber = parseInt(formData["check-target-number"]?.value);
|
||||
const chosenGMModifier = parseInt(formData["gm-modifier"]?.value);
|
||||
const chosenMaximumCoupResult = parseInt(formData["maximum-coup-result"]?.value);
|
||||
const chosenMinimumFumbleResult = parseInt(formData["minimum-fumble-result"]?.value);
|
||||
const chosenRollMode = formData["roll-mode"]?.value;
|
||||
|
||||
const invalidNumbers = [NaN, Infinity, -Infinity];
|
||||
|
||||
return {
|
||||
checkTargetNumber: parseInt(formData["check-target-number"]?.value),
|
||||
gmModifier: parseInt(formData["gm-modifier"]?.value),
|
||||
maximumCoupResult: parseInt(formData["maximum-coup-result"]?.value),
|
||||
minimumFumbleResult: parseInt(formData["minimum-fumble-result"]?.value),
|
||||
rollMode: formData["roll-mode"]?.value,
|
||||
checkTargetNumber: invalidNumbers.includes(chosenCheckTargetNumber) ? undefined : chosenCheckTargetNumber,
|
||||
gmModifier: invalidNumbers.includes(chosenGMModifier) ? undefined : chosenGMModifier,
|
||||
maximumCoupResult: invalidNumbers.includes(chosenMaximumCoupResult) ? undefined : chosenMaximumCoupResult,
|
||||
minimumFumbleResult: invalidNumbers.includes(chosenMinimumFumbleResult) ? undefined : chosenMinimumFumbleResult,
|
||||
rollMode: Object.values(CONST.DICE_ROLL_MODES).includes(chosenRollMode) ? chosenRollMode : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue