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

@ -53,8 +53,8 @@ export default class DhpAdversary extends BaseDataActor {
})
}),
resources: new fields.SchemaField({
hitPoints: resourceField(0, 'DAGGERHEART.GENERAL.HitPoints.plural', true),
stress: resourceField(0, 'DAGGERHEART.GENERAL.stress', true)
hitPoints: resourceField(0, 0, 'DAGGERHEART.GENERAL.HitPoints.plural', true),
stress: resourceField(0, 0, 'DAGGERHEART.GENERAL.stress', true)
}),
attack: new ActionField({
initial: {
@ -105,6 +105,13 @@ export default class DhpAdversary extends BaseDataActor {
};
}
/* -------------------------------------------- */
/**@inheritdoc */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/actors/dragon-head.svg';
/* -------------------------------------------- */
get attackBonus() {
return this.attack.roll.bonus;
}

View file

@ -1,4 +1,5 @@
import DHBaseActorSettings from '../../applications/sheets/api/actor-setting.mjs';
import { createScrollText, getScrollTextData } from '../../helpers/utils.mjs';
const resistanceField = (resistanceLabel, immunityLabel, reductionLabel) =>
new foundry.data.fields.SchemaField({
@ -69,6 +70,16 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
return schema;
}
/* -------------------------------------------- */
/**
* The default icon used for newly created Actors documents
* @type {string}
*/
static DEFAULT_ICON = null;
/* -------------------------------------------- */
/**
* Obtain a data object used to evaluate any dice rolls associated with this Item Type
* @param {object} [options] - Options which modify the getRollData method.
@ -78,4 +89,28 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
const data = { ...this };
return data;
}
async _preUpdate(changes, options, userId) {
const allowed = await super._preUpdate(changes, options, userId);
if (allowed === false) return;
const autoSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
if (changes.system?.resources && autoSettings.resourceScrollTexts) {
const textData = Object.keys(changes.system.resources).reduce((acc, key) => {
const resource = changes.system.resources[key];
if (resource.value !== undefined && resource.value !== this.resources[key].value) {
acc.push(getScrollTextData(this.resources, resource, key));
}
return acc;
}, []);
options.scrollingTextData = textData;
}
}
_onUpdate(changes, options, userId) {
super._onUpdate(changes, options, userId);
createScrollText(this.parent, options.scrollingTextData);
}
}

View file

@ -7,8 +7,10 @@ import { ActionField } from '../fields/actionField.mjs';
import DHCharacterSettings from '../../applications/sheets-configs/character-settings.mjs';
export default class DhCharacter extends BaseDataActor {
/**@override */
static LOCALIZATION_PREFIXES = ['DAGGERHEART.ACTORS.Character'];
/**@inheritdoc */
static get metadata() {
return foundry.utils.mergeObject(super.metadata, {
label: 'TYPES.Actor.character',
@ -18,6 +20,7 @@ export default class DhCharacter extends BaseDataActor {
});
}
/**@inheritdoc */
static defineSchema() {
const fields = foundry.data.fields;
@ -25,13 +28,14 @@ export default class DhCharacter extends BaseDataActor {
...super.defineSchema(),
resources: new fields.SchemaField({
hitPoints: resourceField(
0,
0,
'DAGGERHEART.GENERAL.HitPoints.plural',
true,
'DAGGERHEART.ACTORS.Character.maxHPBonus'
),
stress: resourceField(6, 'DAGGERHEART.GENERAL.stress', true),
hope: resourceField(6, 'DAGGERHEART.GENERAL.hope')
stress: resourceField(6, 0, 'DAGGERHEART.GENERAL.stress', true),
hope: resourceField(6, 2, 'DAGGERHEART.GENERAL.hope')
}),
traits: new fields.SchemaField({
agility: attributeField('DAGGERHEART.CONFIG.Traits.agility.name'),
@ -239,7 +243,8 @@ export default class DhCharacter extends BaseDataActor {
stressDamageReduction: new fields.SchemaField({
severe: stressDamageReductionRule('DAGGERHEART.GENERAL.Rules.damageReduction.stress.severe'),
major: stressDamageReductionRule('DAGGERHEART.GENERAL.Rules.damageReduction.stress.major'),
minor: stressDamageReductionRule('DAGGERHEART.GENERAL.Rules.damageReduction.stress.minor')
minor: stressDamageReductionRule('DAGGERHEART.GENERAL.Rules.damageReduction.stress.minor'),
any: stressDamageReductionRule('DAGGERHEART.GENERAL.Rules.damageReduction.stress.any')
}),
increasePerArmorMark: new fields.NumberField({
integer: true,
@ -248,7 +253,11 @@ export default class DhCharacter extends BaseDataActor {
hint: 'DAGGERHEART.GENERAL.Rules.damageReduction.increasePerArmorMark.hint'
}),
magical: new fields.BooleanField({ initial: false }),
physical: new fields.BooleanField({ initial: false })
physical: new fields.BooleanField({ initial: false }),
thresholdImmunities: new fields.SchemaField({
minor: new fields.BooleanField({ initial: false })
}),
disabledArmor: new fields.BooleanField({ intial: false })
}),
attack: new fields.SchemaField({
damage: new fields.SchemaField({
@ -289,11 +298,16 @@ export default class DhCharacter extends BaseDataActor {
*/
flipMinDiceValue: new fields.BooleanField({ intial: false })
}),
runeWard: new fields.BooleanField({ initial: false })
runeWard: new fields.BooleanField({ initial: false }),
burden: new fields.SchemaField({
ignore: new fields.BooleanField()
})
})
};
}
/* -------------------------------------------- */
get tier() {
const currentLevel = this.levelData.level.current;
return currentLevel === 1

View file

@ -9,6 +9,7 @@ import { resourceField, bonusField } from '../fields/actorField.mjs';
export default class DhCompanion extends BaseDataActor {
static LOCALIZATION_PREFIXES = ['DAGGERHEART.ACTORS.Companion'];
/**@inheritdoc */
static get metadata() {
return foundry.utils.mergeObject(super.metadata, {
label: 'TYPES.Actor.companion',
@ -18,6 +19,7 @@ export default class DhCompanion extends BaseDataActor {
});
}
/**@inheritdoc */
static defineSchema() {
const fields = foundry.data.fields;
@ -25,7 +27,7 @@ export default class DhCompanion extends BaseDataActor {
...super.defineSchema(),
partner: new ForeignDocumentUUIDField({ type: 'Actor' }),
resources: new fields.SchemaField({
stress: resourceField(3, 'DAGGERHEART.GENERAL.stress', true),
stress: resourceField(3, 0, 'DAGGERHEART.GENERAL.stress', true),
hope: new fields.NumberField({ initial: 0, integer: true, label: 'DAGGERHEART.GENERAL.hope' })
}),
evasion: new fields.NumberField({
@ -87,6 +89,13 @@ export default class DhCompanion extends BaseDataActor {
};
}
/* -------------------------------------------- */
/**@inheritdoc */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/actors/capybara.svg';
/* -------------------------------------------- */
get proficiency() {
return this.partner?.system?.proficiency ?? 1;
}

View file

@ -3,8 +3,10 @@ import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayFie
import DHEnvironmentSettings from '../../applications/sheets-configs/environment-settings.mjs';
export default class DhEnvironment extends BaseDataActor {
/**@override */
static LOCALIZATION_PREFIXES = ['DAGGERHEART.ACTORS.Environment'];
/**@inheritdoc */
static get metadata() {
return foundry.utils.mergeObject(super.metadata, {
label: 'TYPES.Actor.environment',
@ -14,6 +16,7 @@ export default class DhEnvironment extends BaseDataActor {
});
}
/**@inheritdoc */
static defineSchema() {
const fields = foundry.data.fields;
return {
@ -37,6 +40,13 @@ export default class DhEnvironment extends BaseDataActor {
};
}
/* -------------------------------------------- */
/**@inheritdoc */
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/actors/forest.svg';
/* -------------------------------------------- */
get features() {
return this.parent.items.filter(x => x.type === 'feature');
}

View file

@ -103,7 +103,7 @@ class DhCountdown extends foundry.abstract.DataModel {
required: true,
choices: CONFIG.DH.GENERAL.countdownTypes,
initial: CONFIG.DH.GENERAL.countdownTypes.custom.id,
label: 'DAGGERHEART.APPLICATIONS.Countdown.FIELDS.countdowns.element.progress.type.value.label'
label: 'DAGGERHEART.GENERAL.type'
}),
label: new fields.StringField({
label: 'DAGGERHEART.APPLICATIONS.Countdown.FIELDS.countdowns.element.progress.type.label.label'

View file

@ -6,9 +6,9 @@ const attributeField = label =>
tierMarked: new fields.BooleanField({ initial: false })
});
const resourceField = (max = 0, label, reverse = false, maxLabel) =>
const resourceField = (max = 0, initial = 0, label, reverse = false, maxLabel) =>
new fields.SchemaField({
value: new fields.NumberField({ initial: 0, min: 0, integer: true, label }),
value: new fields.NumberField({ initial: initial, min: 0, integer: true, label }),
max: new fields.NumberField({
initial: max,
integer: true,

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];
}

View file

@ -34,6 +34,17 @@ export default class DhAutomation extends foundry.abstract.DataModel {
initial: true,
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.effects.rangeDependent.label'
})
}),
damageReductionRulesDefault: new fields.StringField({
required: true,
choices: CONFIG.DH.GENERAL.ruleChoice,
initial: CONFIG.DH.GENERAL.ruleChoice.onWithToggle.id,
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.damageReductionRulesDefault.label'
}),
resourceScrollTexts: new fields.BooleanField({
required: true,
initial: true,
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.resourceScrollTexts.label'
})
};
}