diff --git a/src/ds4.scss b/src/ds4.scss index a3b14a06..db46a09a 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 8159ced0..84c7d542 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1,12 +1,12 @@ { "DS4.UserInteractionAddItem": "Add item", "DS4.NotOwned": "No owner", - "DS4.Description": "Description", - "DS4.DescriptionAbbr": "Desc", - "DS4.Details": "Details", - "DS4.Effects": "Effects", - "DS4.Profile": "Profile", - "DS4.Items": "Items", + "DS4.HeadingDescription": "Description", + "DS4.HeadingDetails": "Details", + "DS4.HeadingEffects": "Effects", + "DS4.HeadingItems": "Items", + "DS4.HeadingProfile": "Profile", + "DS4.HeadingTalents": "Talents & Abilities", "DS4.AttackType": "Attack Type", "DS4.AttackTypeAbbr": "AT", "DS4.WeaponBonus": "Weapon Bonus", @@ -35,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", @@ -85,6 +86,11 @@ "DS4.ProgressionExperiencePoints": "Experience Points", "DS4.ProgressionTalentPoints": "Talent Points", "DS4.ProgressionProgressPoints": "Progress Points", + "DS4.TalentRank": "Rank", + "DS4.TalentRankBase": "Acquired Ranks", + "DS4.TalentRankMax": "Maximum Ranks", + "DS4.TalentRankMod": "Additional Ranks", + "DS4.TalentRankTotal": "Total Ranks", "DS4.LanguageLanguages": "Languages", "DS4.LanguageAlphabets": "Alphabets", "DS4.ProfileGender": "Gender", diff --git a/src/module/config.ts b/src/module/config.ts index c5c1dea3..c98f3d41 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 cf43adb8..6fe0aa7a 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -37,6 +37,9 @@ 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/overview-add-button.hbs", + "systems/ds4/templates/actor/partials/overview-control-buttons.hbs", "systems/ds4/templates/actor/partials/attributes-traits.hbs", "systems/ds4/templates/actor/partials/combat-values.hbs", "systems/ds4/templates/actor/partials/profile.hbs", diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index 58f4dc90..3af52fd2 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -1,5 +1,6 @@ -// TODO: Actually add a type for data -export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment; +import { ModifiableData } from "../actor/actor-data"; + +export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment | DS4Talent; // types @@ -14,6 +15,14 @@ interface DS4Armor extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4It armorType: "body" | "helmet" | "vambrace" | "greaves" | "vambraceGreaves"; } +export interface DS4Talent extends DS4ItemBase { + rank: 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 {} @@ -30,6 +39,10 @@ interface DS4ItemPhysical { storageLocation: string; } +export function isDS4ItemDataTypePhysical(input: DS4ItemDataType): boolean { + return "quantity" in input && "price" in input && "availability" in input && "storageLocation" in input; +} + interface DS4ItemEquipable { equipped: boolean; } diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index ac8197aa..8670dc3e 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -1,5 +1,5 @@ import { DS4Item } from "./item"; -import { DS4ItemDataType } from "./item-data"; +import { DS4ItemDataType, isDS4ItemDataTypePhysical } from "./item-data"; /** * Extend the basic ItemSheet with some very simple modifications @@ -26,7 +26,13 @@ export class DS4ItemSheet extends ItemSheet { /** @override */ getData(): ItemSheetData { - const data = { ...super.getData(), config: CONFIG.DS4, isOwned: this.item.isOwned, actor: this.item.actor }; + const data = { + ...super.getData(), + config: CONFIG.DS4, + isOwned: this.item.isOwned, + actor: this.item.actor, + isPhysical: isDS4ItemDataTypePhysical(this.item.data.data), + }; console.log(data); return data; } diff --git a/src/module/item/item.ts b/src/module/item/item.ts index c32f0cfe..e9a1aa3e 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 = this.data.data as DS4Talent; + data.rank.total = data.rank.base + data.rank.mod; + } + } } diff --git a/src/scss/components/_basic_property.scss b/src/scss/components/_basic_property.scss index e284529c..40978da4 100644 --- a/src/scss/components/_basic_property.scss +++ b/src/scss/components/_basic_property.scss @@ -2,18 +2,24 @@ flex: 0 0 100%; gap: 2px; .basic-property { + display: grid; + align-content: end; padding-left: 1px; padding-right: 1px; - .basic-property-label { + + & > label { font-weight: bold; } - .basic-property-select { + & > select { display: block; width: 100%; } + .input-divider { text-align: center; } + + @include mark-invalid-or-disabled-input; } } diff --git a/src/scss/components/_description.scss b/src/scss/components/_description.scss index 8bd3b18b..084b1796 100644 --- a/src/scss/components/_description.scss +++ b/src/scss/components/_description.scss @@ -9,7 +9,7 @@ .side-property { margin: 2px 0; display: grid; - grid-template-columns: 40% auto; + grid-template-columns: minmax(30%, auto) auto; justify-content: left; label { @@ -23,6 +23,8 @@ width: calc(100% - 2px); } + @include mark-invalid-or-disabled-input; + input[type="checkbox"] { width: auto; height: 100%; diff --git a/src/scss/components/_items.scss b/src/scss/components/_items.scss index 4dd97f78..6382c587 100644 --- a/src/scss/components/_items.scss +++ b/src/scss/components/_items.scss @@ -31,6 +31,7 @@ input { border: 0; padding: 0; + background-color: transparent; } input[type="checkbox"] { @@ -38,6 +39,8 @@ height: 100%; margin: 0px; } + + @include mark-invalid-or-disabled-input; } .item-name { @@ -54,9 +57,6 @@ width: 2.5em; padding: 0; } - .item-num-val:invalid { - background-color: color.mix(lightcoral, $c-light-grey, 25%); - } .item-description { font-size: 75%; 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/scss/utils/_colors.scss b/src/scss/utils/_colors.scss index 7a2200d1..55fb8c0a 100644 --- a/src/scss/utils/_colors.scss +++ b/src/scss/utils/_colors.scss @@ -2,3 +2,4 @@ $c-white: #fff; $c-black: #000; $c-light-grey: #777; $c-border-groove: #eeede0; +$c-invalid-input: rgba(lightcoral, 50%); diff --git a/src/scss/utils/_mixins.scss b/src/scss/utils/_mixins.scss index 7e028c29..adc2e69a 100644 --- a/src/scss/utils/_mixins.scss +++ b/src/scss/utils/_mixins.scss @@ -19,3 +19,12 @@ display: grid; place-items: center; } + +@mixin mark-invalid-or-disabled-input { + input:invalid { + background-color: $c-invalid-input; + } + input:disabled { + background-color: transparent; + } +} diff --git a/src/template.json b/src/template.json index fe663ed3..f4aef42d 100644 --- a/src/template.json +++ b/src/template.json @@ -116,7 +116,7 @@ } }, "Item": { - "types": ["weapon", "armor", "shield", "trinket", "equipment"], + "types": ["weapon", "armor", "shield", "trinket", "equipment", "talent"], "templates": { "base": { "description": "" @@ -153,6 +153,14 @@ }, "equipment": { "templates": ["base", "physical"] + }, + "talent": { + "templates": ["base"], + "rank": { + "base": 0, + "max": 0, + "mod": 0 + } } } } diff --git a/src/templates/actor/actor-sheet.hbs b/src/templates/actor/actor-sheet.hbs index 989ab3a0..05a62038 100644 --- a/src/templates/actor/actor-sheet.hbs +++ b/src/templates/actor/actor-sheet.hbs @@ -58,9 +58,10 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} @@ -73,6 +74,9 @@ {{! Profile Tab --}} {{> systems/ds4/templates/actor/partials/profile.hbs}} + {{!-- 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/items-overview.hbs b/src/templates/actor/partials/items-overview.hbs index 0cc57faf..da54d2e8 100644 --- a/src/templates/actor/partials/items-overview.hbs +++ b/src/templates/actor/partials/items-overview.hbs @@ -5,29 +5,6 @@ {{!-- 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}} - {{!-- !-- Render a header row for a given data type. @@ -55,9 +32,9 @@ {{!-- item type specifics --}} {{> @partial-block }} {{!-- description --}} -
{{localize 'DS4.Description'}}
+
{{localize 'DS4.HeadingDescription'}}
{{!-- add button --}} - {{> addItemButton dataType=dataType }} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} {{/inline}} @@ -94,7 +71,7 @@ {{!-- description --}}
{{{item.data.data.description}}}
{{!-- control buttons --}} - {{> itemControlButtons}} + {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} {{/inline}} diff --git a/src/templates/actor/partials/overview-add-button.hbs b/src/templates/actor/partials/overview-add-button.hbs new file mode 100644 index 00000000..86e5d774 --- /dev/null +++ b/src/templates/actor/partials/overview-add-button.hbs @@ -0,0 +1,11 @@ +{{! +!-- Render an "add" button for adding an item of given data type. +!-- +!-- @param datType: hand over the dataType to the partial as hash parameter +}} + \ No newline at end of file diff --git a/src/templates/actor/partials/overview-control-buttons.hbs b/src/templates/actor/partials/overview-control-buttons.hbs new file mode 100644 index 00000000..d10dbc3f --- /dev/null +++ b/src/templates/actor/partials/overview-control-buttons.hbs @@ -0,0 +1,8 @@ +{{!-- +!-- 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. +--}} +
+ + +
diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs new file mode 100644 index 00000000..3c2cfeac --- /dev/null +++ b/src/templates/actor/partials/talents-overview.hbs @@ -0,0 +1,83 @@ +{{!-- ======================================================================== --}} +{{!-- INLINE PARTIAL DEFINITIONS --}} +{{!-- ======================================================================== --}} +{{!-- 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 +--}} +{{#*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 --}} + {{> 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 }} +
  • +{{/inline}} + + +{{!-- ======================================================================== --}} + + +
    +
      +
    1. + {{!-- image --}} +
      + {{!-- name --}} +
      {{localize 'DS4.ItemName'}}
      + {{!-- rank info --}} +
      {{localize 'DS4.TalentRank'}}
      + {{!-- description --}} +
      {{localize 'DS4.HeadingDescription'}}
      + {{!-- add button --}} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs 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/armor-sheet.hbs b/src/templates/item/armor-sheet.hbs index a0a671dc..b7887131 100644 --- a/src/templates/item/armor-sheet.hbs +++ b/src/templates/item/armor-sheet.hbs @@ -6,8 +6,8 @@

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

    - - {{#select data.armorType}} {{#each config.armorTypes as |value key|}} @@ -16,8 +16,8 @@
    - - {{#select data.armorMaterialType}} {{#each config.armorMaterialTypes as |value key|}} @@ -26,8 +26,8 @@
    - - {{localize "DS4.ArmorValue"}} +
    diff --git a/src/templates/item/partials/body.hbs b/src/templates/item/partials/body.hbs index 9b5cde20..1f465d9f 100644 --- a/src/templates/item/partials/body.hbs +++ b/src/templates/item/partials/body.hbs @@ -2,9 +2,11 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} @@ -13,10 +15,12 @@ {{!-- Description Tab --}} {{> systems/ds4/templates/item/partials/description.hbs}} - {{!-- Details Tab --}} - {{> systems/ds4/templates/item/partials/details.hbs}} - {{!-- Effects Tab --}} {{> systems/ds4/templates/item/partials/effects.hbs}} + {{#if isPhysical}} + {{!-- Details Tab --}} + {{> systems/ds4/templates/item/partials/details.hbs}} + {{/if}} + \ No newline at end of file diff --git a/src/templates/item/partials/description.hbs b/src/templates/item/partials/description.hbs index 1776f1f2..d7088a30 100644 --- a/src/templates/item/partials/description.hbs +++ b/src/templates/item/partials/description.hbs @@ -11,19 +11,21 @@ {{actor.name}} -
    - - -
    -
    - - -
    + {{#if isPhysical}} +
    + + +
    +
    + + +
    + {{/if}} {{else}} - {{localize "DS4.NotOwned"}} + {{localize "DS4.NotOwned"}} {{/if}} -
    +
    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
    \ No newline at end of file diff --git a/src/templates/item/shield-sheet.hbs b/src/templates/item/shield-sheet.hbs index 1e893d2a..ede89655 100644 --- a/src/templates/item/shield-sheet.hbs +++ b/src/templates/item/shield-sheet.hbs @@ -6,8 +6,8 @@

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

    - - {{localize "DS4.ArmorValue"}} +
    diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs new file mode 100644 index 00000000..a4be9b03 --- /dev/null +++ b/src/templates/item/talent-sheet.hbs @@ -0,0 +1,37 @@ +{{!-- ======================================================================== --}} +{{!-- INLINE PARTIAL DEFINITIONS --}} +{{!-- ======================================================================== --}} + + +{{#*inline "talentRankBasicProperty" }} +
    + + +
    +{{/inline}} + + +{{!-- ======================================================================== --}} + + +
    +
    + +
    +

    +

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

    +
    + {{> talentRankBasicProperty data=data property='base' localizeString='DS4.TalentRankBase' }} + {{> talentRankBasicProperty data=data property='max' localizeString='DS4.TalentRankMax'}} + {{> talentRankBasicProperty data=data property='mod' localizeString='DS4.TalentRankMod'}} + {{> talentRankBasicProperty data=data property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} +
    +
    +
    + + {{!-- Common Item body --}} + {{> systems/ds4/templates/item/partials/body.hbs}} + +
    diff --git a/src/templates/item/weapon-sheet.hbs b/src/templates/item/weapon-sheet.hbs index 7a7efcfd..24a5f2d7 100644 --- a/src/templates/item/weapon-sheet.hbs +++ b/src/templates/item/weapon-sheet.hbs @@ -6,8 +6,8 @@

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

    - - {{#select data.attackType}} {{#each config.attackTypes as |value key|}} @@ -16,13 +16,13 @@
    - - {{localize "DS4.WeaponBonus"}} +
    - - {{localize "DS4.OpponentDefense"}} +