diff --git a/lang/en.json b/lang/en.json index 10b7a9b0..d7d1ce64 100644 --- a/lang/en.json +++ b/lang/en.json @@ -94,7 +94,9 @@ "LacksDomain": "Your character doesn't have the domain of the card!", "MaxLoadoutReached": "You can't have any more domain cards at this level!", "DuplicateDomainCard": "You already have a domain card with that name!", - "ActionRequiresTarget": "The action requires at least one target" + "ActionRequiresTarget": "The action requires at least one target", + "TwoHandedWeaponEquipped": "You have a two-handed weapon equipped", + "SecondaryWeaponEquipped": "You have a secondary weapon equipped" } }, "General": { @@ -843,9 +845,10 @@ "InventoryWeapon": "Inventory Weapon" }, "InventoryTab": { - "EquipmentTitle": "Equipment", "ConsumableTitle": "Consumables", "MiscellaneousTitle": "Miscellaneous", + "WeaponsTitle": "Weapons", + "ArmorsTitle": "Armors", "QuantityTitle": "Quantity" }, "Weapons": { diff --git a/module/applications/sheets/pc.mjs b/module/applications/sheets/pc.mjs index 72fb3fc7..192b22dc 100644 --- a/module/applications/sheets/pc.mjs +++ b/module/applications/sheets/pc.mjs @@ -48,8 +48,6 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { useFeature: this.useFeature, takeShortRest: this.takeShortRest, takeLongRest: this.takeLongRest, - removeActiveItem: this.removeActiveItem, - removeInventoryWeapon: this.removeInventoryWeapon, addMiscItem: this.addMiscItem, deleteItem: this.deleteItem, addScar: this.addScar, @@ -63,18 +61,12 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { useAbility: this.useAbility, useAdvancementCard: this.useAdvancementCard, useAdvancementAbility: this.useAdvancementAbility, - selectFeatureSet: this.selectFeatureSet + selectFeatureSet: this.selectFeatureSet, + toggleEquipItem: this.toggleEquipItem }, window: { - //frame: boolean; - //positioned: boolean; - //title: string; - //icon: string | false; - //controls: ApplicationHeaderControlsEntry[]; minimizable: false, resizable: true - //contentTag: string; - //contentClasses: string[]; }, form: { handler: this.updateForm, @@ -280,6 +272,20 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { quantity: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.QuantityTitle') }, items: this.document.items.filter(x => x.type === 'miscellaneous') + }, + weapons: { + titles: { + name: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.WeaponsTitle'), + quantity: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.QuantityTitle') + }, + items: this.document.items.filter(x => x.type === 'weapon') + }, + armor: { + titles: { + name: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.ArmorsTitle'), + quantity: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.QuantityTitle') + }, + items: this.document.items.filter(x => x.type === 'armor') } }; @@ -690,7 +696,7 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { (await game.packs.get('daggerheart.playtest-communities'))?.render(true); } - static async viewObject(button) { + static async viewObject(_, button) { const object = await fromUuid(button.dataset.value); if (!object) return; @@ -712,18 +718,6 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { await this.minimize(); } - static async removeActiveItem(_, event) { - event.stopPropagation(); - const item = await fromUuid(event.currentTarget.dataset.item); - await item.delete(); - } - - static async removeInventoryWeapon(_, event) { - event.stopPropagation(); - const item = await fromUuid(event.currentTarget.dataset.item); - await item.delete(); - } - static async addMiscItem() { const result = await this.document.createEmbeddedDocuments('Item', [ { @@ -941,6 +935,57 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { this.render(); } + static async toggleEquipItem(_, button) { + const item = this.document.items.get(button.id); + if (item.system.equipped) { + await item.update({ 'system.equipped': false }); + return; + } + + switch (item.type) { + case 'armor': + const currentArmor = this.document.system.armor; + if (currentArmor) { + await currentArmor.update({ 'system.equipped': false }); + } + + await item.update({ 'system.equipped': true }); + break; + case 'weapon': + const currentWeapons = this.document.system.equippedWeapons; + if (item.system.secondary) { + if ( + currentWeapons.primary && + currentWeapons.primary.burden === SYSTEM.GENERAL.burden.twoHanded.value + ) { + ui.notifications.error( + game.i18n.localize('DAGGERHEART.Notification.Error.TwoHandedWeaponEquipped') + ); + return; + } + + if (currentWeapons.secondary) { + await this.document.items.get(currentWeapons.secondary.id).update({ 'system.equipped': false }); + } + } else { + if (currentWeapons.secondary && item.system.burden === SYSTEM.GENERAL.burden.twoHanded.value) { + ui.notifications.error( + game.i18n.localize('DAGGERHEART.Notification.Error.SecondaryWeaponEquipped') + ); + return; + } + + if (currentWeapons.primary) { + await this.document.items.get(currentWeapons.primary.id).update({ 'system.equipped': false }); + } + } + + await item.update({ 'system.equipped': true }); + break; + } + this.render(); + } + static async close(options) { this.onVaultTab = false; super.close(options); @@ -984,14 +1029,17 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { const itemObject = await fromUuid(item.uuid); switch (target) { case 'weapon-section': - if (itemObject.system.secondary && this.document.system.activeWeapons.burden === 'twoHanded') { + if ( + itemObject.system.secondary && + this.document.system.equippedWeapons.burden === 'twoHanded' + ) { ui.notifications.info( game.i18n.localize('DAGGERHEART.Notification.Info.SecondaryEquipWhileTwohanded') ); return; } else if ( itemObject.system.burden === 'twoHanded' && - this.document.system.activeWeapons.secondary + this.document.system.equippedWeapons.secondary ) { ui.notifications.info( game.i18n.localize('DAGGERHEART.Notification.Info.TwohandedEquipWhileSecondary') @@ -1160,12 +1208,18 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { if (!element) return; if (element.classList.contains('weapon-section')) { - if (item.system.secondary && this.document.system.activeWeapons.burden === 'twoHanded') { + if ( + item.system.secondary && + this.document.system.equippedWeapons.burden === SYSTEM.GENERAL.burden.twoHanded.value + ) { ui.notifications.info( game.i18n.localize('DAGGERHEART.Notification.Info.SecondaryEquipWhileTwohanded') ); return; - } else if (item.system.burden === 'twoHanded' && this.document.system.activeWeapons.secondary) { + } else if ( + item.system.burden === SYSTEM.GENERAL.burden.twoHanded.value && + this.document.system.equippedWeapons.secondary + ) { ui.notifications.info( game.i18n.localize('DAGGERHEART.Notification.Info.TwohandedEquipWhileSecondary') ); @@ -1173,10 +1227,10 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { } const existing = - this.document.system.activeWeapons.primary && !item.system.secondary - ? await fromUuid(this.document.system.activeWeapons.primary.uuid) - : this.document.system.activeWeapons.secondary && item.system.secondary - ? await fromUuid(this.document.system.activeWeapons.secondary.uuid) + this.document.system.equippedWeapons.primary && !item.system.secondary + ? await fromUuid(this.document.system.equippedWeapons.primary.uuid) + : this.document.system.equippedWeapons.secondary && item.system.secondary + ? await fromUuid(this.document.system.equippedWeapons.secondary.uuid) : null; await existing?.delete(); itemData.system.active = true; @@ -1194,7 +1248,7 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { await existing?.delete(); itemData.system.inventoryWeapon = 2; - } else return []; + } } if (item.type === 'armor') { @@ -1205,7 +1259,7 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { ? await fromUuid(this.document.system.armor.uuid) : null; await existing?.delete(); - } else return; + } } const createdItem = await this._onDropItemCreate(itemData); diff --git a/module/config/generalConfig.mjs b/module/config/generalConfig.mjs index b8bac359..90c7e6e6 100644 --- a/module/config/generalConfig.mjs +++ b/module/config/generalConfig.mjs @@ -27,8 +27,14 @@ export const range = { }; export const burden = { - oneHanded: 'DAGGERHEART.Burden.OneHanded', - twoHanded: 'DAGGERHEART.Burden.TwoHanded' + oneHanded: { + value: 'oneHanded', + label: 'DAGGERHEART.Burden.OneHanded' + }, + twoHanded: { + value: 'twoHanded', + label: 'DAGGERHEART.Burden.TwoHanded' + } }; export const damageTypes = { diff --git a/module/data/armor.mjs b/module/data/armor.mjs index d3398e06..dc6cda19 100644 --- a/module/data/armor.mjs +++ b/module/data/armor.mjs @@ -2,6 +2,7 @@ export default class DhpArmor extends foundry.abstract.TypeDataModel { static defineSchema() { const fields = foundry.data.fields; return { + equipped: new fields.BooleanField({ initial: false }), baseScore: new fields.NumberField({ initial: 1, integer: true }), feature: new fields.StringField({ choices: SYSTEM.ITEM.armorFeatures, @@ -16,6 +17,7 @@ export default class DhpArmor extends foundry.abstract.TypeDataModel { major: new fields.NumberField({ initial: 0, integer: true }), severe: new fields.NumberField({ initial: 0, integer: true }) }), + quantity: new fields.NumberField({ initial: 1, integer: true }), description: new fields.HTMLField({}) }; } diff --git a/module/data/pc.mjs b/module/data/pc.mjs index 047520c2..6f6073bd 100644 --- a/module/data/pc.mjs +++ b/module/data/pc.mjs @@ -242,15 +242,15 @@ export default class DhpPC extends foundry.abstract.TypeDataModel { } get armor() { - return this.parent.items.find(x => x.type === 'armor'); + return this.parent.items.find(x => x.type === 'armor' && x.system.equipped); } - get activeWeapons() { + get equippedWeapons() { const primaryWeapon = this.parent.items.find( - x => x.type === 'weapon' && x.system.active && !x.system.secondary + x => x.type === 'weapon' && x.system.equipped && !x.system.secondary ); const secondaryWeapon = this.parent.items.find( - x => x.type === 'weapon' && x.system.active && x.system.secondary + x => x.type === 'weapon' && x.system.equipped && x.system.secondary ); return { primary: this.#weaponData(primaryWeapon), @@ -325,16 +325,19 @@ export default class DhpPC extends foundry.abstract.TypeDataModel { ); } + //Should not be done in data? #weaponData(weapon) { return weapon ? { + id: weapon.id, name: weapon.name, - trait: CONFIG.daggerheart.ACTOR.abilities[weapon.system.trait].name, //Should not be done in data? + trait: game.i18n.localize(CONFIG.daggerheart.ACTOR.abilities[weapon.system.trait].label), range: CONFIG.daggerheart.GENERAL.range[weapon.system.range], damage: { value: weapon.system.damage.value, type: CONFIG.daggerheart.GENERAL.damageTypes[weapon.system.damage.type] }, + burden: weapon.system.burden, feature: CONFIG.daggerheart.ITEM.weaponFeatures[weapon.system.feature], img: weapon.img, uuid: weapon.uuid diff --git a/module/data/weapon.mjs b/module/data/weapon.mjs index 3e9127ca..263a4fb4 100644 --- a/module/data/weapon.mjs +++ b/module/data/weapon.mjs @@ -2,7 +2,7 @@ export default class DhpWeapon extends foundry.abstract.TypeDataModel { static defineSchema() { const fields = foundry.data.fields; return { - active: new fields.BooleanField({ initial: false }), + equipped: new fields.BooleanField({ initial: false }), inventoryWeapon: new fields.NumberField({ initial: null, nullable: true, integer: true }), secondary: new fields.BooleanField({ initial: false }), trait: new fields.StringField({ choices: SYSTEM.ACTOR.abilities, integer: false }), diff --git a/styles/daggerheart.css b/styles/daggerheart.css index e982c973..4f856d8c 100644 --- a/styles/daggerheart.css +++ b/styles/daggerheart.css @@ -1250,7 +1250,7 @@ filter: drop-shadow(0 0 3px gold); } .daggerheart.sheet.pc div[data-application-part] .sheet-body .inventory-container .inventory-item-list .inventory-item .inventory-item-quantity { - width: 48px; + width: 60px; display: flex; align-items: center; } diff --git a/styles/pc.less b/styles/pc.less index a6920304..07a91411 100644 --- a/styles/pc.less +++ b/styles/pc.less @@ -1455,7 +1455,7 @@ } .inventory-item-quantity { - width: 48px; + width: 60px; display: flex; align-items: center; diff --git a/templates/sheets/parts/armor.hbs b/templates/sheets/parts/armor.hbs index 4f12ccc5..28d23944 100644 --- a/templates/sheets/parts/armor.hbs +++ b/templates/sheets/parts/armor.hbs @@ -1,12 +1,6 @@
{{localize "DAGGERHEART.Sheets.PC.Armor.Title"}} - {{#if armor}} -
- - -
- {{/if}}
diff --git a/templates/sheets/parts/inventory.hbs b/templates/sheets/parts/inventory.hbs index 33b9a21f..8e72f848 100644 --- a/templates/sheets/parts/inventory.hbs +++ b/templates/sheets/parts/inventory.hbs @@ -6,12 +6,6 @@

{{localize "DAGGERHEART.Sheets.PC.Inventory.InventoryWeapon"}} - {{#if weapons.first}} -
- - -
- {{/if}}

diff --git a/templates/sheets/parts/weapons.hbs b/templates/sheets/parts/weapons.hbs index d2a8f977..53b63c1c 100644 --- a/templates/sheets/parts/weapons.hbs +++ b/templates/sheets/parts/weapons.hbs @@ -20,37 +20,29 @@

{{localize "DAGGERHEART.Sheets.PC.Weapons.PrimaryTitle"}} {{#if weapons.primary}} -
- - -
{{/if}}

- +
- +

{{localize "DAGGERHEART.Sheets.PC.Weapons.SecondaryTitle"}} {{#if weapons.secondary}} -
- - -
{{/if}}

- - + +
diff --git a/templates/sheets/pc/pc.hbs b/templates/sheets/pc/pc.hbs index 0de09cd2..53cb0501 100644 --- a/templates/sheets/pc/pc.hbs +++ b/templates/sheets/pc/pc.hbs @@ -88,7 +88,7 @@
{{> "systems/daggerheart/templates/sheets/parts/attributes.hbs" }} - {{> "systems/daggerheart/templates/sheets/parts/weapons.hbs" weapons=document.system.activeWeapons proficiency=document.system.proficiency.value }} + {{> "systems/daggerheart/templates/sheets/parts/weapons.hbs" weapons=document.system.equippedWeapons proficiency=document.system.proficiency.value }} {{> "systems/daggerheart/templates/sheets/parts/armor.hbs" armor=document.system.armor }} {{> "systems/daggerheart/templates/sheets/parts/inventory.hbs" weapons=document.system.inventoryWeapons }}
diff --git a/templates/sheets/pc/sections/inventory.hbs b/templates/sheets/pc/sections/inventory.hbs index 4afb6872..6f4aeb49 100644 --- a/templates/sheets/pc/sections/inventory.hbs +++ b/templates/sheets/pc/sections/inventory.hbs @@ -18,6 +18,9 @@ {{item.name}}
+
+ +