Attribute Item Subtype #76
3 changed files with 30 additions and 3 deletions
|
|
@ -133,7 +133,8 @@
|
||||||
"error": {
|
"error": {
|
||||||
"missing-id": "An ID must be provided",
|
"missing-id": "An ID must be provided",
|
||||||
"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}",
|
||||||
|
"duplicate-attribute-key": "Cannot create an Attribute with a key (\"{key}\") that already exists on the Actor"
|
||||||
},
|
},
|
||||||
"warn": {
|
"warn": {
|
||||||
"migration-in-progress": "Applying data migrations for version {version}. Please do NOT refresh the window while this warning is present."
|
"migration-in-progress": "Applying data migrations for version {version}. Please do NOT refresh the window while this warning is present."
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,9 @@ export class PlayerData extends foundry.abstract.TypeDataModel {
|
||||||
};
|
};
|
||||||
// #endregion Lifecycle
|
// #endregion Lifecycle
|
||||||
|
|
||||||
// #region Getters
|
// #region Methods
|
||||||
get hasAttributes() {
|
get hasAttributes() {
|
||||||
return Object.keys(this.attr).length > 0;
|
return Object.keys(this.attr).length > 0;
|
||||||
};
|
};
|
||||||
// #endregion Getters
|
// #endregion Methods
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
export class AttributeItemData extends foundry.abstract.TypeDataModel {
|
export class AttributeItemData extends foundry.abstract.TypeDataModel {
|
||||||
|
// #region Schema
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
return {
|
return {
|
||||||
|
|
@ -32,8 +33,33 @@ export class AttributeItemData extends foundry.abstract.TypeDataModel {
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
// #endregion Schema
|
||||||
|
|
||||||
|
// #region Lifecycle
|
||||||
|
async _preCreate(data, options, user) {
|
||||||
|
|
||||||
|
// Prevent duplicate Attribute keys from existing on a single Actor
|
||||||
|
if (this.parent.isEmbedded) {
|
||||||
|
const attr = this.parent.parent?.getAttribute(this.key);
|
||||||
|
if (attr) {
|
||||||
|
ui.notifications.error(
|
||||||
|
`taf.notifs.error.duplicate-attribute-key`,
|
||||||
|
{
|
||||||
|
localize: true,
|
||||||
|
format: { key: this.key },
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
return super._preCreate(data, options, user);
|
||||||
|
};
|
||||||
|
// #endregion Lifecycle
|
||||||
|
|
||||||
|
// #region Methods
|
||||||
get isRange() {
|
get isRange() {
|
||||||
return this.max !== null;
|
return this.max !== null;
|
||||||
};
|
};
|
||||||
|
// #endregion Methods
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue