diff --git a/lang/en.json b/lang/en.json index 81cb2d49..14292e5b 100755 --- a/lang/en.json +++ b/lang/en.json @@ -1080,6 +1080,9 @@ "hint": "The number of extra Long Rest Moves the character can take during a Long Rest." } } + }, + "maxLoadout": { + "label": "Max Loadout Cards Bonus" } }, "Character": { @@ -1516,7 +1519,8 @@ "resetMovesText": "Are you sure you want to reset?", "FIELDS": { "maxFear": { "label": "Max Fear" }, - "traitArray": { "label": "Initial Trait Modifiers" } + "traitArray": { "label": "Initial Trait Modifiers" }, + "maxLoadout": { "label": "Max Cards in Loadout" } }, "currency": { "enabled": "Enable Overrides", @@ -1687,7 +1691,8 @@ "beastformMissingEffect": "The Beastform is missing a Beastform Effect. Cannot be used.", "beastformToManyAdvantages": "You cannot select any more advantages.", "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": { "disableEffect": "Disable Effect", diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index 9d5f6a45..31755bca 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -259,7 +259,12 @@ export default class CharacterSheet extends DHBaseActorSheet { name: 'toLoadout', icon: 'fa-solid fa-arrow-up', 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', @@ -729,7 +734,7 @@ export default class CharacterSheet extends DHBaseActorSheet { const item = await Item.implementation.fromDropData(data); 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; } diff --git a/module/applications/sheets/api/application-mixin.mjs b/module/applications/sheets/api/application-mixin.mjs index 7267ff2b..51328c8d 100644 --- a/module/applications/sheets/api/application-mixin.mjs +++ b/module/applications/sheets/api/application-mixin.mjs @@ -310,6 +310,10 @@ export default function DHApplicationMixin(Base) { options.unshift({ name: 'DAGGERHEART.APPLICATIONS.ContextMenu.useItem', 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) }); diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index c0306afa..3348ca59 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -202,6 +202,11 @@ export default class DhCharacter extends BaseDataActor { 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 }), @@ -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() { return this.parent.items.find(x => x.type === 'armor' && x.system.equipped); } diff --git a/module/data/settings/Homebrew.mjs b/module/data/settings/Homebrew.mjs index 5619898e..29da1aa0 100644 --- a/module/data/settings/Homebrew.mjs +++ b/module/data/settings/Homebrew.mjs @@ -14,6 +14,13 @@ export default class DhHomebrew extends foundry.abstract.DataModel { initial: 12, 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 }), { initial: () => [2, 1, 1, 0, 0, -1] }), diff --git a/templates/settings/homebrew-settings.hbs b/templates/settings/homebrew-settings.hbs index ada2c7a9..6bfcbb9c 100644 --- a/templates/settings/homebrew-settings.hbs +++ b/templates/settings/homebrew-settings.hbs @@ -3,6 +3,7 @@