CombatTracker, ChatCard, Fear Roll and localization fixes#307
CombatTracker, ChatCard, Fear Roll and localization fixes#307ClipplerBlood merged 14 commits intoXacus:masterfrom
Conversation
Item macro
Global parameters: Pass specific parameters:
(*) - Does not have attack attribute Example Weapon macro.In case of successful hit, it applies the Blinded affliction on the target for 1 round. If the total of the attack roll was 20 or higher and exceeds the score of the attribute or characteristic by 5 or more, the Blinded affliction duration is 3 rounds. if (args.pass === 'postRollAttack' && args.successfullHit) {
const targetActor = fromUuidSync(args.targetActorUuid)
const blindedEffect = foundry.utils.deepClone(CONFIG.statusEffects.find(e => e.id === 'blinded'))
blindedEffect['statuses'] = blindedEffect.id
blindedEffect.duration.rounds = args.plus20 ? 3 : 1
await ActiveEffect.create(blindedEffect, {
parent: targetActor,
})
} |
juanferrer
left a comment
There was a problem hiding this comment.
Added a few questions/suggestions.
| else return game.i18n.localize(tooltip) | ||
| }) | ||
|
|
||
| Handlebars.registerHelper('dlLocalize', function (groupName, str) { |
There was a problem hiding this comment.
Maybe should change the name to improve clarity, as it's building the localization string and handling special cases.
| // Get attacker attribute and defender attribute name | ||
| let attackAttribute = item.system.action?.attack?.toLowerCase() | ||
| const defenseAttribute = item.system.action?.against?.toLowerCase() | ||
| if (game.settings.get('demonlord', 'enableItemMacro')) await item.executeDLMacro({},{pass : 'preRollAttack', attackAttribute : attackAttribute, defenseAttribute: defenseAttribute, targetActorUuid: defender?.uuid}) |
There was a problem hiding this comment.
Maybe we should get the value once to avoid querying the settings so many times.
const itemMacroEnabled = game.settings.get('demonlord', 'enableItemMacro')and reuse
| @@ -168,13 +168,42 @@ export function buildAttackEffectsMessage(attacker, defender, item, attackAttrib | |||
| : defender?.system.horrifying | |||
| ? game.i18n.localize('DL.CreatureHorrifying') | |||
| : '' | |||
| else | |||
| creatureType = | |||
| defender?.system.frightening && defender?.system.horrifying | |||
| ? game.i18n.localize('DL.CreatureHorrifying') + '/' + game.i18n.localize('DL.CreatureFrightening') | |||
| : defender?.system.frightening | |||
| ? game.i18n.localize('DL.CreatureFrightening') | |||
| : defender?.system.horrifying | |||
| ? game.i18n.localize('DL.CreatureHorrifying') | |||
| : '' | |||
There was a problem hiding this comment.
From what I understand the code, it's basically the following:
- If we're in traitMode2025, it only matters if it's horrifying
- Otherwise, we add the relevant string for frightening/horrifying
Nested ternary operators get too complex too quickly. It can be simplified like this:
let creatureType = ''
const isFrightening = defender?.system.frightening
const isHorrifying = defender?.system.horrifying
const isTraitMode2025 = game.settings.get('demonlord', 'optionalRuleTraitMode2025')
if (isHorrifying && isTraitMode2025) {
creatureType = game.i18n.localize('DL.CreatureHorrifying')
} else if (isFrightening || isHorrifying) {
creatureType = isHorrifying ? game.i18n.localize('DL.CreatureHorrifying') : game.i18n.localize('DL.CreatureFrightening')
}I removed the frightening AND horrifying case, as a creature can't be frightening and horrifying, the strongest state wins (i.e. horrifying).





Thanks for pt-br transaltion to @nafeels !