Made the active PartySize available as a parameter for formulas

This commit is contained in:
WBHarry 2026-04-14 17:25:09 +02:00
parent 8d8dea81fe
commit ca097c21a3
9 changed files with 154 additions and 69 deletions

View file

@ -9,6 +9,7 @@ export default class DhParty extends BaseDataActor {
const fields = foundry.data.fields;
return {
...super.defineSchema(),
active: new fields.BooleanField(),
partyMembers: new ForeignDocumentUUIDArrayField({ type: 'Actor' }, { prune: true }),
notes: new fields.HTMLField(),
gold: new fields.SchemaField({
@ -44,6 +45,15 @@ export default class DhParty extends BaseDataActor {
}
}
/**@inheritdoc */
async _preCreate(data, options, user) {
const allowed = await super._preCreate(data, options, user);
if (allowed === false) return;
if (!game.actors.some(x => x.type === 'party' && x.active))
await this.updateSource({ active: true });
}
_onDelete(options, userId) {
super._onDelete(options, userId);