Max Cards loadout switch & Homebrew setting (#412)

* Max Cards loadout switch & Homebrew setting

* Fixes

* Fixes
This commit is contained in:
Dapoulp 2025-07-26 00:50:39 +02:00 committed by GitHub
parent 2a4777f1a0
commit dddee78356
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 42 additions and 4 deletions

View file

@ -1080,6 +1080,9 @@
"hint": "The number of extra Long Rest Moves the character can take during a Long Rest." "hint": "The number of extra Long Rest Moves the character can take during a Long Rest."
} }
} }
},
"maxLoadout": {
"label": "Max Loadout Cards Bonus"
} }
}, },
"Character": { "Character": {
@ -1516,7 +1519,8 @@
"resetMovesText": "Are you sure you want to reset?", "resetMovesText": "Are you sure you want to reset?",
"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" }
}, },
"currency": { "currency": {
"enabled": "Enable Overrides", "enabled": "Enable Overrides",
@ -1687,7 +1691,8 @@
"beastformMissingEffect": "The Beastform is missing a Beastform Effect. Cannot be used.", "beastformMissingEffect": "The Beastform is missing a Beastform Effect. Cannot be used.",
"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 already have {max} cards in your loadout. Move atleast one to your vault before adding a new one."
}, },
"Tooltip": { "Tooltip": {
"disableEffect": "Disable Effect", "disableEffect": "Disable Effect",

View file

@ -259,7 +259,12 @@ export default class CharacterSheet extends DHBaseActorSheet {
name: 'toLoadout', name: 'toLoadout',
icon: 'fa-solid fa-arrow-up', icon: 'fa-solid fa-arrow-up',
condition: target => getDocFromElement(target).system.inVault, condition: target => getDocFromElement(target).system.inVault,
callback: target => getDocFromElement(target).update({ 'system.inVault': false }) callback: target => {
const doc = getDocFromElement(target),
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 }))
}
}, },
{ {
name: 'toVault', name: 'toVault',
@ -729,7 +734,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
const item = await Item.implementation.fromDropData(data); const item = await Item.implementation.fromDropData(data);
const itemData = item.toObject(); const itemData = item.toObject();
if (item.type === 'domainCard' && this.document.system.domainCards.loadout.length >= 5) { if (item.type === 'domainCard' && !this.document.system.loadoutSlot.available) {
itemData.system.inVault = true; itemData.system.inVault = true;
} }

View file

@ -310,6 +310,10 @@ export default function DHApplicationMixin(Base) {
options.unshift({ options.unshift({
name: 'DAGGERHEART.APPLICATIONS.ContextMenu.useItem', name: 'DAGGERHEART.APPLICATIONS.ContextMenu.useItem',
icon: 'fa-solid fa-burst', icon: 'fa-solid fa-burst',
condition: target => {
const doc = getDocFromElement(target);
return !(doc.type === 'domainCard' && doc.system.inVault)
},
callback: (target, event) => getDocFromElement(target).use(event) callback: (target, event) => getDocFromElement(target).use(event)
}); });

View file

@ -202,6 +202,11 @@ export default class DhCharacter extends BaseDataActor {
hint: 'DAGGERHEART.GENERAL.Bonuses.rest.longRest.longRestMoves.hint' hint: 'DAGGERHEART.GENERAL.Bonuses.rest.longRest.longRestMoves.hint'
}) })
}) })
}),
maxLoadout : new fields.NumberField({
integer: true,
initial: 0,
label: 'DAGGERHEART.GENERAL.Bonuses.maxLoadout.label'
}) })
}), }),
companion: new ForeignDocumentUUIDField({ type: 'Actor', nullable: true, initial: null }), companion: new ForeignDocumentUUIDField({ type: 'Actor', nullable: true, initial: null }),
@ -321,6 +326,17 @@ 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;
return {
current: loadoutCount,
available: Math.max(max - loadoutCount, 0),
max
}
}
get armor() { get armor() {
return this.parent.items.find(x => x.type === 'armor' && x.system.equipped); return this.parent.items.find(x => x.type === 'armor' && x.system.equipped);
} }

View file

@ -14,6 +14,13 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
initial: 12, initial: 12,
label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.maxFear.label' label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.maxFear.label'
}), }),
maxLoadout: new fields.NumberField({
required: true,
integer: true,
min: 0,
initial: 5,
label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.maxLoadout.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

@ -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.maxLoadout value=settingFields._source.maxLoadout localize=true}}
<h4>{{localize "DAGGERHEART.SETTINGS.Homebrew.FIELDS.traitArray.label"}}</h4> <h4>{{localize "DAGGERHEART.SETTINGS.Homebrew.FIELDS.traitArray.label"}}</h4>
<div class="trait-array-container"> <div class="trait-array-container">