diff --git a/ChangeLog.md b/ChangeLog.md index ac5960e..33a9345 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,6 @@ +# v3.13.1 +* PF2e/Dnd4e: Localize the chat scraping functions + # v3.13.0 * PF2e: Update chat parsing to match changed text in hide and seek actions * PF2e: Add an error notification if PF2e Workbench is missing diff --git a/scripts/systems/dnd4e.js b/scripts/systems/dnd4e.js index 2107ebb..b45a6df 100644 --- a/scripts/systems/dnd4e.js +++ b/scripts/systems/dnd4e.js @@ -1,20 +1,20 @@ import { Stealthy } from '../stealthy.js'; import Engine from '../engine.js'; -// This mechanically works, but I don't know how one is supposed to get rid -// of the Hidden effect once it is placed given the PF1 UI doesn't seem to show -// active effects. - class Engine4e extends Engine { constructor() { super(); + const usesStealth = `uses ${game.i18n.localize('DND4EBETA.SkillStl')}.` + const usesPerception = `uses ${game.i18n.localize('DND4EBETA.SkillPrc')}.` + Stealthy.log('Localized Chat Tags', { usesStealth, usesPerception }); + Hooks.on('createChatMessage', async (message, options, id) => { - if (message.flavor.endsWith('uses Stealth.')) { + if (message.flavor.endsWith(usesStealth)) { await this.rollStealth(message, options, id); } - else if (message.flavor.endsWith('uses Perception.')) { + else if (message.flavor.endsWith(usesPerception)) { await this.rollPerception(message, options, id); } }); diff --git a/scripts/systems/pf2e.js b/scripts/systems/pf2e.js index e4de658..6c231f7 100644 --- a/scripts/systems/pf2e.js +++ b/scripts/systems/pf2e.js @@ -9,7 +9,6 @@ export class EnginePF2e extends Engine { super(); const workbench = game.modules.get('xdy-pf2e-workbench')?.active; - Stealthy.log('workbench', workbench); if (!workbench) { Hooks.once('ready', async () => { ui.notifications.error(`${game.i18n.localize('stealthy.pf2e.dependency')}`); @@ -17,12 +16,22 @@ export class EnginePF2e extends Engine { } // There is probably a better practice for figuring out skill checks in PF2E, but this "works" + const stealthTags = [ + `>${game.i18n.localize('xdy-pf2e-workbench.macros.basicActionMacros.actions.Hide')} - ${game.i18n.localize('PF2E.StealthLabel')} ${game.i18n.localize('PF2E.Check.Label')}<`, + `>${game.i18n.format("PF2E.InitiativeWithSkill", { skillName: game.i18n.localize('PF2E.StealthLabel') }) }<`, + ]; + const perceptionTags = [ + `>${game.i18n.localize('xdy-pf2e-workbench.macros.basicActionMacros.actions.Seek')} - ${game.i18n.localize('PF2E.PerceptionCheck')}<`, + `>${game.i18n.format("PF2E.InitiativeWithSkill", { skillName: game.i18n.localize('PF2E.PerceptionLabel') })}<`, + ]; + Stealthy.log('Localized Chat Tags', { stealthTags, perceptionTags }); + Hooks.on('createChatMessage', async (message, options, id) => { // Stealthy.log("createChatMessage", message); - if (['>Initiative: Stealth<', '>(Stealth Check)<', 'Hide - Stealth Check'].some(t => message.flavor.includes(t))) { + if (stealthTags.some(t => message.flavor.includes(t))) { await this.rollStealth(message, options, id); } - else if (['>(Perception Check)<', 'Seek - Perception Check', '>Initiative: Perception<'].some(t => message.flavor.includes(t))) { + else if (perceptionTags.some(t => message.flavor.includes(t))) { await this.rollPerception(message, options, id); } }); @@ -40,7 +49,7 @@ export class EnginePF2e extends Engine { const stealth = hiddenEffect?.flags?.stealthy?.hidden ?? (10 + target.actor.system.skills.ste.value); const source = visionSource.object?.actor; let seeking = this.findSpotEffect(source); - const perception = seeking?.flags?.stealthy?.spot ?? 10 + source.system.attributes.perception.value; + const perception = seeking?.flags?.stealthy?.spot ?? 10 + source.system.attributes.perception?.value; if (perception < stealth) { Stealthy.log(`${visionSource.object.name}'s ${perception} can't see ${target.name}'s ${stealth}`); @@ -134,7 +143,7 @@ export class EnginePF2e extends Engine { } getSpotFlagAndValue(actor, effect) { - const value = effect?.flags.stealthy.spot ?? (10 + actor.system.attributes.perception.value); + const value = effect?.flags.stealthy.spot ?? (10 + actor.system.attributes.perception?.value); return { flag: { spot: value }, value }; }