Error checking for the fate type parsing in all potential problem locations

This commit is contained in:
Chris Ryan 2025-12-10 22:09:28 +10:00
parent 9ce5c27c85
commit 3e366a4c44
2 changed files with 35 additions and 7 deletions

View file

@ -10,7 +10,7 @@ import { enricherConfig, enricherRenderSetup } from './module/enrichers/_module.
import { getCommandTarget, rollCommandToJSON } from './module/helpers/utils.mjs';
import { BaseRoll, DHRoll, DualityRoll, D20Roll, DamageRoll, FateRoll } from './module/dice/_module.mjs';
import { enrichedDualityRoll } from './module/enrichers/DualityRollEnricher.mjs';
import { enrichedFateRoll } from './module/enrichers/FateRollEnricher.mjs';
import { enrichedFateRoll, getFateType } from './module/enrichers/FateRollEnricher.mjs';
import {
handlebarsRegistration,
runMigrations,
@ -259,12 +259,10 @@ Hooks.on('chatMessage', (_, message) => {
const { result: rollCommand, flavor } = result;
const fateTypeFromRollCommand = rollCommand?.type ?
(rollCommand?.type?.toLowerCase() == "fear" ? "Fear" :
(rollCommand?.type?.toLowerCase() == "hope" ? "Hope" : "BAD")) : "Hope";
const fateTypeFromRollCommand = getFateType(rollCommand?.type);
if (fateTypeFromRollCommand == "BAD") {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateParsing'));
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateParsing') + ". Bad Fate Type. Valid Fate Types are 'Hope' and 'Fear'.");
return false;
}