Merge branch 'main' into feature/56-Level-Up-Overview

This commit is contained in:
WBHarry 2025-05-31 21:47:48 +02:00
commit e0b986da3f
9 changed files with 81 additions and 26 deletions

View file

@ -5,12 +5,15 @@ import { GMUpdateEvent, socketEvent } from '../helpers/socket.mjs';
import { setDiceSoNiceForDualityRoll } from '../helpers/utils.mjs';
export default class DhpActor extends Actor {
_preCreate(data, changes, user) {
if (data.type === 'pc') {
data.prototypeToken = { actorLink: true, disposition: 1, sight: { enabled: true } };
}
super._preCreate(data, changes, user);
async _preCreate(data, options, user) {
if ( (await super._preCreate(data, options, user)) === false ) return false;
// Configure prototype token settings
const prototypeToken = {};
if ( this.type === "pc" ) Object.assign(prototypeToken, {
sight: { enabled: true }, actorLink: true, disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY
});
this.updateSource({ prototypeToken });
}
prepareData() {
@ -450,10 +453,20 @@ export default class DhpActor extends Actor {
let update = {};
switch (type) {
case SYSTEM.GENERAL.healingTypes.health.id:
update = { 'system.resources.health.value': Math.max(this.system.resources.health.value - healing, 0) };
update = {
'system.resources.health.value': Math.min(
this.system.resources.health.value + healing,
this.system.resources.health.max
)
};
break;
case SYSTEM.GENERAL.healingTypes.stress.id:
update = { 'system.resources.stress.value': Math.max(this.system.resources.stress.value - healing, 0) };
update = {
'system.resources.stress.value': Math.min(
this.system.resources.stress.value + healing,
this.system.resources.stress.max
)
};
break;
}
@ -486,7 +499,10 @@ export default class DhpActor extends Actor {
}
if (action.cost.type != null && action.cost.value != null) {
if (this.system.resources[action.cost.type].value < action.cost.value - 1) {
if (
this.system.resources[action.cost.type].value - action.cost.value <=
this.system.resources[action.cost.type].min
) {
ui.notifications.error(game.i18n.localize(`Insufficient ${action.cost.type} to use this ability`));
return;
}