This commit is contained in:
WBHarry 2025-08-06 10:56:21 +02:00
parent 0bb20b2ddc
commit d01965e5b9
20 changed files with 146 additions and 67 deletions

View file

@ -34,7 +34,7 @@ export default class MulticlassChoiceDialog extends HandlebarsApplicationMixin(A
const context = await super._prepareContext(_options);
context.multiclass = this.multiclass;
context.domainChoices = this.multiclass.domains.map(value => {
const domain = CONFIG.DH.DOMAIN.domains[value];
const domain = CONFIG.DH.DOMAIN.allDomains()[value];
return {
value: value,
label: game.i18n.localize(domain.label),

View file

@ -1,6 +1,5 @@
import LevelUpBase from './levelup.mjs';
import { DhLevelup } from '../../data/levelup.mjs';
import { domains } from '../../config/domainConfig.mjs';
import { abilities, subclassFeatureLabels } from '../../config/actorConfig.mjs';
export default class DhCharacterLevelUp extends LevelUpBase {
@ -113,7 +112,7 @@ export default class DhCharacterLevelUp extends LevelUpBase {
: levelBase;
return game.i18n.format('DAGGERHEART.APPLICATIONS.Levelup.selections.emptyDomainCardHint', {
domain: game.i18n.localize(domains[domain.domain].label),
domain: game.i18n.localize(CONFIG.DH.DOMAIN.allDomains()[domain.domain].label),
level: levelMax
});
}),
@ -170,7 +169,7 @@ export default class DhCharacterLevelUp extends LevelUpBase {
uuid: multiclass.uuid,
domains:
multiclass?.system?.domains.map(key => {
const domain = domains[key];
const domain = CONFIG.DH.DOMAIN.allDomains()[key];
const alreadySelected = this.actor.system.class.value.system.domains.includes(key);
return {
@ -315,7 +314,10 @@ export default class DhCharacterLevelUp extends LevelUpBase {
? {
...multiclassItem.toObject(),
domain: checkbox.secondaryData.domain
? game.i18n.localize(domains[checkbox.secondaryData.domain].label)
? game.i18n.localize(
CONFIG.DH.DOMAIN.allDomains()[checkbox.secondaryData.domain]
.label
)
: null,
subclass: subclass ? subclass.name : null
}

View file

@ -1,5 +1,4 @@
import { abilities, subclassFeatureLabels } from '../../config/actorConfig.mjs';
import { domains } from '../../config/domainConfig.mjs';
import { getDeleteKeys, tagifyElement } from '../../helpers/utils.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
@ -249,7 +248,10 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
? {
...multiclassItem.toObject(),
domain: checkbox.secondaryData.domain
? game.i18n.localize(domains[checkbox.secondaryData.domain].label)
? game.i18n.localize(
CONFIG.DH.DOMAIN.allDomains()[checkbox.secondaryData.domain]
.label
)
: null,
subclass: subclass ? subclass.name : null
}
@ -353,10 +355,10 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
experienceIncreaseTagify,
Object.keys(this.actor.system.experiences).reduce((acc, id) => {
const experience = this.actor.system.experiences[id];
acc[id] = { label: experience.name };
acc.push({ id: id, label: experience.name });
return acc;
}, {}),
}, []),
this.tagifyUpdate('experience').bind(this)
);
}

View file

@ -83,7 +83,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
return context;
}
static async updateData(event, element, formData) {
static async updateData(_event, _element, formData) {
const updatedSettings = foundry.utils.expandObject(formData.object);
await this.settings.updateSource({
@ -199,7 +199,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
this.render();
}
static async addDomain(_, target) {
static async addDomain() {
const id = foundry.utils.randomID();
this.settings.updateSource({
[`domains.${id}`]: {
@ -219,6 +219,40 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
}
static async deleteDomain() {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.domains.deleteDomain')
},
content: game.i18n.format('DAGGERHEART.SETTINGS.Homebrew.domains.deleteDomainText', {
name: this.settings.domains[this.selected.domain].label
})
});
if (!confirmed) return;
const updateClasses = game.items.filter(
x => x.type === 'class' && x.system.domains.includes(this.selected.domain)
);
for (let actor of game.actors) {
updateClasses.push(
...actor.items.filter(x => x.type === 'class' && x.system.domains.includes(this.selected.domain))
);
}
for (let c of updateClasses) {
const newDomains = c.system.domains.map(x =>
x === this.selected.domain ? CONFIG.DH.DOMAIN.domains.arcana.id : x
);
await c.update({ 'system.domains': newDomains });
}
const updateDomainCards = game.items.filter(
x => x.type === 'domainCard' && x.system.domain === this.selected.domain
);
for (let d of updateDomainCards) {
await d.update({ 'system.domain': CONFIG.DH.DOMAIN.domains.arcana.id });
}
await this.settings.updateSource({
[`domains.-=${this.selected.domain}`]: null
});

View file

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

View file

@ -34,4 +34,12 @@ export default class DomainCardSheet extends DHBaseItemSheet {
scrollable: ['.effects']
}
};
async _prepareContext(options) {
const context = await super._prepareContext(options);
context.domain = CONFIG.DH.DOMAIN.allDomains()[this.document.system.domain];
context.domainChoices = CONFIG.DH.DOMAIN.orderedDomains();
return context;
}
}

View file

@ -219,7 +219,7 @@ export default class FilterMenu extends foundry.applications.ux.ContextMenu {
}
}));
const domainFilter = Object.values(CONFIG.DH.DOMAIN.domains).map(({ id, label }) => ({
const domainFilter = Object.values(CONFIG.DH.DOMAIN.allDomains()).map(({ id, label }) => ({
group: game.i18n.localize('DAGGERHEART.GENERAL.Domain.single'),
name: game.i18n.localize(label),
filter: {