Added catch for stats of 0 to prevent errors.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user