From 150a0ea487d9379026ce3351d1fdc05c8318f8ca Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 01:24:37 +0100 Subject: [PATCH] added talents overview and sheet - added talents item type: - added scss - added to template.json (Item.types, Item.talent) - added to config.ts itemTypes - added type definition - added localizations - added talent overview tab to actor sheet - made total rank calculated upon data preparation by adding a prepareData method to DS4Item --- src/ds4.scss | 1 + src/lang/en.json | 10 +- src/module/config.ts | 1 + src/module/ds4.ts | 1 + src/module/item/item-data.ts | 12 ++- src/module/item/item.ts | 10 +- src/scss/components/_talents.scss | 3 + src/template.json | 10 +- src/templates/actor/actor-sheet.hbs | 8 +- .../actor/partials/talents-overview.hbs | 95 +++++++++++++++++++ src/templates/item/talent-sheet.hbs | 63 ++++++++++++ 11 files changed, 208 insertions(+), 6 deletions(-) create mode 100644 src/scss/components/_talents.scss create mode 100644 src/templates/actor/partials/talents-overview.hbs create mode 100644 src/templates/item/talent-sheet.hbs diff --git a/src/ds4.scss b/src/ds4.scss index 2fedca1f..b69bbd1f 100644 --- a/src/ds4.scss +++ b/src/ds4.scss @@ -16,6 +16,7 @@ @import "scss/components/basic_property"; @import "scss/components/tabs"; @import "scss/components/items"; + @import "scss/components/talents"; @import "scss/components/description"; @import "scss/components/character_values"; @import "scss/components/attributes_traits"; diff --git a/src/lang/en.json b/src/lang/en.json index de17c09b..5227291e 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -5,6 +5,8 @@ "DS4.DescriptionAbbr": "Desc", "DS4.Details": "Details", "DS4.Effects": "Effects", + "DS4.Items": "Items", + "DS4.Talents": "Talents & Abilities", "DS4.AttackType": "Attack Type", "DS4.AttackTypeAbbr": "AT", "DS4.WeaponBonus": "Weapon Bonus", @@ -33,6 +35,7 @@ "DS4.ItemTypeShield": "Shield", "DS4.ItemTypeTrinket": "Trinket", "DS4.ItemTypeEquipment": "Equipment", + "DS4.ItemTypeTalent": "Talent", "DS4.ArmorType": "Armor Type", "DS4.ArmorTypeAbbr": "AT", "DS4.ArmorMaterialType": "Material Type", @@ -81,5 +84,10 @@ "DS4.ProgressionLevel": "Level", "DS4.ProgressionExperiencePoints": "Experience Points", "DS4.ProgressionTalentPoints": "Talent Points", - "DS4.ProgressionProgressPoints": "Progress Points" + "DS4.ProgressionProgressPoints": "Progress Points", + "DS4.TalentRank": "Rank", + "DS4.TalentRankBase": "Acquired Ranks", + "DS4.TalentRankMax": "Maximum Ranks", + "DS4.TalentRankMod": "Additional Ranks", + "DS4.TalentRankTotal": "Total Ranks" } diff --git a/src/module/config.ts b/src/module/config.ts index 89d285cf..502927ef 100644 --- a/src/module/config.ts +++ b/src/module/config.ts @@ -48,6 +48,7 @@ export const DS4 = { shield: "DS4.ItemTypeShield", trinket: "DS4.ItemTypeTrinket", equipment: "DS4.ItemTypeEquipment", + talent: "DS4.ItemTypeTalent", }, /** diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 358074b0..4bcf2223 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -37,6 +37,7 @@ async function registerHandlebarsPartials() { "systems/ds4/templates/item/partials/effects.hbs", "systems/ds4/templates/item/partials/body.hbs", "systems/ds4/templates/actor/partials/items-overview.hbs", + "systems/ds4/templates/actor/partials/talents-overview.hbs", "systems/ds4/templates/actor/partials/attributes-traits.hbs", "systems/ds4/templates/actor/partials/combat-values.hbs", ]; diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index 58f4dc90..a2cbc61b 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -1,5 +1,7 @@ +import { ModifiableData } from "../actor/actor-data"; + // TODO: Actually add a type for data -export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment; +export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment | DS4Talent; // types @@ -14,6 +16,14 @@ interface DS4Armor extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4It armorType: "body" | "helmet" | "vambrace" | "greaves" | "vambraceGreaves"; } +export interface DS4Talent extends DS4ItemBase { + talentRank: DS4TalentRank; +} + +interface DS4TalentRank extends ModifiableData { + max: number; +} + interface DS4Shield extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4ItemProtective {} interface DS4Trinket extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable {} interface DS4Equipment extends DS4ItemBase, DS4ItemPhysical {} diff --git a/src/module/item/item.ts b/src/module/item/item.ts index c32f0cfe..814a6e15 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -1,6 +1,6 @@ import { DS4Actor } from "../actor/actor"; import { DS4ActorDataType } from "../actor/actor-data"; -import { DS4ItemDataType } from "./item-data"; +import { DS4ItemDataType, DS4Talent } from "./item-data"; /** * Extend the basic Item with some very simple modifications. @@ -12,10 +12,18 @@ export class DS4Item extends Item { */ prepareData(): void { super.prepareData(); + this.prepareDerivedData(); // Get the Item's data // const itemData = this.data; // const actorData = this.actor ? this.actor.data : {}; // const data = itemData.data; } + + prepareDerivedData(): void { + if (this.type === "talent") { + const data: DS4Talent = this.data.data as DS4Talent; + data.talentRank.total = data.talentRank.base + data.talentRank.mod; + } + } } diff --git a/src/scss/components/_talents.scss b/src/scss/components/_talents.scss new file mode 100644 index 00000000..2f8db41b --- /dev/null +++ b/src/scss/components/_talents.scss @@ -0,0 +1,3 @@ +.talent-ranks-equation { + text-align: center; +} diff --git a/src/template.json b/src/template.json index b78fd3e1..f412936e 100644 --- a/src/template.json +++ b/src/template.json @@ -100,7 +100,7 @@ } }, "Item": { - "types": ["weapon", "armor", "shield", "trinket", "equipment"], + "types": ["weapon", "armor", "shield", "trinket", "equipment", "talent"], "templates": { "base": { "description": "" @@ -137,6 +137,14 @@ }, "equipment": { "templates": ["base", "physical"] + }, + "talent": { + "templates": ["base"], + "talentRank": { + "base": 0, + "max": 0, + "mod": 0 + } } } } diff --git a/src/templates/actor/actor-sheet.hbs b/src/templates/actor/actor-sheet.hbs index 475ce2fd..b22aae3b 100644 --- a/src/templates/actor/actor-sheet.hbs +++ b/src/templates/actor/actor-sheet.hbs @@ -90,8 +90,9 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} @@ -101,6 +102,9 @@ {{editor content=data.biography target="data.biography" button=true owner=owner editable=editable}} + {{!-- Talents Tab --}} + {{> systems/ds4/templates/actor/partials/talents-overview.hbs}} + {{!-- Items Tab --}} {{> systems/ds4/templates/actor/partials/items-overview.hbs}} diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs new file mode 100644 index 00000000..03a9335d --- /dev/null +++ b/src/templates/actor/partials/talents-overview.hbs @@ -0,0 +1,95 @@ +{{!-- ======================================================================== --}} +{{!-- INLINE PARTIAL DEFINITIONS --}} +{{!-- ======================================================================== --}} + +{{!-- +!-- Render an "add" button for a given data type. +!-- +!-- @param datType: hand over the dataType to the partial as hash parameter +--}} +{{#*inline "addItemButton"}} + +{{/inline}} +{{!-- +!-- Render a group of an "edit" and a "delete" button for the current item. +!-- The current item is defined by the data-item-id HTML property of the parent li element. +--}} +{{#*inline "itemControlButtons"}} +
+ + +
+{{/inline}} + + +{{#*inline "talentRankValue"}} + +{{/inline}} + +{{!-- +!-- Render a talent 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 "talentListEntry"}} +
  • + {{!-- 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 --}} + {{item.data.data.talentRank.total}} +
    + {{!-- description --}} +
    {{{item.data.data.description}}}
    + {{!-- control buttons --}} + {{> itemControlButtons}} +
  • +{{/inline}} + + +{{!-- ======================================================================== --}} + + +
    +
      +
    1. + {{!-- image --}} +
      + {{!-- name --}} +
      {{localize 'DS4.ItemName'}}
      + {{!-- rank info --}} +
      {{localize 'DS4.TalentRank'}}
      + {{!-- description --}} +
      {{localize 'DS4.Description'}}
      + {{!-- add button --}} + {{> addItemButton dataType='talent' }} +
    2. + {{#each itemsByType.talent as |item id|}} + {{> talentListEntry item=item}} + {{/each}} +
    +
    \ No newline at end of file diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs new file mode 100644 index 00000000..400999c7 --- /dev/null +++ b/src/templates/item/talent-sheet.hbs @@ -0,0 +1,63 @@ + +{{#*inline "talentRankSideProperty" }} +
    + + +
    +{{/inline}} + + +
    +
    + +
    +

    +

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

    +
    +
    + + {{!-- Sheet Tab Navigation --}} + + + {{!-- Sheet Body --}} +
    + {{!-- The item tab for details. --}} +
    + {{!-- As you add new fields, add them in here! --}} +
    + {{!-- TODO: remove duplication of isOwned section here and in description.hbs--}} + {{#if isOwned}} + {{#if (ne data.equipped undefined)}}
    + + +
    + {{/if}} +
    + + {{actor.name}} +
    + {{else}} + {{localize "DS4.NotOwned"}} + {{/if}} + {{> talentRankSideProperty data=data property='base' localizeString='DS4.TalentRankBase' }} + {{> talentRankSideProperty data=data property='max' localizeString='DS4.TalentRankMax'}} + {{> talentRankSideProperty data=data property='mod' localizeString='DS4.TalentRankMod'}} + {{> talentRankSideProperty data=data property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} +
    +
    + {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} +
    +
    + +
    + + {{!-- Effects Tab --}} + {{> systems/ds4/templates/item/partials/effects.hbs}} + +