Compare commits

..

No commits in common. "b3ab7ee3a7576e69826a1bdd7e8a0a48b3079efb" and "cfd9950aae0ac5f4a7f3d9be61e4f22c50450742" have entirely different histories.

7 changed files with 23 additions and 26 deletions

View file

@ -57,10 +57,16 @@ const companionBaseResources = Object.freeze({
stress: { stress: {
id: 'stress', id: 'stress',
initial: 0, initial: 0,
max: 3, max: 0,
reverse: true, reverse: true,
label: 'DAGGERHEART.GENERAL.stress' label: 'DAGGERHEART.GENERAL.stress'
}, },
hope: {
id: 'hope',
initial: 0,
reverse: false,
label: 'DAGGERHEART.GENERAL.hope'
}
}); });
export const character = { export const character = {

View file

@ -189,9 +189,6 @@ export default class DhpAdversary extends DhCreature {
prepareDerivedData() { prepareDerivedData() {
super.prepareDerivedData(); super.prepareDerivedData();
this.attack.roll.isStandardAttack = true; this.attack.roll.isStandardAttack = true;
// Clamp resources (must be done last to ensure all updates occur)
this.resources.clamp();
} }
_getTags() { _getTags() {

View file

@ -660,8 +660,6 @@ export default class DhCharacter extends DhCreature {
prepareDerivedData() { prepareDerivedData() {
super.prepareDerivedData(); super.prepareDerivedData();
this.resources.hope.max -= this.scars;
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,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.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
this.resources.armor = { 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}` : ''}`; 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() { getRollData() {

View file

@ -130,6 +130,9 @@ export default class DhCompanion extends DhCreature {
const level = this.levelData.levelups[levelKey]; const level = this.levelData.levelups[levelKey];
for (let selection of level.selections) { for (let selection of level.selections) {
switch (selection.type) { switch (selection.type) {
case 'hope':
this.resources.hope += selection.value;
break;
case 'vicious': case 'vicious':
if (selection.data[0] === 'damage') { if (selection.data[0] === 'damage') {
this.attack.damage.parts[0].value.dice = adjustDice(this.attack.damage.parts[0].value.dice); 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; return acc;
}, this.partner.system.companionData.levelupChoices); }, this.partner.system.companionData.levelupChoices);
} }
// Clamp resources (must be done last to ensure all updates occur)
this.resources.clamp();
} }
async _preUpdate(changes, options, userId) { async _preUpdate(changes, options, userId) {

View file

@ -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);
}
} }

View file

@ -80,18 +80,6 @@ class ResourcesField extends fields.TypedObjectField {
value.isReversed = resources[key].reverse; value.isReversed = resources[key].reverse;
value.max = typeof resource.max === 'number' ? (value.max ?? resource.max) : null; 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; return data;
} }

View file

@ -2,7 +2,7 @@
"id": "daggerheart", "id": "daggerheart",
"title": "Daggerheart", "title": "Daggerheart",
"description": "An unofficial implementation of the Daggerheart system", "description": "An unofficial implementation of the Daggerheart system",
"version": "1.9.11", "version": "1.9.10",
"compatibility": { "compatibility": {
"minimum": "13.346", "minimum": "13.346",
"verified": "13.351", "verified": "13.351",
@ -10,7 +10,7 @@
}, },
"url": "https://github.com/Foundryborne/daggerheart", "url": "https://github.com/Foundryborne/daggerheart",
"manifest": "https://raw.githubusercontent.com/Foundryborne/daggerheart/V13/system.json", "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": [ "authors": [
{ {
"name": "WBHarry" "name": "WBHarry"