Merged with main

This commit is contained in:
WBHarry 2025-08-01 17:15:35 +02:00
commit 6a3eb345c4
208 changed files with 21473 additions and 1792 deletions

View file

@ -345,4 +345,17 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
});
}
}
/**
* Generates a list of localized tags for this action.
* @returns {string[]} An array of localized tag strings.
*/
_getTags() {
const tags = [
game.i18n.localize(`DAGGERHEART.ACTIONS.TYPES.${this.type}.name`),
game.i18n.localize(`DAGGERHEART.CONFIG.ActionType.${this.actionType}`)
];
return tags;
}
}

View file

@ -10,10 +10,8 @@ export default class DHDamageAction extends DHBaseAction {
const isAdversary = this.actor.type === 'adversary';
if (isAdversary && this.actor.system.type === CONFIG.DH.ACTOR.adversaryTypes.horde.id) {
const hasHordeDamage = this.actor.effects.find(
x => x.name === game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label')
);
if (hasHordeDamage) return part.valueAlt;
const hasHordeDamage = this.actor.effects.find(x => x.type === 'horde');
if (hasHordeDamage && !hasHordeDamage.disabled) return part.valueAlt;
}
return formulaValue;
@ -47,7 +45,9 @@ export default class DHDamageAction extends DHBaseAction {
formulas = this.formatFormulas(formulas, systemData);
const config = {
title: game.i18n.format(`DAGGERHEART.UI.Chat.${ this.type === 'healing' ? 'healing' : 'damage'}Roll.title`, { damage: game.i18n.localize(this.name) }),
title: game.i18n.format(`DAGGERHEART.UI.Chat.${this.type === 'healing' ? 'healing' : 'damage'}Roll.title`, {
damage: game.i18n.localize(this.name)
}),
roll: formulas,
targets: systemData.targets?.filter(t => t.hit) ?? data.targets,
hasSave: this.hasSave,

View file

@ -1,9 +1,11 @@
import BaseEffect from './baseEffect.mjs';
import BeastformEffect from './beastformEffect.mjs';
import HordeEffect from './hordeEffect.mjs';
export { BaseEffect, BeastformEffect };
export { BaseEffect, BeastformEffect, HordeEffect };
export const config = {
base: BaseEffect,
beastform: BeastformEffect
beastform: BeastformEffect,
horde: HordeEffect
};

View file

@ -0,0 +1,3 @@
import BaseEffect from './baseEffect.mjs';
export default class HordeEffect extends BaseEffect {}

View file

@ -118,29 +118,46 @@ export default class DhpAdversary extends BaseDataActor {
if (allowed === false) return false;
if (this.type === CONFIG.DH.ACTOR.adversaryTypes.horde.id) {
if (changes.system?.resources?.hitPoints?.value) {
const halfHP = Math.ceil(this.resources.hitPoints.max / 2);
const newHitPoints = changes.system.resources.hitPoints.value;
const previouslyAboveHalf = this.resources.hitPoints.value < halfHP;
const loweredBelowHalf = previouslyAboveHalf && newHitPoints >= halfHP;
const raisedAboveHalf = !previouslyAboveHalf && newHitPoints < halfHP;
if (loweredBelowHalf) {
await this.parent.createEmbeddedDocuments('ActiveEffect', [
{
name: game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label'),
img: 'icons/magic/movement/chevrons-down-yellow.webp',
disabled: !game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation)
.hordeDamage
}
]);
} else if (raisedAboveHalf) {
const hordeEffects = this.parent.effects.filter(
x => x.name === game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label')
);
await this.parent.deleteEmbeddedDocuments(
'ActiveEffect',
hordeEffects.map(x => x.id)
);
const autoHordeDamage = game.settings.get(
CONFIG.DH.id,
CONFIG.DH.SETTINGS.gameSettings.Automation
).hordeDamage;
if (autoHordeDamage && changes.system?.resources?.hitPoints?.value) {
const hordeActiveEffect = this.parent.effects.find(x => x.type === 'horde');
if (hordeActiveEffect) {
const halfHP = Math.ceil(this.resources.hitPoints.max / 2);
const newHitPoints = changes.system.resources.hitPoints.value;
const previouslyAboveHalf = this.resources.hitPoints.value < halfHP;
const loweredBelowHalf = previouslyAboveHalf && newHitPoints >= halfHP;
const raisedAboveHalf = !previouslyAboveHalf && newHitPoints < halfHP;
if (loweredBelowHalf) {
await hordeActiveEffect.update({ disabled: false });
} else if (raisedAboveHalf) {
await hordeActiveEffect.update({ disabled: true });
}
}
}
}
}
_onUpdate(changes, options, userId) {
super._onUpdate(changes, options, userId);
if (game.user.id === userId) {
if (changes.system.type) {
const existingHordeEffect = this.parent.effects.find(x => x.type === 'horde');
if (changes.system.type === CONFIG.DH.ACTOR.adversaryTypes.horde.id) {
if (!existingHordeEffect)
this.parent.createEmbeddedDocuments('ActiveEffect', [
{
type: 'horde',
name: game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label'),
img: 'icons/magic/movement/chevrons-down-yellow.webp',
disabled: true
}
]);
} else {
existingHordeEffect?.delete();
}
}
}

View file

@ -117,4 +117,26 @@ export default class DHArmor extends AttachableItem {
}
}
}
/**
* Generates a list of localized tags based on this item's type-specific properties.
* @returns {string[]} An array of localized tag strings.
*/
_getTags() {
const tags = [
`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseScore')}: ${this.baseScore}`,
`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseThresholds.base')}: ${this.baseThresholds.major} / ${this.baseThresholds.severe}`
];
return tags;
}
/**
* Generate a localized label array for this item subtype.
* @returns {(string | { value: string, icons: string[] })[]} An array of localized strings and damage label objects.
*/
_getLabels() {
const labels = [`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseScore')}: ${this.baseScore}`];
return labels;
}
}

View file

@ -127,7 +127,8 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
if (this.actor && this.actor.type === 'character' && this.features) {
const featureUpdates = {};
for (let f of this.features) {
const feature = f.item ?? f;
const fBase = f.item ?? f;
const feature = fBase.system ? fBase : await foundry.utils.fromUuid(fBase.uuid);
const createData = foundry.utils.mergeObject(
feature.toObject(),
{

View file

@ -1,5 +1,4 @@
import BaseDataItem from './base.mjs';
import { ActionField } from '../fields/actionField.mjs';
export default class DHDomainCard extends BaseDataItem {
/** @inheritDoc */
@ -34,6 +33,7 @@ export default class DHDomainCard extends BaseDataItem {
};
}
/**@inheritdoc */
async _preCreate(data, options, user) {
const allowed = await super._preCreate(data, options, user);
if (allowed === false) return;
@ -55,4 +55,35 @@ export default class DHDomainCard extends BaseDataItem {
}
}
}
/**
* Generates a list of localized tags based on this item's type-specific properties.
* @returns {string[]} An array of localized tag strings.
*/
_getTags() {
const tags = [
game.i18n.localize(`DAGGERHEART.CONFIG.DomainCardTypes.${this.type}`),
game.i18n.localize(`DAGGERHEART.GENERAL.Domain.${this.domain}.label`),
`${game.i18n.localize('DAGGERHEART.ITEMS.DomainCard.recallCost')}: ${this.recallCost}`
];
return tags;
}
/**
* Generate a localized label array for this item subtype.
* @returns {(string | { value: string, icons: string[] })[]} An array of localized strings and damage label objects.
*/
_getLabels() {
const labels = [
game.i18n.localize(`DAGGERHEART.CONFIG.DomainCardTypes.${this.type}`),
game.i18n.localize(`DAGGERHEART.GENERAL.Domain.${this.domain}.label`),
{
value: `${this.recallCost}`, //converts the number to a string
icons: ['fa-bolt']
}
];
return labels;
}
}

View file

@ -167,4 +167,64 @@ export default class DHWeapon extends AttachableItem {
}
}
}
/**
* Generates a list of localized tags based on this item's type-specific properties.
* @returns {string[]} An array of localized tag strings.
*/
_getTags() {
const { attack, burden } = this;
const tags = [
game.i18n.localize(`DAGGERHEART.CONFIG.Traits.${attack.roll.trait}.name`),
game.i18n.localize(`DAGGERHEART.CONFIG.Range.${attack.range}.name`),
game.i18n.localize(`DAGGERHEART.CONFIG.Burden.${burden}`)
];
for (const { value, type } of attack.damage.parts) {
const parts = [value.dice];
if (value.bonus) parts.push(value.bonus.signedString());
if (type.size > 0) {
const typeTags = Array.from(type)
.map(t => game.i18n.localize(`DAGGERHEART.CONFIG.DamageType.${t}.abbreviation`))
.join(' | ');
parts.push(` (${typeTags})`); // Add a space in front and put it inside a ().
}
tags.push(parts.join(''));
}
return tags;
}
/**
* Generate a localized label array for this item subtype.
* @returns {(string | { value: string, icons: string[] })[]} An array of localized strings and damage label objects.
*/
_getLabels() {
const { roll, range, damage } = this.attack;
const labels = [
game.i18n.localize(`DAGGERHEART.CONFIG.Traits.${roll.trait}.short`),
game.i18n.localize(`DAGGERHEART.CONFIG.Range.${range}.short`)
];
for (const { value, type } of damage.parts) {
const str = [value.dice];
if (value.bonus) str.push(value.bonus.signedString());
const icons = Array.from(type)
.map(t => CONFIG.DH.GENERAL.damageTypes[t]?.icon)
.filter(Boolean);
const labelValue = str.join('');
if (icons.length === 0) {
labels.push(labelValue);
} else {
labels.push({ value: labelValue, icons });
}
}
return labels;
}
}