Added Homebrew maxDomains

This commit is contained in:
WBHarry 2025-08-02 21:05:33 +02:00
parent 397053dcb3
commit c340f084b3
6 changed files with 29 additions and 5 deletions

View file

@ -2086,7 +2086,11 @@
"FIELDS": { "FIELDS": {
"maxFear": { "label": "Max Fear" }, "maxFear": { "label": "Max Fear" },
"traitArray": { "label": "Initial Trait Modifiers" }, "traitArray": { "label": "Initial Trait Modifiers" },
"maxLoadout": { "label": "Max Cards in Loadout", "hint": "Set to blank or 0 for unlimited maximum" } "maxLoadout": {
"label": "Max Cards in Loadout",
"hint": "Set to blank or 0 for unlimited maximum"
},
"maxDomains": { "label": "Max Class Domains", "hint": "Max domains you can set on a class" }
}, },
"currency": { "currency": {
"enabled": "Enable Overrides", "enabled": "Enable Overrides",
@ -2276,7 +2280,8 @@
"beastformToManyAdvantages": "You cannot select any more advantages.", "beastformToManyAdvantages": "You cannot select any more advantages.",
"beastformToManyFeatures": "You cannot select any more features.", "beastformToManyFeatures": "You cannot select any more features.",
"beastformEquipWeapon": "You cannot use weapons while in a Beastform.", "beastformEquipWeapon": "You cannot use weapons while in a Beastform.",
"loadoutMaxReached": "You've reached maximum loadout. Move atleast one domain card to the vault.", "loadoutMaxReached": "You've reached maximum loadout. Move atleast one domain card to the vault, or increase the limit in homebrew settings if desired.",
"domainMaxReached": "You've reached the maximum domains for the class. Increase the limit in homebrew settings if desired.",
"insufficientResources": "You have insufficient resources", "insufficientResources": "You have insufficient resources",
"multiclassAlreadyPresent": "You already have a class and multiclass", "multiclassAlreadyPresent": "You already have a class and multiclass",
"subclassesAlreadyPresent": "You already have a class and multiclass subclass" "subclassesAlreadyPresent": "You already have a class and multiclass subclass"

View file

@ -15,7 +15,10 @@ export default class ClassSheet extends DHBaseItemSheet {
{ {
selector: '.domain-input', selector: '.domain-input',
options: () => CONFIG.DH.DOMAIN.domains, 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: [ dragDrop: [

View file

@ -19,7 +19,7 @@ export default class DHClass extends BaseDataItem {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {
...super.defineSchema(), ...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 }), classItems: new ForeignDocumentUUIDArrayField({ type: 'Item', required: false }),
hitPoints: new fields.NumberField({ hitPoints: new fields.NumberField({
required: true, required: true,
@ -123,6 +123,14 @@ export default class DHClass extends BaseDataItem {
const allowed = await super._preUpdate(changed, options, userId); const allowed = await super._preUpdate(changed, options, userId);
if (allowed === false) return false; 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 = [ const paths = [
'subclasses', 'subclasses',
'characterGuide.suggestedPrimaryWeapon', 'characterGuide.suggestedPrimaryWeapon',

View file

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

View file

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

View file

@ -3,6 +3,7 @@
<h1>{{localize 'DAGGERHEART.SETTINGS.Menu.homebrew.name'}}</h1> <h1>{{localize 'DAGGERHEART.SETTINGS.Menu.homebrew.name'}}</h1>
</header> </header>
{{formGroup settingFields.schema.fields.maxFear value=settingFields._source.maxFear localize=true}} {{formGroup settingFields.schema.fields.maxFear value=settingFields._source.maxFear localize=true}}
{{formGroup settingFields.schema.fields.maxDomains value=settingFields._source.maxDomains localize=true}}
{{formGroup settingFields.schema.fields.maxLoadout value=settingFields._source.maxLoadout localize=true}} {{formGroup settingFields.schema.fields.maxLoadout value=settingFields._source.maxLoadout localize=true}}
<div class="settings-hint"><label>{{localize "DAGGERHEART.SETTINGS.Homebrew.FIELDS.maxLoadout.hint"}}</label></div> <div class="settings-hint"><label>{{localize "DAGGERHEART.SETTINGS.Homebrew.FIELDS.maxLoadout.hint"}}</label></div>