Prevent creating a Trait when it's on a non-geist Actor

This commit is contained in:
Eldritch-Oliver 2025-10-10 21:49:32 -06:00
parent 0e0f9d3831
commit 4d0f29d7f0
2 changed files with 21 additions and 2 deletions

View file

@ -202,7 +202,8 @@
"invalid-socket": "Invalid socket data received, this means a module or system bug is present.", "invalid-socket": "Invalid socket data received, this means a module or system bug is present.",
"unknown-socket-event": "An unknown socket event was received: {event}", "unknown-socket-event": "An unknown socket event was received: {event}",
"no-active-gm": "No active @USER.GM is logged in, you must wait for a @USER.GM to be active before you can do that.", "no-active-gm": "No active @USER.GM is logged in, you must wait for a @USER.GM to be active before you can do that.",
"malformed-socket-payload": "Socket event \"{event}\" received with malformed payload. Details: {details}" "malformed-socket-payload": "Socket event \"{event}\" received with malformed payload. Details: {details}",
"invalid-parent-document": "Cannot create an item with type \"{itemType}\" on a parent document of type \"{parentType}\""
}, },
"warn": { "warn": {
"cannot-go-negative": "\"{name}\" is unable to be a negative number." "cannot-go-negative": "\"{name}\" is unable to be a negative number."

View file

@ -1,11 +1,29 @@
import { localizer } from "../../utils/Localizer.mjs";
const { fields } = foundry.data; const { fields } = foundry.data;
export class TraitData extends foundry.abstract.TypeDataModel { export class TraitData extends foundry.abstract.TypeDataModel {
// #region Schema // #region Schema
static defineSchema() { static defineSchema() {
return { return {
description: fields.HTMLField({ blank: true, nullable: false, trim: true }), description: new fields.HTMLField({ blank: true, nullable: false, trim: true }),
}; };
}; };
// #endregion Schema // #endregion Schema
// #region Lifecycle
async _preCreate() {
if (this.parent.isEmbedded && this.parent.parent.type !== `geist`) {
ui.notifications.error(localizer(
`RipCrypt.notifs.error.invalid-parent-document`,
{ itemType: `trait`, parentType: this.parent.parent.type },
));
return false;
};
};
// #endregion
async getFormFields() {
return [];
};
}; };