mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-16 05:31:07 +01:00
Fix/877 hope update order (#896)
* Action Macro working again * k * Fix Hope gain on Duality Roll
This commit is contained in:
parent
6d789aceb3
commit
86a09df944
3 changed files with 25 additions and 16 deletions
|
|
@ -639,14 +639,20 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
this.consumeResource(result?.costs);
|
||||||
this.consumeResource(result?.costs);
|
|
||||||
}, 50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove when Action Refactor part #2 done
|
||||||
async consumeResource(costs) {
|
async consumeResource(costs) {
|
||||||
if (!costs?.length) return;
|
if (!costs?.length) return;
|
||||||
const usefulResources = foundry.utils.deepClone(this.actor.system.resources);
|
const usefulResources = {
|
||||||
|
...foundry.utils.deepClone(this.actor.system.resources),
|
||||||
|
fear: {
|
||||||
|
value: game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear),
|
||||||
|
max: game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxFear,
|
||||||
|
reversed: false
|
||||||
|
}
|
||||||
|
};
|
||||||
const resources = game.system.api.fields.ActionFields.CostField.getRealCosts(costs).map(c => {
|
const resources = game.system.api.fields.ActionFields.CostField.getRealCosts(costs).map(c => {
|
||||||
const resource = usefulResources[c.key];
|
const resource = usefulResources[c.key];
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -222,26 +222,27 @@ export const registerRollDiceHooks = () => {
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const actor = await fromUuid(config.source.actor),
|
const actor = await fromUuid(config.source.actor);
|
||||||
updates = [];
|
let updates = [];
|
||||||
if (!actor) return;
|
if (!actor) return;
|
||||||
if (config.roll.isCritical || config.roll.result.duality === 1) updates.push({ key: 'hope', value: 1 });
|
if (config.roll.isCritical || config.roll.result.duality === 1) updates.push({ key: 'hope', value: 1, total: -1, enabled: true });
|
||||||
if (config.roll.isCritical) updates.push({ key: 'stress', value: -1 });
|
if (config.roll.isCritical) updates.push({ key: 'stress', value: -1, total: 1, enabled: true });
|
||||||
if (config.roll.result.duality === -1) updates.push({ key: 'fear', value: 1 });
|
if (config.roll.result.duality === -1) updates.push({ key: 'fear', value: 1, total: -1, enabled: true });
|
||||||
|
|
||||||
if (config.rerolledRoll) {
|
if (config.rerolledRoll) {
|
||||||
if (config.rerolledRoll.isCritical || config.rerolledRoll.result.duality === 1)
|
if (config.rerolledRoll.isCritical || config.rerolledRoll.result.duality === 1)
|
||||||
updates.push({ key: 'hope', value: -1 });
|
updates.push({ key: 'hope', value: -1, total: 1, enabled: true });
|
||||||
if (config.rerolledRoll.isCritical) updates.push({ key: 'stress', value: 1 });
|
if (config.rerolledRoll.isCritical) updates.push({ key: 'stress', value: 1, total: -1, enabled: true });
|
||||||
if (config.rerolledRoll.result.duality === -1) updates.push({ key: 'fear', value: -1 });
|
if (config.rerolledRoll.result.duality === -1) updates.push({ key: 'fear', value: -1, total: 1, enabled: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updates.length) {
|
if (updates.length) {
|
||||||
const target = actor.system.partner ?? actor;
|
const target = actor.system.partner ?? actor;
|
||||||
if (!['dead', 'unconscious'].some(x => actor.statuses.has(x))) {
|
if (!['dead', 'unconscious'].some(x => actor.statuses.has(x))) {
|
||||||
setTimeout(() => {
|
if(config.rerolledRoll)
|
||||||
target.modifyResource(updates);
|
target.modifyResource(updates);
|
||||||
}, 50);
|
else
|
||||||
|
config.costs = [...(config.costs ?? []), ...updates];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,5 +255,7 @@ export const registerRollDiceHooks = () => {
|
||||||
const currentCombatant = game.combat.combatants.get(game.combat.current?.combatantId);
|
const currentCombatant = game.combat.combatants.get(game.combat.current?.combatantId);
|
||||||
if (currentCombatant?.actorId == actor.id) ui.combat.setCombatantSpotlight(currentCombatant.id);
|
if (currentCombatant?.actorId == actor.id) ui.combat.setCombatantSpotlight(currentCombatant.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
||||||
|
|
||||||
if(!game.user.isGM) {
|
if(!game.user.isGM) {
|
||||||
const applyButtons = html.querySelector(".apply-buttons");
|
const applyButtons = html.querySelector(".apply-buttons");
|
||||||
applyButtons.remove();
|
applyButtons?.remove();
|
||||||
if(!this.isAuthor && !this.speakerActor?.isOwner) {
|
if(!this.isAuthor && !this.speakerActor?.isOwner) {
|
||||||
const buttons = html.querySelectorAll(".ability-card-footer > .ability-use-button");
|
const buttons = html.querySelectorAll(".ability-card-footer > .ability-use-button");
|
||||||
buttons.forEach(b => b.remove());
|
buttons.forEach(b => b.remove());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue