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": { "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" } "maxLoadout": { "label": "Max Cards in Loadout", "hint": "Set to blank or 0 for unlimited maximum" }
}, },
"currency": { "currency": {
"enabled": "Enable Overrides", "enabled": "Enable Overrides",
@ -2276,7 +2276,7 @@
"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.", "loadoutMaxReached": "You've reached maximum loadout. Move atleast one domain card to the vault.",
"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

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

View file

@ -362,13 +362,12 @@ export default class DhCharacter extends BaseDataActor {
get loadoutSlot() { get loadoutSlot() {
const loadoutCount = this.domainCards.loadout?.length ?? 0, const loadoutCount = this.domainCards.loadout?.length ?? 0,
max = worldSetting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxLoadout,
game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxLoadout + max = !worldSetting ? null : worldSetting + this.bonuses.maxLoadout;
this.bonuses.maxLoadout;
return { return {
current: loadoutCount, current: loadoutCount,
available: Math.max(max - loadoutCount, 0), available: !max ? true : Math.max(max - loadoutCount, 0),
max max
}; };
} }

View file

@ -318,8 +318,16 @@ export default class DhpActor extends Actor {
for (var domainCard of domainCards) { for (var domainCard of domainCards) {
if (levelupAuto) { if (levelupAuto) {
const item = await foundry.utils.fromUuid(domainCard.data[0]); const itemData = (await foundry.utils.fromUuid(domainCard.data[0])).toObject();
const embeddedItem = await this.createEmbeddedDocuments('Item', [item.toObject()]); const embeddedItem = await this.createEmbeddedDocuments('Item', [
{
...itemData,
system: {
...itemData.system,
inVault: true
}
}
]);
selections.push({ ...domainCard, itemUuid: embeddedItem[0].uuid }); selections.push({ ...domainCard, itemUuid: embeddedItem[0].uuid });
} else { } else {
selections.push({ ...domainCard }); selections.push({ ...domainCard });
@ -329,8 +337,16 @@ export default class DhpActor extends Actor {
const achievementDomainCards = []; const achievementDomainCards = [];
if (levelupAuto) { if (levelupAuto) {
for (var card of Object.values(level.achievements.domainCards)) { for (var card of Object.values(level.achievements.domainCards)) {
const item = await foundry.utils.fromUuid(card.uuid); const itemData = (await foundry.utils.fromUuid(card.uuid)).toObject();
const embeddedItem = await this.createEmbeddedDocuments('Item', [item.toObject()]); const embeddedItem = await this.createEmbeddedDocuments('Item', [
{
...itemData,
system: {
...itemData.system,
inVault: true
}
}
]);
card.itemUuid = embeddedItem[0].uuid; card.itemUuid = embeddedItem[0].uuid;
achievementDomainCards.push(card); 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> </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}} {{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> <h4>{{localize "DAGGERHEART.SETTINGS.Homebrew.FIELDS.traitArray.label"}}</h4>
<div class="trait-array-container"> <div class="trait-array-container">