From 149096e98514c1e948fe58143239bbcb191ff55e Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 7 Jan 2021 20:20:40 +0100 Subject: [PATCH] add racial abilites as item type --- src/lang/en.json | 10 +- src/module/config.ts | 1 + src/module/item/item-data.ts | 10 +- src/scss/components/_forms.scss | 2 +- src/template.json | 5 +- src/templates/actor/actor-sheet.hbs | 2 +- .../actor/partials/items-overview.hbs | 12 +- .../actor/partials/talents-overview.hbs | 108 ++++++++++++------ src/templates/item/racialAbility-sheet.hbs | 13 +++ 9 files changed, 118 insertions(+), 45 deletions(-) create mode 100644 src/templates/item/racialAbility-sheet.hbs diff --git a/src/lang/en.json b/src/lang/en.json index 84c7d542..72f0455b 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -4,7 +4,7 @@ "DS4.HeadingDescription": "Description", "DS4.HeadingDetails": "Details", "DS4.HeadingEffects": "Effects", - "DS4.HeadingItems": "Items", + "DS4.HeadingInventory": "Inventory", "DS4.HeadingProfile": "Profile", "DS4.HeadingTalents": "Talents & Abilities", "DS4.AttackType": "Attack Type", @@ -31,11 +31,19 @@ "DS4.ItemAvailabilityNowhere": "Nowhere", "DS4.ItemName": "Name", "DS4.ItemTypeWeapon": "Weapon", + "DS4.ItemTypeWeaponPlural": "Weapons", "DS4.ItemTypeArmor": "Armor", + "DS4.ItemTypeArmorPlural": "Armor", "DS4.ItemTypeShield": "Shield", + "DS4.ItemTypeShieldPlural": "Shields", "DS4.ItemTypeTrinket": "Trinket", + "DS4.ItemTypeTrinketPlural": "Trinkets", "DS4.ItemTypeEquipment": "Equipment", + "DS4.ItemTypeEquipmentPlural": "Equipment", "DS4.ItemTypeTalent": "Talent", + "DS4.ItemTypeTalentPlural": "Talents", + "DS4.ItemTypeRacialAbility": "Racial Ability", + "DS4.ItemTypeRacialAbilityPlural": "Racial Abilities", "DS4.ArmorType": "Armor Type", "DS4.ArmorTypeAbbr": "AT", "DS4.ArmorMaterialType": "Material Type", diff --git a/src/module/config.ts b/src/module/config.ts index c98f3d41..28e0a655 100644 --- a/src/module/config.ts +++ b/src/module/config.ts @@ -49,6 +49,7 @@ export const DS4 = { trinket: "DS4.ItemTypeTrinket", equipment: "DS4.ItemTypeEquipment", talent: "DS4.ItemTypeTalent", + racialAbility: "DS4.ItemTypeRacialAbility", }, /** diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index 3af52fd2..76b90e78 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -1,6 +1,13 @@ import { ModifiableData } from "../actor/actor-data"; -export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment | DS4Talent; +export type DS4ItemDataType = + | DS4Weapon + | DS4Armor + | DS4Shield + | DS4Trinket + | DS4Equipment + | DS4Talent + | DS4RacialAbility; // types @@ -26,6 +33,7 @@ interface DS4TalentRank extends ModifiableData { interface DS4Shield extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4ItemProtective {} interface DS4Trinket extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable {} interface DS4Equipment extends DS4ItemBase, DS4ItemPhysical {} +type DS4RacialAbility = DS4ItemBase; // templates diff --git a/src/scss/components/_forms.scss b/src/scss/components/_forms.scss index 2a992d7b..4c99b156 100644 --- a/src/scss/components/_forms.scss +++ b/src/scss/components/_forms.scss @@ -43,7 +43,7 @@ header.sheet-header { display: block; height: 50px; padding: 0px; - flex: 0 0 0; + flex: 0 0 auto; color: $c-light-grey; border: none; line-height: 50px; diff --git a/src/template.json b/src/template.json index f4aef42d..f5a605ef 100644 --- a/src/template.json +++ b/src/template.json @@ -116,7 +116,7 @@ } }, "Item": { - "types": ["weapon", "armor", "shield", "trinket", "equipment", "talent"], + "types": ["weapon", "armor", "shield", "trinket", "equipment", "talent", "racialAbility"], "templates": { "base": { "description": "" @@ -161,6 +161,9 @@ "max": 0, "mod": 0 } + }, + "racialAbility": { + "templates": ["base"] } } } diff --git a/src/templates/actor/actor-sheet.hbs b/src/templates/actor/actor-sheet.hbs index 05a62038..8e3e5f54 100644 --- a/src/templates/actor/actor-sheet.hbs +++ b/src/templates/actor/actor-sheet.hbs @@ -61,7 +61,7 @@ {{localize 'DS4.HeadingDescription'}} {{localize 'DS4.HeadingTalents'}} {{localize "DS4.HeadingProfile"}} - {{localize 'DS4.HeadingItems'}} + {{localize 'DS4.HeadingInventory'}} {{!-- Sheet Body --}} diff --git a/src/templates/actor/partials/items-overview.hbs b/src/templates/actor/partials/items-overview.hbs index da54d2e8..e41d6f98 100644 --- a/src/templates/actor/partials/items-overview.hbs +++ b/src/templates/actor/partials/items-overview.hbs @@ -79,10 +79,10 @@ {{!-- ======================================================================== --}} -
+
{{!-- WEAPONS --}} -

{{localize 'DS4.ItemTypeWeapon'}}

+

{{localize 'DS4.ItemTypeWeaponPlural'}}

    {{#> itemListHeader dataType='weapon'}}
    {{localize 'DS4.AttackTypeAbbr'}}
    @@ -106,7 +106,7 @@
{{!-- ARMOR --}} -

{{localize 'DS4.ItemTypeArmor'}}

+

{{localize 'DS4.ItemTypeArmorPlural'}}

    {{#> itemListHeader dataType='armor'}}
    {{localize 'DS4.ArmorMaterialTypeAbbr'}}
    @@ -130,7 +130,7 @@ {{!-- SHIELD --}} -

    {{localize 'DS4.ItemTypeShield'}}

    {{!-- SPECIFIC --}} +

    {{localize 'DS4.ItemTypeShieldPlural'}}

    {{!-- SPECIFIC --}}
      {{#> itemListHeader dataType='shield' }}
      @@ -145,7 +145,7 @@
    {{!-- TRINKET --}} -

    {{localize 'DS4.ItemTypeTrinket'}}

    +

    {{localize 'DS4.ItemTypeTrinketPlural'}}

      {{#> itemListHeader dataType='trinket'}}
      {{localize 'DS4.StorageLocation'}}
      @@ -159,7 +159,7 @@
    {{!-- EQUIPMENT --}} -

    {{localize 'DS4.ItemTypeEquipment'}}

    +

    {{localize 'DS4.ItemTypeEquipmentPlural'}}

      {{#> itemListHeader dataType='equipment'}}
      {{localize 'DS4.StorageLocation'}}
      diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs index 3c2cfeac..179703e2 100644 --- a/src/templates/actor/partials/talents-overview.hbs +++ b/src/templates/actor/partials/talents-overview.hbs @@ -4,20 +4,18 @@ {{!-- TODO: remove duplicate add and delete button definition --}} -{{!-- +{{!-- !-- Render an input element for a rank value property of an item. !-- !-- @param item: the item !-- @param property: the key of the property in item.data.data (if 'base', the max value is set automatically) !-- @param disabled: if given, is placed plainly into the input as HTML property; -!-- meant to be set to "disabled" to disable the input element +!-- meant to be set to "disabled" to disable the input element --}} {{#*inline "talentRankValue"}} - + {{/inline}} @@ -30,39 +28,64 @@ !-- @param partial-block: hand over custom children of the flexbox in the partial block. --}} {{#*inline "talentListEntry"}} -
    1. - {{!-- image --}} -
      - -
      - {{!-- name --}} - -
      - {{!-- acquired rank --}} - {{> talentRankValue item=item property='base' localizeString='DS4.TalentRankBase'}} - ( of - {{!-- maximum acquirable rank --}} - {{> talentRankValue item=item property='max' localizeString='DS4.TalentRankMax'}} - ) + - {{!-- additional ranks --}} - {{> talentRankValue item=item property='mod' localizeString='DS4.TalentRankMod'}} - = - {{!-- derived total rank --}} - {{> talentRankValue item=item property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} -
      - {{!-- description --}} -
      {{{item.data.data.description}}}
      - {{!-- control buttons --}} - {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} -
    2. +
    3. + {{!-- image --}} +
      + +
      + {{!-- name --}} + +
      + {{!-- acquired rank --}} + {{> talentRankValue item=item property='base' localizeString='DS4.TalentRankBase'}} + ( of + {{!-- maximum acquirable rank --}} + {{> talentRankValue item=item property='max' localizeString='DS4.TalentRankMax'}} + ) + + {{!-- additional ranks --}} + {{> talentRankValue item=item property='mod' localizeString='DS4.TalentRankMod'}} + = + {{!-- derived total rank --}} + {{> talentRankValue item=item property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} +
      + {{!-- description --}} +
      {{{item.data.data.description}}}
      + {{!-- control buttons --}} + {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} +
    4. {{/inline}} +{{!-- +!-- Render a racial ability list row from a given item. +!-- It is a flexbox with a child for each item value of interest. +!-- The partial assumes a variable item to be given in the context. +!-- +!-- @param item: hand over the item to the partial as hash parameter +!-- @param partial-block: hand over custom children of the flexbox in the partial block. +--}} +{{#*inline "racialAbilityListEntry"}} +
    5. + {{!-- image --}} +
      + +
      + {{!-- name --}} + + {{!-- description --}} +
      {{{item.data.data.description}}}
      + {{!-- control buttons --}} + {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} +
    6. +{{/inline}} + {{!-- ======================================================================== --}}
      +

      {{localize 'DS4.ItemTypeTalentPlural'}}

      1. {{!-- image --}} @@ -77,7 +100,24 @@ {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='talent' }}
      2. {{#each itemsByType.talent as |item id|}} - {{> talentListEntry item=item}} + {{> talentListEntry item=item}} + {{/each}} +
      + +

      {{localize 'DS4.ItemTypeRacialAbilityPlural'}}

      +
        +
      1. + {{!-- image --}} +
        + {{!-- name --}} +
        {{localize 'DS4.ItemName'}}
        + {{!-- description --}} +
        {{localize 'DS4.HeadingDescription'}}
        + {{!-- add button --}} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='racialAbility' }} +
      2. + {{#each itemsByType.racialAbility as |item id|}} + {{> racialAbilityListEntry item=item}} {{/each}}
      \ No newline at end of file diff --git a/src/templates/item/racialAbility-sheet.hbs b/src/templates/item/racialAbility-sheet.hbs new file mode 100644 index 00000000..46dcf476 --- /dev/null +++ b/src/templates/item/racialAbility-sheet.hbs @@ -0,0 +1,13 @@ +
      +
      + +
      +

      +

      {{localize (lookup config.itemTypes item.type)}}

      +
      +
      + + {{!-- Common Item body --}} + {{> systems/ds4/templates/item/partials/body.hbs}} + +