mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-22 23:43:37 +02:00
* Initial * . * Fixed positioning * . * Only showing the menu if there are extra resources * Improved resourceManager clickable * . * Changed variable name * Refactor resources selection and data prep (#1721) * Move resources select to scrolly text and accept actor object * Convert isReversed to prepared data and add label * Removed unused imports --------- Co-authored-by: WBHarry <williambjrklund@gmail.com> * Naming * [Feature] Custom Homebrew Resources (#1718) * Added resources to the Homebrew Menu * Fixed translations * . * Inverted from isImage to isIcon. Should be more logical for users * Removed testing resources * Refactor resource settings to not be a method (#1723) * Fix editing homebrew resources with a custom ResourcesField * Fix removing homebrew resources * Remove vestigial code * Use custom config for module data instead of including in all (#1724) * Use custom config for module data instead of including in all * More simple * base highest priority --------- Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com> Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
63 lines
2.6 KiB
JavaScript
63 lines
2.6 KiB
JavaScript
import { ResourcesField } from '../fields/actorField.mjs';
|
|
import BaseDataActor from './base.mjs';
|
|
|
|
export default class DhCreature extends BaseDataActor {
|
|
/**@inheritdoc */
|
|
static defineSchema() {
|
|
const fields = foundry.data.fields;
|
|
|
|
return {
|
|
...super.defineSchema(),
|
|
resources: new ResourcesField(this.metadata.type),
|
|
advantageSources: new fields.ArrayField(new fields.StringField(), {
|
|
label: 'DAGGERHEART.ACTORS.Character.advantageSources.label',
|
|
hint: 'DAGGERHEART.ACTORS.Character.advantageSources.hint'
|
|
}),
|
|
disadvantageSources: new fields.ArrayField(new fields.StringField(), {
|
|
label: 'DAGGERHEART.ACTORS.Character.disadvantageSources.label',
|
|
hint: 'DAGGERHEART.ACTORS.Character.disadvantageSources.hint'
|
|
})
|
|
};
|
|
}
|
|
|
|
get isAutoVulnerableActive() {
|
|
const vulnerableAppliedByOther = this.parent.effects.some(
|
|
x => x.statuses.has('vulnerable') && !x.flags.daggerheart?.autoApplyFlagId
|
|
);
|
|
return !vulnerableAppliedByOther;
|
|
}
|
|
|
|
async _preUpdate(changes, options, userId) {
|
|
const allowed = await super._preUpdate(changes, options, userId);
|
|
if (allowed === false) return;
|
|
|
|
const automationSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
|
|
if (
|
|
automationSettings.vulnerableAutomation &&
|
|
this.parent.type !== 'companion' &&
|
|
changes.system?.resources?.stress?.value
|
|
) {
|
|
const { name, description, img, autoApplyFlagId } = CONFIG.DH.GENERAL.conditions().vulnerable;
|
|
const autoEffects = this.parent.effects.filter(
|
|
x => x.flags.daggerheart?.autoApplyFlagId === autoApplyFlagId
|
|
);
|
|
if (changes.system.resources.stress.value >= this.resources.stress.max) {
|
|
if (!autoEffects.length)
|
|
this.parent.createEmbeddedDocuments('ActiveEffect', [
|
|
{
|
|
name: game.i18n.localize(name),
|
|
description: game.i18n.localize(description),
|
|
img: img,
|
|
statuses: ['vulnerable'],
|
|
flags: { daggerheart: { autoApplyFlagId } }
|
|
}
|
|
]);
|
|
} else if (this.resources.stress.value >= this.resources.stress.max) {
|
|
this.parent.deleteEmbeddedDocuments(
|
|
'ActiveEffect',
|
|
autoEffects.map(x => x.id)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|