diff --git a/module/config/resourceConfig.mjs b/module/config/resourceConfig.mjs index 1306d327..56ef6cd5 100644 --- a/module/config/resourceConfig.mjs +++ b/module/config/resourceConfig.mjs @@ -57,10 +57,16 @@ const companionBaseResources = Object.freeze({ stress: { id: 'stress', initial: 0, - max: 3, + max: 0, reverse: true, label: 'DAGGERHEART.GENERAL.stress' }, + hope: { + id: 'hope', + initial: 0, + reverse: false, + label: 'DAGGERHEART.GENERAL.hope' + } }); export const character = { diff --git a/module/data/actor/adversary.mjs b/module/data/actor/adversary.mjs index dd41f290..2053ac99 100644 --- a/module/data/actor/adversary.mjs +++ b/module/data/actor/adversary.mjs @@ -189,9 +189,6 @@ export default class DhpAdversary extends DhCreature { prepareDerivedData() { super.prepareDerivedData(); this.attack.roll.isStandardAttack = true; - - // Clamp resources (must be done last to ensure all updates occur) - this.resources.clamp(); } _getTags() { diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index bea3a3ec..cde7d280 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -660,8 +660,6 @@ export default class DhCharacter extends DhCreature { prepareDerivedData() { super.prepareDerivedData(); - - this.resources.hope.max -= this.scars; if (this.companion) { for (let levelKey in this.companion.system.levelData.levelups) { const level = this.companion.system.levelData.levelups[levelKey]; @@ -675,6 +673,7 @@ export default class DhCharacter extends DhCreature { } } + this.resources.hope.max -= this.scars; this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait; this.resources.armor = { @@ -685,9 +684,6 @@ export default class DhCharacter extends DhCreature { }; this.attack.damage.parts[0].value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`; - - // Clamp resources (must be done last to ensure all updates occur) - this.resources.clamp(); } getRollData() { diff --git a/module/data/actor/companion.mjs b/module/data/actor/companion.mjs index c6768e95..7a8f0e64 100644 --- a/module/data/actor/companion.mjs +++ b/module/data/actor/companion.mjs @@ -130,6 +130,9 @@ export default class DhCompanion extends DhCreature { const level = this.levelData.levelups[levelKey]; for (let selection of level.selections) { switch (selection.type) { + case 'hope': + this.resources.hope += selection.value; + break; case 'vicious': if (selection.data[0] === 'damage') { this.attack.damage.parts[0].value.dice = adjustDice(this.attack.damage.parts[0].value.dice); @@ -164,9 +167,6 @@ export default class DhCompanion extends DhCreature { return acc; }, this.partner.system.companionData.levelupChoices); } - - // Clamp resources (must be done last to ensure all updates occur) - this.resources.clamp(); } async _preUpdate(changes, options, userId) { diff --git a/module/data/actor/creature.mjs b/module/data/actor/creature.mjs index 601068ad..88646301 100644 --- a/module/data/actor/creature.mjs +++ b/module/data/actor/creature.mjs @@ -60,4 +60,14 @@ export default class DhCreature extends BaseDataActor { } } } + + prepareDerivedData() { + const minLimitResource = resource => { + if (resource) resource.value = Math.min(resource.value, resource.max); + }; + + minLimitResource(this.resources.stress); + minLimitResource(this.resources.hitPoints); + minLimitResource(this.resources.hope); + } } diff --git a/module/data/fields/actorField.mjs b/module/data/fields/actorField.mjs index ac7dd5ef..a3c17281 100644 --- a/module/data/fields/actorField.mjs +++ b/module/data/fields/actorField.mjs @@ -80,18 +80,6 @@ class ResourcesField extends fields.TypedObjectField { value.isReversed = resources[key].reverse; value.max = typeof resource.max === 'number' ? (value.max ?? resource.max) : null; } - Object.defineProperty(data, 'clamp', { - value: function () { - for (const key of Object.keys(this)) { - const resource = this[key]; - if (typeof resource?.max === 'number') { - resource.value = Math.clamp(resource.value, 0, resource.max); - } - } - }, - enumerable: false - }); - return data; } diff --git a/system.json b/system.json index 162aa999..4049e676 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "id": "daggerheart", "title": "Daggerheart", "description": "An unofficial implementation of the Daggerheart system", - "version": "1.9.11", + "version": "1.9.10", "compatibility": { "minimum": "13.346", "verified": "13.351", @@ -10,7 +10,7 @@ }, "url": "https://github.com/Foundryborne/daggerheart", "manifest": "https://raw.githubusercontent.com/Foundryborne/daggerheart/V13/system.json", - "download": "https://github.com/Foundryborne/daggerheart/releases/download/1.9.11/system.zip", + "download": "https://github.com/Foundryborne/daggerheart/releases/download/1.9.10/system.zip", "authors": [ { "name": "WBHarry"