From 6dc0171070eaded71cd69fccd677d82b18f91039 Mon Sep 17 00:00:00 2001 From: Themis Date: Sat, 16 Mar 2024 01:31:16 +0200 Subject: [PATCH] 41 add lang file (#47) * Create en.json * Armor proficiency and stealth tooltip fixes * Update ac5e-hooks.mjs (#46) - Add forgotten `frightened` condition. --- lang/en.json | 11 ++++++++ module.json | 23 ++++++++++++---- scripts/ac5e-hooks.mjs | 56 ++++++++++++--------------------------- scripts/ac5e-settings.mjs | 16 +++++------ 4 files changed, 54 insertions(+), 52 deletions(-) create mode 100644 lang/en.json diff --git a/lang/en.json b/lang/en.json new file mode 100644 index 0000000..c8cb85f --- /dev/null +++ b/lang/en.json @@ -0,0 +1,11 @@ +{ + "AC5E.ShowDialogTooltipsName": "AC5e tooltips on Roll Dialogs.", + "AC5E.ShowDialogTooltipsHint": "When checked, AC5e will show a helpful tooltip when hovering over the suggested Roll button, summing up the reasons for that suggestion.", + "AC5E.AutoArmorName": "AC5e armor automation.", + "AC5E.AutoArmorHint": "When checked, AC5e will automatically process proficiency in the equipped piece of armor for ability, skills and save rolls (STR || DEX) and stealth disadvantage property.", + "AC5E.AutoRangedAttacksName": "AC5e ranged attacks automation.", + "AC5E.AutoRangedAttacksHint": "When checked, AC5e will automatically process distance disadvantage/fail based on target distance and range values of item used to attack.", + "AC5E.AutoExhaustionName": "AC5e exhaustion automation.", + "AC5E.AutoExhaustionHint": "When checked, AC5e will automatically process the normal 5e Exhaustion condition rules. Disable if you want compatibility with other exhaustion modules or your own rules (dnd-1 rules will be added in a future update).", + "AC5E.MultipleTargetsAttackWarn": "Automated Conditions 5e: You are attacking multiple targets and that is not supported. The Roll results can be skewed." +} diff --git a/module.json b/module.json index d6a8926..a6391b3 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "id": "automated-conditions-5e", "title": "Automated Conditions 5e", "description": "A small module for Foundry VTT that tries to automate some rolling aspects of the common 5e Conditions.", - "version": "11.315.304.5.4", + "version": "11.315.304.6", "authors": [ { "name": "thatlonelybugbear", @@ -13,8 +13,8 @@ ], "compatibility": { "minimum": "11", - "maximum": "11", - "verified": "11" + "maximum": "11.999", + "verified": "11.315" }, "esmodules": ["scripts/ac5e-main.mjs"], "relationships": { @@ -29,11 +29,24 @@ } ] }, + "languages": [ + { + "lang": "en", + "name": "English", + "path": "lang/en.json", + "flags": {} + } + ], + "flags": { + "hotReload": { + "paths": ["lang/en.json"] + } + }, "bugs": "https://github.com/thatlonelybugbear/automated-conditions-5e/issues", "flags": { "allowBugReporter": true }, "url": "https://github.com/thatlonelybugbear/automated-conditions-5e", "license": "https://raw.githubusercontent.com/thatlonelybugbear/automated-conditions-5e/main/LICENSE", - "manifest": "https://github.com/thatlonelybugbear/automated-conditions-5e/latest/download/module.json", - "download": "https://github.com/thatlonelybugbear/automated-conditions-5e/releases/download/v11.315.304.5.4/module.zip", + "manifest": "https://github.com/thatlonelybugbear/automated-conditions-5e/releases/latest/download/module.json", + "download": "https://github.com/thatlonelybugbear/automated-conditions-5e/releases/download/v11.315.304.6/module.zip", "changelog": "https://raw.githubusercontent.com/thatlonelybugbear/automated-conditions-5e/main/Changelog.md" } diff --git a/scripts/ac5e-hooks.mjs b/scripts/ac5e-hooks.mjs index 3362e75..21af1a7 100644 --- a/scripts/ac5e-hooks.mjs +++ b/scripts/ac5e-hooks.mjs @@ -14,8 +14,8 @@ const settings = new Settings(); const getConfig = (config) => { return { - advantage: config.advantage ? ['default'] : false, - disadvantage: config.disadvantage ? ['default'] : false, + advantage: config.advantage ? ['default'] : [], + disadvantage: config.disadvantage ? ['default'] : [], fail: false, critical: config.critical ? typeof config.critical === 'number' @@ -38,9 +38,7 @@ export function _preRollAbilitySave(actor, config, abilityId) { let statuses = settings.autoExhaustion ? ['exhaustion3'] : []; if (abilityId === 'dex') statuses.push('restrained'); if (!!_hasStatuses(actor, statuses)) { - ac5eConfig.disadvantage = ac5eConfig.disadvantage?.length - ? ac5eConfig.disadvantage.concat(_hasStatuses(actor, statuses)) - : _hasStatuses(actor, statuses); + ac5eConfig.disadvantage = [...ac5eConfig.disadvantage, ..._hasStatuses(actor, statuses)]; change = true; } //Paralysed, Petrified, Stunned, Unconscious conditions, fail the save @@ -63,9 +61,7 @@ export function _preRollAbilitySave(actor, config, abilityId) { ['dex', 'str'].includes(abilityId) && _autoArmor(actor, 'prof') ) { - ac5eConfig.disadvantage = ac5eConfig.disadvantage?.length - ? ac5eConfig.disadvantage.concat(_i18n5e(TraitArmorProf)) - : [_i18n5e(TraitArmorProf)]; + ac5eConfig.disadvantage = [...ac5eConfig.disadvantage, `${_i18n5e('Armor')} (${_i18n5e('NotProficient')})`]; change = true; } if (change) @@ -89,28 +85,18 @@ export function _preRollSkill(actor, config, skillId) { ? ['exhaustion', 'frightened', 'poisoned'] : ['frightened', 'poisoned']; if (_hasStatuses(actor, statuses).length) { - ac5eConfig.disadvantage = ac5eConfig.disadvantage?.length - ? ac5eConfig.disadvantage.concat(_hasStatuses(actor, statuses)) - : _hasStatuses(actor, statuses); + ac5eConfig.disadvantage = [...ac5eConfig.disadvantage, ..._hasStatuses(actor, statuses)]; change = true; } //check Auto Armor if (settings.autoArmor) { const { defaultAbility } = config.data; - if (['dex', 'str'].includes(defaultAbility) && _autoArmor(actor, 'prof')) { - ac5eConfig.disadvantage = ac5eConfig.disadvantage?.length - ? ac5eConfig.disadvantage.concat( - `${_i18n5e('TraitArmorProf')} (${defaultAbility})` - ) - : [`${_i18n5e('TraitArmorProf')} (${defaultAbility})`]; + if (['dex', 'str'].includes(defaultAbility) && !_autoArmor(actor, 'prof')) { + ac5eConfig.disadvantage = [...ac5eConfig.disadvantage ,`${_i18n5e('Armor')} (${_i18n5e('NotProficient')})`]; change = true; } if (skillId === 'ste' && _autoArmor(actor, 'stealth')) { - ac5eConfig.disadvantage = ac5eConfig.disadvantage?.length - ? ac5eConfig.disadvantage.concat( - `${_i18n5e('NotProficient')} (${_i18n5e('Armor')})` - ) - : [`${_i18n5e('Armor')} (${_i18n5e('NotProficient')})`]; + ac5eConfig.disadvantage = [...ac5eConfig.disadvantage, `${_i18n5e('Armor')} (${_i18n5e('ItemEquipmentStealthDisav')})`]; change = true; } } @@ -134,20 +120,16 @@ export function _preRollAbilityTest(actor, config, abilityId) { ? ['exhaustion', 'frightened', 'poisoned'] : ['frightened', 'poisoned']; if (_hasStatuses(actor, statuses).length) { - ac5eConfig.disadvantage = ac5eConfig.disadvantage?.length - ? ac5eConfig.disadvantage.concat(_hasStatuses(actor, statuses)) - : _hasStatuses(actor, statuses); + ac5eConfig.disadvantage = [...ac5eConfig.disadvantage, ..._hasStatuses(actor, statuses)]; change = true; } //check Auto Armor if ( settings.autoArmor && ['dex', 'str'].includes(abilityId) && - _autoArmor(actor, 'prof') + !_autoArmor(actor, 'prof') ) { - ac5eConfig.disadvantage = ac5eConfig.disadvantage?.length - ? ac5eConfig.disadvantage.concat(_i18n5e('TraitArmorProf')) - : [_i18n5e('TraitArmorProf')]; + ac5eConfig.disadvantage = [...ac5eConfig.disadvantage, `${_i18n5e('Armor')} (${_i18n5e('NotProficient')})`]; change = true; } if (change) @@ -189,18 +171,14 @@ export function _preRollAttack(item, config) { return true; //to-do: Warning if more than one target selected. Think about more than one targets if (game.user.targets.size > 1) { - ui.notifications.warn( - 'Automated Conditions 5e: You are attacking multiple targets and that is not supported. The Roll results can be skewed.' - ); - console.warn( - 'Automated Conditions 5e: You are attacking multiple targets and that is not supported. The Roll results can be skewed.' - ); + ui.notifications.warn(game.i18n.localize("AC5E.MultipleTargetsAttackWarn")); + console.warn(game.i18n.localize("AC5E.MultipleTargetsAttackWarn")); } //on Source disadvantage - Blinded, Exhaustion 3-5, Frightened, Poisoned, Prone, Restrained let statuses = settings.autoExhaustion - ? ['blinded', 'exhaustion3', 'poisoned', 'prone', 'restrained'] - : ['blinded', 'poisoned', 'prone', 'restrained']; + ? ['blinded', 'exhaustion3', 'frightened', 'poisoned', 'prone', 'restrained'] + : ['blinded', 'frightened', 'poisoned', 'prone', 'restrained']; if (_hasStatuses(sourceActor, statuses).length) { ac5eConfig.disadvantage.source = ac5eConfig.disadvantage.source.concat( _hasStatuses(sourceActor, statuses) @@ -224,7 +202,7 @@ export function _preRollAttack(item, config) { ); change = true; } - //on Target advantage - Blinded, Paralysed, Paralyzed, Petrified, Restrained, Stunned, Unconscious + //on Target advantage - Blinded, Paralyzed, Petrified, Restrained, Stunned, Unconscious statuses = [ 'blinded', 'paralyzed', @@ -268,7 +246,7 @@ export function _preRollAttack(item, config) { !_autoArmor(sourceActor, 'prof') ) { ac5eConfig.disadvantage.source = ac5eConfig.disadvantage.source.concat( - _i18n5e('TraitArmorProf') + `${_i18n5e('Armor')} (${_i18n5e('NotProficient')})` ); change = true; } diff --git a/scripts/ac5e-settings.mjs b/scripts/ac5e-settings.mjs index 7b70436..01371c7 100644 --- a/scripts/ac5e-settings.mjs +++ b/scripts/ac5e-settings.mjs @@ -23,8 +23,8 @@ export default class Settings { Constants.MODULE_ID, Settings.SHOW_TOOLTIPS_ROLL_DIALOG, { - name: 'AC5e tooltips on Roll Dialogs.', - hint: 'When checked, AC5e will show a helpful tooltip when hovering over the suggested Roll button, summing up the reasons for that suggestion.', + name: 'AC5E.ShowDialogTooltipsName', + hint: 'AC5E.ShowDialogTooltipsHint', scope: 'client', config: true, default: true, @@ -35,8 +35,8 @@ export default class Settings { Constants.MODULE_ID, Settings.AUTOMATE_ARMOR_PROF_STEALTH, { - name: 'AC5e armor automation.', - hint: 'When checked, AC5e will automatically process proficiency in the equipped piece of armor for ability, skills and save rolls (STR || DEX) and stealth disadvantage property.', + name: 'AC5E.AutoArmorName', + hint: 'AC5E.AutoArmorHint', scope: 'world', config: true, default: false, @@ -47,8 +47,8 @@ export default class Settings { Constants.MODULE_ID, Settings.AUTOMATE_RANGED_ATTACKS, { - name: 'AC5e ranged attacks automation.', - hint: 'When checked, AC5e will automatically process distance disadvantage/fail based on target distance and range values of item used to attack.', + name: 'AC5E.AutoRangedAttacksName', + hint: 'AC5E.AutoRangedAttacksHint', scope: 'world', config: true, default: false, @@ -59,8 +59,8 @@ export default class Settings { Constants.MODULE_ID, Settings.AUTOMATE_EXHAUSTION, { - name: 'AC5e exhaustion automation.', - hint: 'When checked, AC5e will automatically process the normal 5e Exhaustion condition rules. Disable if you want compatibility with other exhaustion modules or your own rules (dnd-1 rules will be added in a future update).', + name: 'AC5e.AutoExhaustionName', + hint: 'AC5e.AutoExhaustionHint', scope: 'world', config: true, default: true,