mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
Show notification when invalid item types are added to actors (#1807)
This commit is contained in:
parent
7d5cdeb09d
commit
aa8771bf0d
10 changed files with 41 additions and 25 deletions
|
|
@ -31,8 +31,13 @@ export default class DHItem extends foundry.documents.Item {
|
|||
static async createDocuments(sources, operation) {
|
||||
// Ensure that items being created are valid to the actor its being added to
|
||||
const actor = operation.parent;
|
||||
sources = actor?.system?.isItemValid ? sources.filter(s => actor.system.isItemValid(s)) : sources;
|
||||
return super.createDocuments(sources, operation);
|
||||
const filtered = actor ? sources.filter(s => actor.system.isItemValid(s)) : sources;
|
||||
if (actor && filtered.length === 0 && sources.length > 0) {
|
||||
const itemType = _loc(`TYPES.Item.${sources[0].type}`);
|
||||
const actorType = _loc(`TYPES.Actor.${actor.type}`);
|
||||
ui.notifications.error('DAGGERHEART.ACTORS.Base.CannotAddType', { format: { itemType, actorType } });
|
||||
}
|
||||
return super.createDocuments(filtered, operation);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue