{{!--
SPDX-FileCopyrightText: 2021 Johannes Loher
SPDX-FileCopyrightText: 2021 Gesina Schwalbe
SPDX-FileCopyrightText: 2021 Siegfried Krug

SPDX-License-Identifier: MIT
--}}

{{!-- WEAPONS --}}
<h4 class="ds4-embedded-document-list-title">{{localize 'DS4.ItemTypeWeaponPlural'}}</h4>
{{#unless (isEmpty itemsByType.weapon)}}
<ol class="ds4-embedded-document-list ds4-embedded-document-list--weapon item-list">
    {{#> systems/ds4/templates/sheets/actor/components/item-list-header.hbs isEquipable=true hasQuantity=true
    type='weapon'}}
    {{!-- attack type --}}
    <div class="ds4-embedded-document-list__clickable sort-items" data-data-path="system.attackType"
        title="{{localize 'DS4.SortByAttackType'}}">
        {{localize
        'DS4.AttackTypeAbbr'}}</div>

    {{!-- weapon bonus --}}
    <div class="ds4-embedded-document-list__clickable sort-items" data-data-path="system.weaponBonus"
        title="{{localize 'DS4.SortByWeaponBonus'}}">
        {{localize 'DS4.WeaponBonusAbbr'}}
    </div>

    {{!-- opponent defense --}}
    <div class="ds4-embedded-document-list__clickable sort-items" data-data-path="system.opponentDefense"
        title="{{localize 'DS4.SortByOpponentDefense'}}">
        {{localize 'DS4.OpponentDefenseAbbr'}}
    </div>
    {{/systems/ds4/templates/sheets/actor/components/item-list-header.hbs}}

    {{#each itemsByType.weapon as |itemData id|}}
    {{#> systems/ds4/templates/sheets/actor/components/item-list-entry.hbs itemData=itemData isEquipable=true
    hasQuantity=true}}
    {{!-- attack type --}}
    <img class="ds4-embedded-document-list__image"
        src="{{lookup @root/config.icons.attackTypes itemData.system.attackType}}"
        title="{{lookup @root/config.i18n.attackTypes itemData.system.attackType}}" />

    {{!-- weapon bonus --}}
    <div>{{ itemData.system.weaponBonus}}</div>

    {{!-- opponent defense --}}
    <div>
        {{#if itemData.system.opponentDefenseForAttackType.melee includeZero=true}}
        {{#if itemData.system.opponentDefenseForAttackType.ranged includeZero=true}}
        <span
            title="{{localize 'DS4.OpponentDefenseMelee'}}">{{itemData.system.opponentDefenseForAttackType.melee}}</span>/<span
            title="{{localize 'DS4.OpponentDefenseRanged'}}">{{itemData.system.opponentDefenseForAttackType.ranged}}</span>
        {{else}}
        {{itemData.system.opponentDefenseForAttackType.melee}}
        {{/if}}
        {{else}}
        {{itemData.system.opponentDefenseForAttackType.ranged}}
        {{/if}}
    </div>
    {{/systems/ds4/templates/sheets/actor/components/item-list-entry.hbs}}
    {{/each}}
</ol>
{{/unless}}
{{> systems/ds4/templates/sheets/shared/components/add-button.hbs title='DS4.UserInteractionAddItemTitle'
documentType='item' type='weapon'}}

{{!-- ARMOR --}}
<h4 class="ds4-embedded-document-list-title">{{localize 'DS4.ItemTypeArmorPlural'}}</h4>
{{#unless (isEmpty itemsByType.armor)}}
<ol class="ds4-embedded-document-list ds4-embedded-document-list--armor item-list">
    {{#> systems/ds4/templates/sheets/actor/components/item-list-header.hbs isEquipable=true hasQuantity=true
    type="armor"}}
    {{!-- armor material type --}}
    <div class="ds4-embedded-document-list__clickable sort-items" data-data-path="system.armorMaterialType"
        title="{{localize 'DS4.SortByArmorMaterialType'}}">{{localize 'DS4.ArmorMaterialTypeAbbr'}}</div>

    {{!-- armor type --}}
    <div class="ds4-embedded-document-list__clickable sort-items" data-data-path="system.armorType"
        title="{{localize 'DS4.SortByArmorType'}}">{{localize 'DS4.ArmorTypeAbbr'}}</div>

    {{!-- armor value --}}
    <div class="ds4-embedded-document-list__clickable sort-items" data-data-path="system.armorValue"
        title="{{localize 'DS4.SortByArmorValue'}}">
        {{localize 'DS4.ArmorValueAbbr'}}
    </div>
    {{/systems/ds4/templates/sheets/actor/components/item-list-header.hbs}}

    {{#each itemsByType.armor as |itemData id|}}
    {{#> systems/ds4/templates/sheets/actor/components/item-list-entry.hbs itemData=itemData isEquipable=true
    hasQuantity=true}}
    {{!-- armor material type --}}
    <div title="{{lookup @root/config.i18n.armorMaterialTypes  itemData.system.armorMaterialType}}">
        {{lookup @root/config.i18n.armorMaterialTypesAbbr itemData.system.armorMaterialType}}
    </div>

    {{!-- armor type --}}
    <div title="{{lookup @root/config.i18n.armorTypes itemData.system.armorType}}">
        {{lookup @root/config.i18n.armorTypesAbbr itemData.system.armorType}}
    </div>

    {{!-- armor value --}}
    <div>{{ itemData.system.armorValue}}</div>
    {{/systems/ds4/templates/sheets/actor/components/item-list-entry.hbs}}
    {{/each}}
</ol>
{{/unless}}
{{> systems/ds4/templates/sheets/shared/components/add-button.hbs title='DS4.UserInteractionAddItemTitle'
documentType='item' type='armor'}}

{{!-- SHIELD --}}
<h4 class="ds4-embedded-document-list-title">{{localize 'DS4.ItemTypeShieldPlural'}}</h4>
{{#unless (isEmpty itemsByType.shield)}}
<ol class="ds4-embedded-document-list ds4-embedded-document-list--shield item-list">
    {{#> systems/ds4/templates/sheets/actor/components/item-list-header.hbs isEquipable=true hasQuantity=true
    type='shield'}}
    {{!-- armor value --}}
    <div class="ds4-embedded-document-list__clickable sort-items" data-data-path="system.armorValue"
        title="{{localize 'DS4.SortByArmorValue'}}">
        {{localize 'DS4.ArmorValueAbbr'}}
    </div>
    {{/systems/ds4/templates/sheets/actor/components/item-list-header.hbs}}
    {{#each itemsByType.shield as |itemData id|}}
    {{#> systems/ds4/templates/sheets/actor/components/item-list-entry.hbs itemData=itemData isEquipable=true
    hasQuantity=true}}
    {{!-- armor value --}}
    <div>{{itemData.system.armorValue}}</div>
    {{/systems/ds4/templates/sheets/actor/components/item-list-entry.hbs}}
    {{/each}}
</ol>
{{/unless}}
{{> systems/ds4/templates/sheets/shared/components/add-button.hbs title='DS4.UserInteractionAddItemTitle'
documentType='item' type='shield'}}

{{!-- EQUIPMENT --}}
<h4 class="ds4-embedded-document-list-title">{{localize 'DS4.ItemTypeEquipmentPlural'}}</h4>
{{#unless (isEmpty itemsByType.equipment)}}
<ol class="ds4-embedded-document-list ds4-embedded-document-list--equipment item-list">
    {{#> systems/ds4/templates/sheets/actor/components/item-list-header.hbs isEquipable=true hasQuantity=true
    type='equipment'}}
    {{!-- storage location --}}
    <div class="ds4-embedded-document-list__clickable sort-items" data-data-path="system.storageLocation"
        title="{{localize 'DS4.SortByStorageLocation'}}">{{localize 'DS4.StorageLocation'}}</div>
    {{/systems/ds4/templates/sheets/actor/components/item-list-header.hbs}}
    {{#each itemsByType.equipment as |itemData id|}}
    {{#> systems/ds4/templates/sheets/actor/components/item-list-entry.hbs itemData=itemData isEquipable=true
    hasQuantity=true}}
    {{!-- storage location --}}
    <input class="ds4-embedded-document-list__editable change-item" type="text"
        value="{{itemData.system.storageLocation}}" data-dtype="String" data-property="system.storageLocation"
        title="{{localize 'DS4.StorageLocation'}}">
    {{/systems/ds4/templates/sheets/actor/components/item-list-entry.hbs}}
    {{/each}}
</ol>
{{/unless}}
{{> systems/ds4/templates/sheets/shared/components/add-button.hbs title='DS4.UserInteractionAddItemTitle'
documentType='item' type='equipment'}}

{{!-- LOOT --}}
<h4 class="ds4-embedded-document-list-title">{{localize 'DS4.ItemTypeLootPlural'}}</h4>
{{#unless (isEmpty itemsByType.loot)}}
<ol class="ds4-embedded-document-list ds4-embedded-document-list--loot item-list">
    {{#> systems/ds4/templates/sheets/actor/components/item-list-header.hbs hasQuantity=true type='loot'}}
    {{!-- storage location --}}
    <div class="ds4-embedded-document-list__clickable sort-items" data-data-path="system.storageLocation"
        title="{{localize 'DS4.SortByStorageLocation'}}">{{localize 'DS4.StorageLocation'}}</div>
    {{/systems/ds4/templates/sheets/actor/components/item-list-header.hbs}}
    {{#each itemsByType.loot as |itemData id|}}
    {{#> systems/ds4/templates/sheets/actor/components/item-list-entry.hbs itemData=itemData hasQuantity=true}}
    {{!-- storage location --}}
    <input class="ds4-embedded-document-list__editable change-item" type="text"
        value="{{itemData.system.storageLocation}}" data-dtype="String" data-property="system.storageLocation"
        title="{{localize 'DS4.StorageLocation'}}">
    {{/systems/ds4/templates/sheets/actor/components/item-list-entry.hbs}}
    {{/each}}
</ol>
{{/unless}}
{{> systems/ds4/templates/sheets/shared/components/add-button.hbs title='DS4.UserInteractionAddItemTitle'
documentType='item' type='loot'}}