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

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

    {{!-- opponent defense --}}
    <div>
        {{#if item.system.opponentDefenseForAttackType.melee includeZero=true}}
        {{#if item.system.opponentDefenseForAttackType.ranged includeZero=true}}
        <span
            title="{{localize 'DS4.OpponentDefenseMelee'}}">{{item.system.opponentDefenseForAttackType.melee}}</span>/<span
            title="{{localize 'DS4.OpponentDefenseRanged'}}">{{item.system.opponentDefenseForAttackType.ranged}}</span>
        {{else}}
        {{item.system.opponentDefenseForAttackType.melee}}
        {{/if}}
        {{else}}
        {{item.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 |item id|}}
    {{#> systems/ds4/templates/sheets/actor/components/item-list-entry.hbs item=item isEquipable=true
    hasQuantity=true}}
    {{!-- armor material type --}}
    <div title="{{lookup @root/config.i18n.armorMaterialTypes  item.system.armorMaterialType}}">
        {{lookup @root/config.i18n.armorMaterialTypesAbbr item.system.armorMaterialType}}
    </div>

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

    {{!-- armor value --}}
    <div>{{ item.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 |item id|}}
    {{#> systems/ds4/templates/sheets/actor/components/item-list-entry.hbs item=item isEquipable=true
    hasQuantity=true}}
    {{!-- armor value --}}
    <div>{{item.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 |item id|}}
    {{#> systems/ds4/templates/sheets/actor/components/item-list-entry.hbs item=item isEquipable=true
    hasQuantity=true}}
    {{!-- storage location --}}
    <input class="ds4-embedded-document-list__editable change-item" type="text" value="{{item.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 |item id|}}
    {{#> systems/ds4/templates/sheets/actor/components/item-list-entry.hbs item=item hasQuantity=true}}
    {{!-- storage location --}}
    <input class="ds4-embedded-document-list__editable change-item" type="text" value="{{item.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'}}
