This commit is contained in:
WBHarry 2025-11-14 08:43:51 +01:00
parent 013085299f
commit cd8e9f5f12
7 changed files with 66 additions and 44 deletions

View file

@ -7,6 +7,7 @@ import { socketEvent } from '../../../systemRegistration/socket.mjs';
import GroupRollDialog from '../../dialogs/group-roll-dialog.mjs';
import DhpActor from '../../../documents/actor.mjs';
import DHItem from '../../../documents/item.mjs';
import DhParty from '../../../data/actor/party.mjs';
export default class Party extends DHBaseActorSheet {
constructor(options) {
@ -79,6 +80,9 @@ export default class Party extends DHBaseActorSheet {
}
};
static ALLOWED_ACTOR_TYPES = ['character', 'companion', 'adversary'];
static DICE_ROLL_ACTOR_TYPES = ['character'];
async _onRender(context, options) {
await super._onRender(context, options);
this._createFilterMenus();
@ -276,14 +280,18 @@ export default class Party extends DHBaseActorSheet {
});
}
get partyMembersForRoll() {
return this.document.system.partyMembers.filter(x => Party.DICE_ROLL_ACTOR_TYPES.includes(x.type));
}
static async #tagTeamRoll() {
new game.system.api.applications.dialogs.TagTeamDialog(this.document.system.partyMembers).render({
new game.system.api.applications.dialogs.TagTeamDialog(this.partyMembersForRoll).render({
force: true
});
}
static async #groupRoll(params) {
new GroupRollDialog(this.document.system.partyMembers).render({ force: true });
new GroupRollDialog(this.partyMembersForRoll).render({ force: true });
}
/**
@ -455,7 +463,7 @@ export default class Party extends DHBaseActorSheet {
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
const item = await foundry.utils.fromUuid(data.uuid);
if (item instanceof DhpActor) {
if (item instanceof DhpActor && Party.ALLOWED_ACTOR_TYPES.includes(item.type)) {
const currentMembers = this.document.system.partyMembers.map(x => x.uuid);
if (currentMembers.includes(data.uuid)) {
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.duplicateCharacter'));

View file

@ -672,14 +672,6 @@ export default class DhCharacter extends BaseDataActor {
if (this.companion) {
this.companion.updateLevel(1);
}
if (this.parent.parties) {
for (const party of this.parent.parties) {
await party.update({
'system.partyMembers': party.system.partyMembers.filter(x => x.uuid !== this.parent.uuid)
});
}
}
}
_getTags() {

View file

@ -85,6 +85,17 @@ export default class DhpActor extends Actor {
this.updateSource({ prototypeToken });
}
/**@inheritdoc */
async _preDelete() {
if (this.parent.parties) {
for (const party of this.parent.parties) {
await party.update({
'system.partyMembers': party.system.partyMembers.filter(x => x.uuid !== this.parent.uuid)
});
}
}
}
_onUpdate(changes, options, userId) {
super._onUpdate(changes, options, userId);
for (const party of this.parties) {