mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 19:51:08 +01:00
[Feature] 648 - Mark Defeated Actors (#914)
* Improved death marking styling * Added automation for defeated status * Fixed so the tracker recognises and sets the correct defeated statuses depending on type * Fixed so missing statuses doesn't cause crashes * Increased companion sheet width by 40 pixels * Added missing inheritDoc * Removed fas
This commit is contained in:
parent
c579b5f63c
commit
3489c9c2e8
21 changed files with 288 additions and 84 deletions
|
|
@ -106,6 +106,28 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
|
|||
}, []);
|
||||
options.scrollingTextData = textData;
|
||||
}
|
||||
|
||||
if (changes.system?.resources) {
|
||||
const defeatedSettings = game.settings.get(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.Automation
|
||||
).defeated;
|
||||
const typeForDefeated = ['character', 'adversary', 'companion'].find(x => x === this.parent.type);
|
||||
if (defeatedSettings.enabled && typeForDefeated) {
|
||||
const resource = typeForDefeated === 'companion' ? 'stress' : 'hitPoints';
|
||||
if (changes.system.resources[resource]) {
|
||||
const becameMax = changes.system.resources[resource].value === this.resources[resource].max;
|
||||
const wasMax =
|
||||
this.resources[resource].value === this.resources[resource].max &&
|
||||
this.resources[resource].value !== changes.system.resources[resource].value;
|
||||
if (becameMax) {
|
||||
this.parent.toggleDefeated(true);
|
||||
} else if (wasMax) {
|
||||
this.parent.toggleDefeated(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_onUpdate(changes, options, userId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue