mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
Fixed base resources getting their values capped to max at prepareDerivedData. Fixed effect autocomplete not having labels for baseResources.
This commit is contained in:
parent
d258478218
commit
a4fff56461
3 changed files with 16 additions and 7 deletions
|
|
@ -660,7 +660,6 @@ export default class DhCharacter extends DhCreature {
|
||||||
|
|
||||||
prepareDerivedData() {
|
prepareDerivedData() {
|
||||||
super.prepareDerivedData();
|
super.prepareDerivedData();
|
||||||
let baseHope = this.resources.hope.value;
|
|
||||||
if (this.companion) {
|
if (this.companion) {
|
||||||
for (let levelKey in this.companion.system.levelData.levelups) {
|
for (let levelKey in this.companion.system.levelData.levelups) {
|
||||||
const level = this.companion.system.levelData.levelups[levelKey];
|
const level = this.companion.system.levelData.levelups[levelKey];
|
||||||
|
|
@ -675,7 +674,6 @@ export default class DhCharacter extends DhCreature {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resources.hope.max -= this.scars;
|
this.resources.hope.max -= this.scars;
|
||||||
this.resources.hope.value = Math.min(baseHope, this.resources.hope.max);
|
|
||||||
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
|
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
|
||||||
|
|
||||||
this.resources.armor = {
|
this.resources.armor = {
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,14 +88,15 @@ class ResourcesField extends fields.TypedObjectField {
|
||||||
* This returns the element if its a valid resource key and overwrites the element's label for that retrieval.
|
* This returns the element if its a valid resource key and overwrites the element's label for that retrieval.
|
||||||
*/
|
*/
|
||||||
_getField(path) {
|
_getField(path) {
|
||||||
if ( path.length === 0 ) return this;
|
if (path.length === 0) return this;
|
||||||
const first = path.shift();
|
const first = path.shift();
|
||||||
if (first === this.element.name) return this.element_getField(path);
|
if (first === this.element.name) return this.element_getField(path);
|
||||||
|
|
||||||
const resources = CONFIG.DH.RESOURCE[this.actorType].all;
|
const resources = CONFIG.DH.RESOURCE[this.actorType].all;
|
||||||
if (first in resources) {
|
if (first in resources) {
|
||||||
this.element.label = resources[first].label;
|
const field = this.element._getField(path);
|
||||||
return this.element._getField(path);
|
field.label = resources[first].label;
|
||||||
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue