From 1840460a785553d01aaf0c6640d49db69bb6aa5c Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Thu, 7 Nov 2024 00:48:23 -0800 Subject: [PATCH] Provide a subtitle with actions when using lores Current it will show a subtitle like "Lie (PF2E.ActionsCheck.legal-lore)" when trying to use a skill that doesn't have a translation, which no lore will. Detect the lack of translation and fall back to the "PF2E.ActionsCheck.x" translation format using the label of the skill. This will result in "Lie (Legal Lore Check)" if the skill was labeled in that way. --- src/module/system/action-macros/basic/escape.ts | 2 +- src/module/system/action-macros/helpers.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/module/system/action-macros/basic/escape.ts b/src/module/system/action-macros/basic/escape.ts index c5c97e13141..6a6b7ca18e1 100644 --- a/src/module/system/action-macros/basic/escape.ts +++ b/src/module/system/action-macros/basic/escape.ts @@ -86,7 +86,7 @@ function escapeCheckContext>( ); if (highest) { - const { checkType, stat: slug, subtitle } = ActionMacroHelpers.resolveStat(highest.statistic.slug); + const { checkType, stat: slug, subtitle } = ActionMacroHelpers.resolveStat(highest.statistic.slug, opts.actor); return { modifiers: data.modifiers, rollOptions: highest.rollOptions, diff --git a/src/module/system/action-macros/helpers.ts b/src/module/system/action-macros/helpers.ts index ce711cec7eb..e27ec1882be 100644 --- a/src/module/system/action-macros/helpers.ts +++ b/src/module/system/action-macros/helpers.ts @@ -30,7 +30,10 @@ import type { } from "./types.ts"; class ActionMacroHelpers { - static resolveStat(stat: string): { + static resolveStat( + stat: string, + actor: ActorPF2e, + ): { checkType: CheckType; property: string; stat: string; @@ -54,11 +57,14 @@ class ActionMacroHelpers { default: { const slug = sluggify(stat); const property = `skills.${slug}`; + const subtitle = `PF2E.ActionsCheck.${stat}`; return { checkType: "skill-check", property, stat, - subtitle: `PF2E.ActionsCheck.${stat}`, + subtitle: game.i18n.has(subtitle) + ? subtitle + : game.i18n.format("PF2E.ActionsCheck.x", { type: actor.skills?.[stat]?.label ?? null }), }; } } @@ -68,7 +74,7 @@ class ActionMacroHelpers { options: CheckContextOptions, data: CheckContextData, ): CheckMacroContext | undefined { - const { checkType: type, property, stat: slug, subtitle } = this.resolveStat(data.slug); + const { checkType: type, property, stat: slug, subtitle } = this.resolveStat(data.slug, options.actor); const statistic = options.actor.getStatistic(data.slug) ?? (fu.getProperty(options.actor, property) as StrikeData); if (!statistic) {