Added catch for stats of 0 to prevent errors.

This commit is contained in:
Aaron Lutomski
2026-06-21 13:44:55 -07:00
parent 78e46c66bc
commit efedccc205
6 changed files with 31 additions and 5 deletions
+1
View File
@@ -168,6 +168,7 @@
"DG.Roll.For": "For",
"DG.Roll.Damage": "Damage",
"DG.Roll.Roll": "Roll",
"DG.Roll.CannotRollStat": "A statistic of 0 cannot be rolled.",
"DG.Physical.Wounds": "Wounds",
"DG.Physical.FirstAidLabel": "First Aid Has Already Been Attempted: ",
"DG.Physical.ExhaustionPenalty": "Penalty:",
+15 -1
View File
@@ -255,6 +255,20 @@ export class DGPercentileRoll extends DGRoll {
return { target, localizedKey, skillPath };
}
/**
* i18n key for a user-facing warning when this roll must not be made, or null if allowed.
* @returns {string|null}
*/
get blockedRollMessage() {
if (this.type !== "stat") return null;
const x5 = Number(this.target);
if (!Number.isFinite(x5) || x5 < 1) {
return "DG.Roll.CannotRollStat";
}
return null;
}
/**
* Create label based on result of roll
*
@@ -392,7 +406,7 @@ export class DGPercentileRoll extends DGRoll {
const { rollTargetModifier } = this;
if (!this.target || Number.isNaN(this.target)) {
if (this.target == null || Number.isNaN(this.target)) {
return null;
}
+5
View File
@@ -100,6 +100,11 @@ export async function processDGRoll(event, roll) {
const shiftKey = event?.shiftKey ?? false;
const which = event?.which ?? 0;
if (roll instanceof DGPercentileRoll && roll.blockedRollMessage) {
ui.notifications.warn(roll.blockedRollMessage, { localize: true });
return;
}
if (shiftKey || which === 3) {
if (!(roll instanceof DGSanityDamageRoll)) {
const dialogData = await roll.showDialog();
+7 -1
View File
@@ -36,8 +36,14 @@ export default function RollSheetMixin(Base) {
* @private
*/
static async _onRoll(event, target) {
if (target.classList.contains("not-rollable") || event.which === 2)
if (event.which === 2) return;
if (target.classList.contains("not-rollable")) {
if (target.dataset.rolltype === "stat") {
ui.notifications.warn("DG.Roll.CannotRollStat", { localize: true });
}
return;
}
const item = this.actor.items.get(target.dataset.iid);
const roll = createDGRollFromDataset(target.dataset, {
@@ -7,7 +7,7 @@
<div class="flex-group-center flex-mid-border">
<div>
<div class="physical-stats-outer-grid-3col">
<label class="rollable resource-label"
<label class="{{if_gt statistic.x5 0 'rollable' 'not-rollable'}} resource-label"
data-action="roll"
data-rolltype="stat"
data-key="{{key}}"
@@ -20,7 +20,7 @@
name="system.statistics.{{key}}.value"
value="{{statistic.value}}"
data-dtype="Number" />
<span class="rollable"
<span class="{{if_gt statistic.x5 0 'rollable' 'not-rollable'}}"
data-action="roll"
data-rolltype="stat"
data-key="{{key}}"
+1 -1
View File
@@ -25,7 +25,7 @@
<div class="flex-group-center flex-mid-border">
<div>
<div class="physical-stats-outer-grid-3col agent-left-bar-stat-grid">
<label class="rollable resource-label"
<label class="{{if_gt statistic.x5 0 'rollable' 'not-rollable'}} resource-label"
data-action="roll"
data-rolltype="stat"
data-key="{{key}}"