This commit is contained in:
WBHarry 2025-08-24 18:40:06 +02:00 committed by GitHub
parent 5a38e28a84
commit d686ac1e0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -115,11 +115,16 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
const typeForDefeated = ['character', 'adversary', 'companion'].find(x => x === this.parent.type); const typeForDefeated = ['character', 'adversary', 'companion'].find(x => x === this.parent.type);
if (defeatedSettings.enabled && typeForDefeated) { if (defeatedSettings.enabled && typeForDefeated) {
const resource = typeForDefeated === 'companion' ? 'stress' : 'hitPoints'; const resource = typeForDefeated === 'companion' ? 'stress' : 'hitPoints';
if (changes.system.resources[resource]) { const resourceValue = changes.system.resources[resource];
const becameMax = changes.system.resources[resource].value === this.resources[resource].max; if (
resourceValue &&
this.resources[resource].max &&
resourceValue.value !== this.resources[resource].value
) {
const becameMax = resourceValue.value === this.resources[resource].max;
const wasMax = const wasMax =
this.resources[resource].value === this.resources[resource].max && this.resources[resource].value === this.resources[resource].max &&
this.resources[resource].value !== changes.system.resources[resource].value; this.resources[resource].value !== resourceValue.value;
if (becameMax) { if (becameMax) {
this.parent.toggleDefeated(true); this.parent.toggleDefeated(true);
} else if (wasMax) { } else if (wasMax) {