0 or blank loadoutSize now means unlimited

This commit is contained in:
WBHarry 2025-08-02 20:42:55 +02:00
parent fb8a1e3ff6
commit 397053dcb3
6 changed files with 44 additions and 13 deletions

View file

@ -2086,7 +2086,7 @@
"FIELDS": {
"maxFear": { "label": "Max Fear" },
"traitArray": { "label": "Initial Trait Modifiers" },
"maxLoadout": { "label": "Max Cards in Loadout" }
"maxLoadout": { "label": "Max Cards in Loadout", "hint": "Set to blank or 0 for unlimited maximum" }
},
"currency": {
"enabled": "Enable Overrides",
@ -2276,7 +2276,7 @@
"beastformToManyAdvantages": "You cannot select any more advantages.",
"beastformToManyFeatures": "You cannot select any more features.",
"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.",
"loadoutMaxReached": "You've reached maximum loadout. Move atleast one domain card to the vault.",
"insufficientResources": "You have insufficient resources",
"multiclassAlreadyPresent": "You already have a class and multiclass",
"subclassesAlreadyPresent": "You already have a class and multiclass subclass"

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

@ -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
};
}

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

@ -126,4 +126,16 @@
}
}
}
.settings-hint {
width: 100%;
display: flex;
justify-content: end;
label {
width: 240px;
font-style: italic;
text-align: center;
}
}
}

View file

@ -4,6 +4,7 @@
</header>
{{formGroup settingFields.schema.fields.maxFear value=settingFields._source.maxFear 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>
<h4>{{localize "DAGGERHEART.SETTINGS.Homebrew.FIELDS.traitArray.label"}}</h4>
<div class="trait-array-container">