Merge branch 'main' into feature/517-action-cost-on-success

This commit is contained in:
Dapoolp 2025-08-02 22:45:29 +02:00
commit 382c17a103
33 changed files with 109 additions and 146 deletions

View file

@ -1,4 +1,4 @@
import DhAppearance, { DualityRollColor } from '../../data/settings/Appearance.mjs';
import DhAppearance from '../../data/settings/Appearance.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
@ -96,11 +96,6 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
static async save() {
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance, this.settings.toObject());
document.body.classList.toggle(
'theme-colorful',
game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance).dualityColorScheme ===
DualityRollColor.colorful.value
);
this.close();
}

View file

@ -266,9 +266,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
const doc = await getDocFromElement(target);
const actorLoadout = doc.actor.system.loadoutSlot;
if (actorLoadout.available) return doc.update({ 'system.inVault': false });
ui.notifications.warn(
game.i18n.format('DAGGERHEART.UI.Notifications.loadoutMaxReached', { max: actorLoadout.max })
);
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.loadoutMaxReached'));
}
},
{
@ -686,6 +684,11 @@ export default class CharacterSheet extends DHBaseActorSheet {
*/
static async #toggleVault(_event, button) {
const doc = await getDocFromElement(button);
const { available } = this.document.system.loadoutSlot;
if (doc.system.inVault && !available) {
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.loadoutMaxReached'));
}
await doc?.update({ 'system.inVault': !doc.system.inVault });
}

View file

@ -480,7 +480,7 @@ export default function DHApplicationMixin(Base) {
*/
static async #toChat(_event, target) {
let doc = await getDocFromElement(target);
return doc.toChat(this.document.id);
return doc.toChat(doc.uuid);
}
/**

View file

@ -15,7 +15,10 @@ export default class ClassSheet extends DHBaseItemSheet {
{
selector: '.domain-input',
options: () => CONFIG.DH.DOMAIN.domains,
callback: ClassSheet.#onDomainSelect
callback: ClassSheet.#onDomainSelect,
tagifyOptions: {
maxTags: () => game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxDomains
}
}
],
dragDrop: [

View file

@ -117,9 +117,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
async onRollAllSave(event, message) {
event.stopPropagation();
if (!game.user.isGM) return;
const targets = event.target.parentElement.querySelectorAll(
'[data-token] .target-save'
);
const targets = event.target.parentElement.querySelectorAll('[data-token] .target-save');
const actor = await this.getActor(message.system.source.actor),
action = this.getAction(actor, message.system.source.item, message.system.source.action);
targets.forEach(async el => {
@ -169,9 +167,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
async onRollSimple(event, message) {
const buttonType = event.target.dataset.type ?? 'damage',
total = message.rolls.reduce((a,c) => a + Roll.fromJSON(c).total, 0),
total = message.rolls.reduce((a, c) => a + Roll.fromJSON(c).total, 0),
damages = {
'hitPoints': {
hitPoints: {
parts: [
{
applyTo: 'hitPoints',
@ -186,20 +184,18 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
if (targets.length === 0)
return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected'));
targets.forEach(target => {
if(buttonType === 'healing')
target.actor.takeHealing(damages);
else
target.actor.takeDamage(damages);
})
targets.forEach(target => {
if (buttonType === 'healing') target.actor.takeHealing(damages);
else target.actor.takeDamage(damages);
});
}
async abilityUseButton(event, message) {
event.stopPropagation();
const action = message.system.actions[Number.parseInt(event.currentTarget.dataset.index)];
const actor = game.actors.get(message.system.source.actor);
await actor.use(action);
const item = await foundry.utils.fromUuid(message.system.origin);
const action = item.system.actions.get(event.currentTarget.id);
await item.use(action);
}
async actionUseButton(event, message) {

View file

@ -29,14 +29,3 @@ export const gameSettings = {
LevelTiers: 'LevelTiers',
Countdowns: 'Countdowns'
};
export const DualityRollColor = {
colorful: {
value: 0,
label: 'DAGGERHEART.SETTINGS.DualityRollColor.options.colorful'
},
normal: {
value: 1,
label: 'DAGGERHEART.SETTINGS.DualityRollColor.options.normal'
}
};

View file

@ -144,7 +144,7 @@ export default class DhpAdversary extends BaseDataActor {
super._onUpdate(changes, options, userId);
if (game.user.id === userId) {
if (changes.system.type) {
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)

View file

@ -362,13 +362,12 @@ export default class DhCharacter extends BaseDataActor {
get loadoutSlot() {
const loadoutCount = this.domainCards.loadout?.length ?? 0,
max =
game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxLoadout +
this.bonuses.maxLoadout;
worldSetting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxLoadout,
max = !worldSetting ? null : worldSetting + this.bonuses.maxLoadout;
return {
current: loadoutCount,
available: Math.max(max - loadoutCount, 0),
available: !max ? true : Math.max(max - loadoutCount, 0),
max
};
}
@ -579,7 +578,7 @@ export default class DhCharacter extends BaseDataActor {
: this.levelData.level.current * 2
};
this.resources.hope.max -= Object.keys(this.scars).length;
this.resources.hitPoints.max = this.class.value?.system?.hitPoints ?? 0;
this.resources.hitPoints.max += this.class.value?.system?.hitPoints ?? 0;
}
prepareDerivedData() {

View file

@ -19,7 +19,7 @@ export default class DHClass extends BaseDataItem {
const fields = foundry.data.fields;
return {
...super.defineSchema(),
domains: new fields.ArrayField(new fields.StringField(), { max: 2 }),
domains: new fields.ArrayField(new fields.StringField()),
classItems: new ForeignDocumentUUIDArrayField({ type: 'Item', required: false }),
hitPoints: new fields.NumberField({
required: true,
@ -123,6 +123,14 @@ export default class DHClass extends BaseDataItem {
const allowed = await super._preUpdate(changed, options, userId);
if (allowed === false) return false;
if (changed.system?.domains) {
const maxDomains = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxDomains;
if (changed.system.domains.length > maxDomains) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.domainMaxReached'));
return false;
}
}
const paths = [
'subclasses',
'characterGuide.suggestedPrimaryWeapon',

View file

@ -10,12 +10,6 @@ export default class DhAppearance extends foundry.abstract.DataModel {
initial: fearDisplay.token.value,
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.displayFear.label'
}),
dualityColorScheme: new fields.StringField({
required: true,
choices: DualityRollColor,
initial: DualityRollColor.normal.value,
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.dualityColorScheme.label'
}),
diceSoNice: new fields.SchemaField({
hope: new fields.SchemaField({
foreground: new fields.ColorField({ required: true, initial: '#ffffff' }),
@ -65,14 +59,3 @@ export default class DhAppearance extends foundry.abstract.DataModel {
};
}
}
export const DualityRollColor = {
colorful: {
value: 'colorful',
label: 'DAGGERHEART.SETTINGS.DualityRollColor.options.colorful'
},
normal: {
value: 'normal',
label: 'DAGGERHEART.SETTINGS.DualityRollColor.options.normal'
}
};

View file

@ -21,6 +21,13 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
initial: 5,
label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.maxLoadout.label'
}),
maxDomains: new fields.NumberField({
required: true,
integer: true,
min: 1,
initial: 2,
label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.maxDomains.label'
}),
traitArray: new fields.ArrayField(new fields.NumberField({ required: true, integer: true }), {
initial: () => [2, 1, 1, 0, 0, -1]
}),

View file

@ -318,8 +318,16 @@ export default class DhpActor extends Actor {
for (var domainCard of domainCards) {
if (levelupAuto) {
const item = await foundry.utils.fromUuid(domainCard.data[0]);
const embeddedItem = await this.createEmbeddedDocuments('Item', [item.toObject()]);
const itemData = (await foundry.utils.fromUuid(domainCard.data[0])).toObject();
const embeddedItem = await this.createEmbeddedDocuments('Item', [
{
...itemData,
system: {
...itemData.system,
inVault: true
}
}
]);
selections.push({ ...domainCard, itemUuid: embeddedItem[0].uuid });
} else {
selections.push({ ...domainCard });
@ -329,8 +337,16 @@ export default class DhpActor extends Actor {
const achievementDomainCards = [];
if (levelupAuto) {
for (var card of Object.values(level.achievements.domainCards)) {
const item = await foundry.utils.fromUuid(card.uuid);
const embeddedItem = await this.createEmbeddedDocuments('Item', [item.toObject()]);
const itemData = (await foundry.utils.fromUuid(card.uuid)).toObject();
const embeddedItem = await this.createEmbeddedDocuments('Item', [
{
...itemData,
system: {
...itemData.system,
inVault: true
}
}
]);
card.itemUuid = embeddedItem[0].uuid;
achievementDomainCards.push(card);
}

View file

@ -132,6 +132,8 @@ export default class DHItem extends foundry.documents.Item {
async toChat(origin) {
const cls = getDocumentClass('ChatMessage');
const item = await foundry.utils.fromUuid(origin);
const systemData = {
title:
this.type === 'ancestry'
@ -148,13 +150,14 @@ export default class DHItem extends foundry.documents.Item {
img: this.img,
tags: this._getTags()
},
description: this.system.description,
actions: this.system.actions
actions: item.system.actions,
description: this.system.description
};
const msg = {
type: 'abilityUse',
user: game.user.id,
actor: game.actors.get(cls.getSpeaker().actor),
actor: item.parent,
author: this.author,
speaker: cls.getSpeaker(),
system: systemData,

View file

@ -97,7 +97,7 @@ export const tagifyElement = (element, options, onChange, tagifyOptions = {}) =>
description: option.description
};
}),
maxTags: maxTags,
maxTags: typeof maxTags === 'function' ? maxTags() : maxTags,
dropdown: {
mapValueTo: 'name',
searchKeys: ['name'],