diff --git a/ChangeLog.md b/ChangeLog.md index 9fbd9b7..ab30c7f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,6 @@ +# v4.10 +* Add an opt-out setting to clear Stealthy's stealth/perception flags from combatants at combat end. + # v4.9.1 * Apply alias to Hidden, not Spot (whoops!!) * When testing for hidden/spot effects, first check for Stealthy's flags before resorting to names. diff --git a/languages/en.json b/languages/en.json index b168674..c5e7a4a 100644 --- a/languages/en.json +++ b/languages/en.json @@ -50,6 +50,10 @@ "name": "Global Illumination dim light threshold", "hint": "On scenes with GI enabled, bright light exposure is assumed unless the darkness level exceeds the scene's GI threshold multiplied by this factor, yielding dim light. Use 1.0 to transition directly from bright to dark." }, + "clearAfterCombat": { + "name": "Clear stealth effects after combat", + "hint": "Removes Stealthy's spot/hidden effects from only the combatants" + }, "stealthToActor": { "name": "Bank stealth rolls to actor", "hint": "Bank stealth rolls in an actor effect/item rather than the token." diff --git a/languages/fr.json b/languages/fr.json index e46a1f2..83b37dc 100644 --- a/languages/fr.json +++ b/languages/fr.json @@ -50,6 +50,10 @@ "name": "Global Illumination dim light threshold", "hint": "On scenes with GI enabled, bright light exposure is assumed unless the darkness level exceeds the scene's GI threshold multiplied by this factor, yielding dim light. Use 1.0 to transition directly from bright to dark." }, + "clearAfterCombat": { + "name": "Clear stealth effects after combat", + "hint": "Removes Stealthy's spot/hidden effects from only the combatants" + }, "stealthToActor": { "name": "Bank stealth rolls to actor", "hint": "Bank stealth rolls in an actor effect/item rather than the token." diff --git a/languages/pt-BR.json b/languages/pt-BR.json index 4b68571..7009e4c 100644 --- a/languages/pt-BR.json +++ b/languages/pt-BR.json @@ -50,6 +50,10 @@ "name": "Limite de Iluminação Global de Penumbra", "hint": "Em cenas com Iluminação Global ativada, se assume a exposição à luz plena, a menos que o nível de escuridão exceda o limite de Iluminação Global da cena, multiplicado por este fator, produzindo penumbra. Use 1.0 para fazer a transição direta do claro para escuro." }, + "clearAfterCombat": { + "name": "Clear stealth effects after combat", + "hint": "Removes Stealthy's spot/hidden effects from only the combatants" + }, "stealthToActor": { "name": "Acumular Furtividade no Ator", "hint": "Acumula as rolagens de Furtividade no efeito/item de um ator, ao invés do próprio ator." @@ -150,4 +154,4 @@ "dependency": "Stealthy requer as ações Hide and Seek das macros de ação básicas no PF2e Workbench" } } -} +} \ No newline at end of file diff --git a/languages/ru.json b/languages/ru.json index 0f09d54..2bd3c4c 100644 --- a/languages/ru.json +++ b/languages/ru.json @@ -49,6 +49,10 @@ "name": "Порог яркости глобального освещения (GI)", "hint": "В сценах с включенным GI предполагается яркое освещение, пока уровень темноты не превысит порог GI сцены, умноженный на этот коэффициент, что приведет к тусклому освещению. Используйте 1,0 для прямого перехода от яркого света к темноте." }, + "clearAfterCombat": { + "name": "Clear stealth effects after combat", + "hint": "Removes Stealthy's spot/hidden effects from only the combatants" + }, "stealthToActor": { "name": "Сохранять Стелс бросок в актере", "hint": "Сохранять бросок в актере вместо токена." diff --git a/scripts/engine.js b/scripts/engine.js index ac49631..c316f3b 100644 --- a/scripts/engine.js +++ b/scripts/engine.js @@ -31,6 +31,13 @@ function versionAtLeast(version, target) { return true; } +function interpolateString(str, interpolations) { + return str.replace( + /\{([A-Za-z0-9_]+)\}/g, + (match, key) => interpolations.hasOwnProperty(key) ? interpolations[key] : match + ); +} + export default class Engine { constructor() { @@ -92,6 +99,7 @@ export default class Engine { game.settings.register(Stealthy.MODULE_ID, 'gIDimThreshold', settings.gIDimThreshold); game.settings.register(Stealthy.MODULE_ID, 'spotSecretDoors', settings.spotSecretDoors); game.settings.register(Stealthy.MODULE_ID, 'hiddenAliases', settings.hiddenAliases); + game.settings.register(Stealthy.MODULE_ID, 'clearAfterCombat', settings.clearAfterCombat); game.settings.register(Stealthy.MODULE_ID, 'stealthToActor', settings.stealthToActor); game.settings.register(Stealthy.MODULE_ID, 'perceptionToActor', settings.perceptionToActor); @@ -304,6 +312,15 @@ export default class Engine { type: String, default: 'Hidden;Caché;Escondido;Стелс' }, + clearAfterCombat: { + name: "stealthy.clearAfterCombat.name", + hint: "stealthy.clearAfterCombat.hint", + scope: 'world', + config: true, + type: Boolean, + default: true, + }, + hiddenSource: { name: "stealthy.hidden.source", hint: "stealthy.source.hint", @@ -554,6 +571,67 @@ export default class Engine { await this.updateOrCreatePerceptionEffect(token.actor, { perception: value }); } + async createClearMessage(token, skill, value) { + const text = interpolateString( + game.i18n.localize(`${Stealthy.MODULE_ID}.clearAfterCombat.${skill}`), + { name: token.name } + ); + const tooltip = game.i18n.localize(`${Stealthy.MODULE_ID}.clearAfterCombat.restoreBank`); + const content = ` +