Skip to content

Commit

Permalink
41 add lang file (#47)
Browse files Browse the repository at this point in the history
* Create en.json

* Armor proficiency and stealth tooltip fixes

* Update ac5e-hooks.mjs (#46)

- Add forgotten `frightened` condition.
  • Loading branch information
thatlonelybugbear authored Mar 15, 2024
1 parent efef92f commit 6dc0171
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 52 deletions.
11 changes: 11 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
@@ -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."
}
23 changes: 18 additions & 5 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -13,8 +13,8 @@
],
"compatibility": {
"minimum": "11",
"maximum": "11",
"verified": "11"
"maximum": "11.999",
"verified": "11.315"
},
"esmodules": ["scripts/ac5e-main.mjs"],
"relationships": {
Expand All @@ -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"
}
56 changes: 17 additions & 39 deletions scripts/ac5e-hooks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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;
}
}
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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',
Expand Down Expand Up @@ -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;
}
Expand Down
16 changes: 8 additions & 8 deletions scripts/ac5e-settings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 6dc0171

Please sign in to comment.