Fix conflict

This commit is contained in:
Dapoolp 2025-08-05 21:16:13 +02:00
commit 3d1be5fa22
487 changed files with 16301 additions and 1974 deletions

View file

@ -19,10 +19,26 @@ export default class DHAncestry extends BaseDataItem {
};
}
/* -------------------------------------------- */
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/family-tree.svg';
/* -------------------------------------------- */
/**
* Gets the primary feature.
* @type {foundry.documents.Item|null} Returns the item of the first feature with type "primary" or null if none is found.
*/
get primaryFeature() {
return this.features.find(x => x.type === CONFIG.DH.ITEM.featureSubTypes.primary)?.item;
}
/**
* Gets the secondary feature.
* @type {foundry.documents.Item|null} Returns the item of the first feature with type "secondary" or null if none is found.
*/
get secondaryFeature() {
return this.features.find(x => x.type === CONFIG.DH.ITEM.featureSubTypes.secondary)?.item;
}

View file

@ -42,12 +42,20 @@ export default class DHArmor extends AttachableItem {
};
}
/* -------------------------------------------- */
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/chest-armor.svg';
/* -------------------------------------------- */
get customActions() {
return this.actions.filter(
action => !this.armorFeatures.some(feature => feature.actionIds.includes(action.id))
);
}
/**@inheritdoc */
async _preUpdate(changes, options, user) {
const allowed = await super._preUpdate(changes, options, user);
if (allowed === false) return false;
@ -68,7 +76,7 @@ export default class DHArmor extends AttachableItem {
return acc;
}, {});
for (var feature of added) {
for (const feature of added) {
const featureData = armorFeatures[feature.value];
if (featureData.effects?.length > 0) {
const embeddedItems = await this.parent.createEmbeddedDocuments(

View file

@ -8,7 +8,7 @@
* @property {boolean} isInventoryItem- Indicates whether items of this type is a Inventory Item
*/
import { addLinkedItemsDiff, updateLinkedItemApps } from '../../helpers/utils.mjs';
import { addLinkedItemsDiff, createScrollText, getScrollTextData, updateLinkedItemApps } from '../../helpers/utils.mjs';
import { ActionsField } from '../fields/actionField.mjs';
import FormulaField from '../fields/formulaField.mjs';
@ -56,6 +56,11 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
initial: null,
nullable: true
}),
progression: new fields.StringField({
required: true,
choices: CONFIG.DH.ITEM.itemResourceProgression,
initial: CONFIG.DH.ITEM.itemResourceProgression.increasing.id
}),
diceStates: new fields.TypedObjectField(
new fields.SchemaField({
value: new fields.NumberField({ integer: true, initial: 1, min: 1 }),
@ -79,6 +84,16 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
return schema;
}
/* -------------------------------------------- */
/**
* The default icon used for newly created Item documents
* @type {string}
*/
static DEFAULT_ICON = null;
/* -------------------------------------------- */
/**
* Convenient access to the item's actor, if it exists.
* @returns {foundry.documents.Actor | null}
@ -178,11 +193,20 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
if (allowed === false) return false;
addLinkedItemsDiff(changed.system?.features, this.features, options);
const autoSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
const armorChanged =
changed.system?.marks?.value !== undefined && changed.system.marks.value !== this.marks.value;
if (armorChanged && autoSettings.resourceScrollTexts && this.parent.parent?.type === 'character') {
const armorData = getScrollTextData(this.parent.parent.system.resources, changed.system.marks, 'armor');
options.scrollingTextData = [armorData];
}
}
_onUpdate(changed, options, userId) {
super._onUpdate(changed, options, userId);
updateLinkedItemApps(options, this.parent.sheet);
createScrollText(this.parent?.parent, options.scrollingTextData);
}
}

View file

@ -81,6 +81,13 @@ export default class DHBeastform extends BaseDataItem {
};
}
/* -------------------------------------------- */
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/wolf-head.svg';
/* -------------------------------------------- */
async _preCreate() {
if (!this.actor) return;

View file

@ -53,6 +53,13 @@ export default class DHClass extends BaseDataItem {
};
}
/* -------------------------------------------- */
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/laurel-crown.svg';
/* -------------------------------------------- */
get hopeFeatures() {
return this.features.filter(x => x.type === CONFIG.DH.ITEM.featureSubTypes.hope).map(x => x.item);
}

View file

@ -13,10 +13,15 @@ export default class DHCommunity extends BaseDataItem {
/** @inheritDoc */
static defineSchema() {
const fields = foundry.data.fields;
return {
...super.defineSchema(),
features: new ForeignDocumentUUIDArrayField({ type: 'Item' })
};
}
/* -------------------------------------------- */
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/village.svg';
}

View file

@ -22,4 +22,10 @@ export default class DHConsumable extends BaseDataItem {
consumeOnUse: new fields.BooleanField({ initial: false })
};
}
/* -------------------------------------------- */
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/round-potion.svg';
}

View file

@ -33,18 +33,26 @@ export default class DHDomainCard extends BaseDataItem {
};
}
/* -------------------------------------------- */
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/card-play.svg';
/* -------------------------------------------- */
/**@inheritdoc */
async _preCreate(data, options, user) {
const allowed = await super._preCreate(data, options, user);
if (allowed === false) return;
if (this.actor?.type === 'character') {
if (!this.actor.system.class.value) {
const actorClasses = this.actor.items.filter(x => x.type === 'class');
if (!actorClasses.length) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.noClassSelected'));
return false;
}
if (!this.actor.system.domains.find(x => x === this.domain)) {
if (!actorClasses.some(c => c.system.domains.find(x => x === this.domain))) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.lacksDomain'));
return false;
}

View file

@ -13,6 +13,13 @@ export default class DHFeature extends BaseDataItem {
});
}
/* -------------------------------------------- */
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/stars-stack.svg';
/* -------------------------------------------- */
/** @inheritDoc */
static defineSchema() {
const fields = foundry.data.fields;

View file

@ -19,4 +19,11 @@ export default class DHLoot extends BaseDataItem {
...super.defineSchema()
};
}
/* -------------------------------------------- */
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/open-treasure-chest.svg';
/* -------------------------------------------- */
}

View file

@ -29,6 +29,13 @@ export default class DHSubclass extends BaseDataItem {
};
}
/* -------------------------------------------- */
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/laurels.svg';
/* -------------------------------------------- */
get foundationFeatures() {
return this.features.filter(x => x.type === CONFIG.DH.ITEM.featureSubTypes.foundation).map(x => x.item);
}
@ -43,6 +50,7 @@ export default class DHSubclass extends BaseDataItem {
async _preCreate(data, options, user) {
if (this.actor?.type === 'character') {
const dataUuid = data.uuid ?? data._stats?.compendiumSource ?? `Item.${data._id}`;
if (this.actor.system.class.subclass) {
if (this.actor.system.multiclass.subclass) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassesAlreadyPresent'));
@ -54,7 +62,7 @@ export default class DHSubclass extends BaseDataItem {
return false;
}
if (multiclass.system.subclasses.every(x => x.uuid !== (data.uuid ?? `Item.${data._id}`))) {
if (multiclass.system.subclasses.every(x => x.uuid !== dataUuid)) {
ui.notifications.error(
game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInMulticlass')
);
@ -69,7 +77,7 @@ export default class DHSubclass extends BaseDataItem {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.missingClass'));
return false;
}
if (actorClass.system.subclasses.every(x => x.uuid !== (data.uuid ?? `Item.${data._id}`))) {
if (actorClass.system.subclasses.every(x => x.uuid !== dataUuid)) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.subclassNotInClass'));
return false;
}

View file

@ -80,6 +80,13 @@ export default class DHWeapon extends AttachableItem {
};
}
/* -------------------------------------------- */
/**@override */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/battered-axe.svg';
/* -------------------------------------------- */
get actionsList() {
return [this.attack, ...this.actions];
}