mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Feature/247 auto add yope fear clear stress (#285)
* cleanup * test * Step 1 * #2 * Fix Effect Action & Add Hope tumation settings to hook * remove circular dependency * Snuck in some localization fixes I noticed * Remove success condition for duality roll gain * Changed config.roll.type logic --------- Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
parent
ee4a5d17a6
commit
52be430eff
21 changed files with 187 additions and 160 deletions
|
|
@ -19,7 +19,7 @@ export default class DHRoll extends Roll {
|
|||
}
|
||||
|
||||
static async buildConfigure(config = {}, message = {}) {
|
||||
config.hooks = [...(config.hooks ?? []), ''];
|
||||
config.hooks = [...this.getHooks(), ''];
|
||||
config.dialog ??= {};
|
||||
for (const hook of config.hooks) {
|
||||
if (Hooks.call(`${CONFIG.DH.id}.preRoll${hook.capitalize()}`, config, message) === false) return null;
|
||||
|
|
@ -94,6 +94,10 @@ export default class DHRoll extends Roll {
|
|||
config.dialog.configure ??= !(config.event.shiftKey || config.event.altKey || config.event.ctrlKey);
|
||||
}
|
||||
|
||||
static getHooks(hooks) {
|
||||
return hooks ?? [];
|
||||
}
|
||||
|
||||
formatModifier(modifier) {
|
||||
const numTerm = modifier < 0 ? '-' : '+';
|
||||
return [
|
||||
|
|
@ -131,3 +135,32 @@ export default class DHRoll extends Roll {
|
|||
return modifierTotal;
|
||||
}
|
||||
}
|
||||
|
||||
export const registerRollDiceHooks = () => {
|
||||
Hooks.on(`${CONFIG.DH.id}.postRollDuality`, async (config, message) => {
|
||||
if (
|
||||
!game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).hope ||
|
||||
config.roll.type === 'reaction'
|
||||
)
|
||||
return;
|
||||
|
||||
const actor = await fromUuid(config.source.actor),
|
||||
updates = [];
|
||||
if (!actor) return;
|
||||
if (config.roll.isCritical || config.roll.result.duality === 1) updates.push({ type: 'hope', value: 1 });
|
||||
if (config.roll.isCritical) updates.push({ type: 'stress', value: -1 });
|
||||
if (config.roll.result.duality === -1) updates.push({ type: 'fear', value: 1 });
|
||||
|
||||
if (updates.length) actor.modifyResource(updates);
|
||||
|
||||
if (!config.roll.hasOwnProperty('success') && !config.targets.length) return;
|
||||
|
||||
const rollResult = config.roll.success || config.targets.some(t => t.hit),
|
||||
looseSpotlight = !rollResult || config.roll.result.duality === -1;
|
||||
|
||||
if (looseSpotlight && game.combat?.active) {
|
||||
const currentCombatant = game.combat.combatants.get(game.combat.current?.combatantId);
|
||||
if (currentCombatant?.actorId == actor.id) ui.combat.setCombatantSpotlight(currentCombatant.id);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue