Review Inventory (#55)

* Weapons and Armor are now stored like any other item on the PC. Added equip/unequip logic.

* Changed so that equip attempts always go through and the neccessary weapons are unequipped to fascilitate it

* Fixed drag equip and extracted unequipBeforeEquip logic
This commit is contained in:
WBHarry 2025-05-26 15:43:04 +02:00 committed by GitHub
parent d36520438a
commit cf51153432
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 106 additions and 143 deletions

View file

@ -1,12 +1,6 @@
<fieldset class="left-main-container armor-section active-item-section item-section">
<legend class="legend armor-container">
<span>{{localize "DAGGERHEART.Sheets.PC.Armor.Title"}}</span>
{{#if armor}}
<div data-action="viewObject" data-value="{{armor.uuid}}" class="active-item-label-chip">
<img src="{{armor.img}}" />
<button data-action="removeActiveItem" data-item="{{armor.uuid}}"><i class="fa-solid fa-x"></i></button>
</div>
{{/if}}
</legend>
<div class="active-item-container">

View file

@ -1,47 +0,0 @@
<fieldset class="left-main-container" style="flex: 1; display: flex; flex-direction: column;">
<legend class="legend inventory-legend">
{{localize "DAGGERHEART.Sheets.PC.Inventory.Title"}}
</legend>
<div class="inventory-items">
<div class="inventory-weapon-section-first item-section">
<h2 class="armor-container">
{{localize "DAGGERHEART.Sheets.PC.Inventory.InventoryWeapon"}}
{{#if weapons.first}}
<div data-action="viewObject" data-value="{{weapons.first.uuid}}" class="active-item-label-chip">
<img src="{{weapons.first.img}}" />
<button data-action="removeInventoryWeapon" data-item="{{weapons.first.uuid}}"><i class="fa-solid fa-x"></i></button>
</div>
{{/if}}
</h2>
<div class="active-item-container">
<div class="flexrow">
<input value="{{weapons.first.name}}" type="text" />
<input value="{{localize weapons.first.trait}}" type="text" />
<input value="{{localize weapons.first.range.name}}" type="text" />
<input value="{{weapons.first.damage.value}} {{#if weapons.first}}({{localize weapons.first.damage.type.abbreviation}}){{/if}}" type="text" />
</div>
<input value="{{localize weapons.first.feature.name}} {{#if weapons.first.feature}}({{localize weapons.first.feature.description}}){{/if}}" type="text" />
</div>
</div>
<div class="inventory-weapon-section-second item-section">
<h2 class="armor-container">
{{localize "DAGGERHEART.Sheets.PC.Inventory.InventoryWeapon"}}
{{#if weapons.second}}
<div data-action="viewObject" data-value="{{weapons.second.uuid}}" class="active-item-label-chip">
<img src="{{weapons.second.img}}" />
<button data-action="removeInventoryWeapon" data-item="{{weapons.second.uuid}}"><i class="fa-solid fa-x"></i></button>
</div>
{{/if}}
</h2>
<div class="active-item-container">
<div class="flexrow">
<input value="{{weapons.second.name}}" type="text" />
<input value="{{localize weapons.second.trait}}" type="text" />
<input value="{{localize weapons.second.range.name}}" type="text" />
<input value="{{weapons.second.damage.value}} {{#if weapons.second}}({{localize weapons.second.damage.type.abbreviation}}){{/if}}" type="text" />
</div>
<input value="{{localize weapons.second.feature.name}} {{#if weapons.second.feature}}({{localize weapons.second.feature.description}}){{/if}}" type="text" />
</div>
</div>
</div>
</fieldset>

View file

@ -20,37 +20,29 @@
<h2 class="weapons-label-row">
{{localize "DAGGERHEART.Sheets.PC.Weapons.PrimaryTitle"}}
{{#if weapons.primary}}
<div data-action="viewObject" data-value="{{weapons.primary.uuid}}" class="active-item-label-chip">
<img src="{{weapons.primary.img}}" />
<button data-action="removeActiveItem" data-item="{{weapons.primary.uuid}}"><i class="fa-solid fa-x"></i></button>
</div>
<img class="damage-roll" data-action="attackRoll" data-weapon="{{weapons.primary.uuid}}" src="icons/svg/d12-grey.svg" />
{{/if}}
</h2>
<div class="flexrow">
<input value="{{weapons.primary.name}}" type="text" />
<input value="{{localize weapons.primary.trait}}" type="text" />
<input value="{{localize weapons.primary.range.name}}" type="text" />
<input value="{{localize weapons.primary.range.label}}" type="text" />
<input value="{{weapons.primary.damage.value}} {{#if weapons.primary}}({{localize weapons.primary.damage.type.abbreviation}}){{/if}}" type="text" />
</div>
<input value="{{localize weapons.primary.feature.name}} {{#if weapons.primary.feature}}({{localize weapons.primary.feature.description}}){{/if}}" type="text" />
<input value="{{localize weapons.primary.feature.label}} {{#if weapons.primary.feature}}({{localize weapons.primary.feature.description}}){{/if}}" type="text" />
</div>
<div class="active-item-container">
<h2 class="weapons-label-row">
{{localize "DAGGERHEART.Sheets.PC.Weapons.SecondaryTitle"}}
{{#if weapons.secondary}}
<div data-action="viewObject" data-value="{{weapons.secondary.uuid}}" class="active-item-label-chip">
<img src="{{weapons.secondary.img}}" />
<button data-action="removeActiveItem" data-item="{{weapons.secondary.uuid}}"><i class="fa-solid fa-x"></i></button>
</div>
<img class="damage-roll" data-action="damageRoll" data-value="{{weapons.secondary.damage.value}}" src="icons/svg/d12-grey.svg" />
{{/if}}
</h2>
<div class="flexrow">
<input value="{{weapons.secondary.name}}" type="text" />
<input value="{{localize weapons.secondary.trait}}" type="text" />
<input value="{{localize weapons.secondary.range.name}}" type="text" />
<input value="{{weapons.secondary.damage.value}} {{#if weapons.secondary}}({{localize weapons.secondary.damage.type.abbreviation}}){{/if}}" type="text" />
<input value="{{localize weapons.secondary.range.label}}" type="text" />
<input value="{{weapons.secondary.damage.label}} {{#if weapons.secondary}}({{localize weapons.secondary.damage.type.abbreviation}}){{/if}}" type="text" />
</div>
<input value="{{localize weapons.secondary.feature.name}} {{#if weapons.secondary.feature}}({{localize weapons.secondary.feature.description}}){{/if}}" style="text-overflow: ellipsis;" type="text" />
</div>

View file

@ -88,9 +88,8 @@
</div>
<div class="body-section flex3">
{{> "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 }}
</div>
</div>
</div>

View file

@ -18,6 +18,9 @@
{{item.name}}
</div>
</div>
<div class="flexrow">
<button data-action="toggleEquipItem" id="{{item.id}}">{{localize "Equip"}}</button>
</div>
<div class="inventory-item-quantity spaced">
<i data-action="itemQuantityDecrease" class="fa-solid fa-chevron-left icon-button {{#if (lte item.system.quantity 1)}}disabled{{/if}}"></i>
<input type="text" data-item="system.quantity" value="{{item.system.quantity}}" data-dtype="Number" />