mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 13:11:08 +01:00
This is psuedo fix to the incorrect resource usage when using multiple experiences.
This commit is contained in:
parent
3c893df175
commit
830c772c8b
2 changed files with 14 additions and 6 deletions
|
|
@ -95,6 +95,14 @@ export default class CostField extends fields.ArrayField {
|
||||||
|
|
||||||
static getRealCosts(costs) {
|
static getRealCosts(costs) {
|
||||||
const realCosts = costs?.length ? costs.filter(c => c.enabled) : [];
|
const realCosts = costs?.length ? costs.filter(c => c.enabled) : [];
|
||||||
|
|
||||||
|
// Reset totals in case of repeat calls.
|
||||||
|
realCosts.forEach(c => {
|
||||||
|
c.scale = c.scale ?? 0;
|
||||||
|
c.step = c.step ?? 1;
|
||||||
|
c.total = c.value + c.scale * c.step;
|
||||||
|
});
|
||||||
|
|
||||||
let mergedCosts = [];
|
let mergedCosts = [];
|
||||||
realCosts.forEach(c => {
|
realCosts.forEach(c => {
|
||||||
const getCost = Object.values(mergedCosts).find(gc => gc.key === c.key);
|
const getCost = Object.values(mergedCosts).find(gc => gc.key === c.key);
|
||||||
|
|
|
||||||
|
|
@ -226,16 +226,16 @@ export const registerRollDiceHooks = () => {
|
||||||
let updates = [];
|
let updates = [];
|
||||||
if (!actor) return;
|
if (!actor) return;
|
||||||
if (config.roll.isCritical || config.roll.result.duality === 1)
|
if (config.roll.isCritical || config.roll.result.duality === 1)
|
||||||
updates.push({ key: 'hope', value: 1, total: -1, enabled: true });
|
updates.push({ key: 'hope', value: -1, total: -1, enabled: true });
|
||||||
if (config.roll.isCritical) updates.push({ key: 'stress', value: 1, total: -1, enabled: true });
|
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, total: -1, enabled: true });
|
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, total: 1, enabled: true });
|
updates.push({ key: 'hope', value: -1, total: -1, enabled: true });
|
||||||
if (config.rerolledRoll.isCritical) updates.push({ key: 'stress', value: -1, total: 1, enabled: true });
|
if (config.rerolledRoll.isCritical) updates.push({ key: 'stress', value: -1, total: -1, enabled: true });
|
||||||
if (config.rerolledRoll.result.duality === -1)
|
if (config.rerolledRoll.result.duality === -1)
|
||||||
updates.push({ key: 'fear', value: -1, total: 1, enabled: true });
|
updates.push({ key: 'fear', value: -1, total: -1, enabled: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updates.length) {
|
if (updates.length) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue