From e61da356173e056403f9b158fb99ab92a72b8e4b Mon Sep 17 00:00:00 2001 From: U~man Date: Sun, 28 Jun 2020 18:47:36 +0200 Subject: [PATCH] ENH: Monster layout base done --- src/lang/en.json | 5 +- src/module/actor/monster-sheet.js | 54 +++++++++++------- src/scss/monster.scss | 6 ++ src/template.json | 3 + .../partials/monster-attributes-tab.html | 57 +++++++++++++++---- 5 files changed, 92 insertions(+), 33 deletions(-) diff --git a/src/lang/en.json b/src/lang/en.json index 856f293..f7e087a 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -45,6 +45,8 @@ "OSE.Thac0": "THAC0", "OSE.Initiative": "Initiative", "OSE.InitiativeShort": "INIT", + "OSE.Attacks": "Attacks Usable per Round", + "OSE.AttacksShort": "ATT", "OSE.category.attributes": "Attributes", @@ -52,5 +54,6 @@ "OSE.category.spells": "Spells", "OSE.category.notes": "Notes", - "OSE.panel.abilities": "Abilities" + "OSE.panel.abilities": "Abilities", + "OSE.panel.equipment": "Equipment" } \ No newline at end of file diff --git a/src/module/actor/monster-sheet.js b/src/module/actor/monster-sheet.js index 61e51af..09b7dff 100644 --- a/src/module/actor/monster-sheet.js +++ b/src/module/actor/monster-sheet.js @@ -25,7 +25,7 @@ export class OseActorSheetMonster extends ActorSheet { { navSelector: ".tabs", contentSelector: ".sheet-body", - initial: "notes", + initial: "attributes", }, ], }); @@ -39,10 +39,13 @@ export class OseActorSheetMonster extends ActorSheet { */ getData() { const data = super.getData(); + data.config = CONFIG.OSE; // Prepare owned items this._prepareItems(data); + + // DEBUG return data; } @@ -51,31 +54,40 @@ export class OseActorSheetMonster extends ActorSheet { * @private */ _prepareItems(data) { + // Partition items by category + let [inventory, abilities, spells] = data.items.reduce( + (arr, item) => { + // Classify items into types + if (item.type === "item") arr[0].push(item); + if (item.type === "ability") arr[1].push(item); + else if (item.type === "spell") arr[2].push(item); + return arr; + }, + [[], [], [], []] + ); + + // Assign and return + data.inventory = inventory; + data.spells = spells; + data.abilities = abilities; } + _onItemSummary(event) { event.preventDefault(); - let li = $(event.currentTarget).parents(".item-entry"), - expanded = !li.children(".collapsible").hasClass("collapsed"); - li = $(li); - let ol = li.children(".collapsible"); - let icon = li.find("i.fas"); - - // Collapse the Playlist - if (expanded) { - ol.slideUp(200, () => { - ol.addClass("collapsed"); - icon.removeClass("fa-angle-up").addClass("fa-angle-down"); - }); - } - - // Expand the Playlist - else { - ol.slideDown(200, () => { - ol.removeClass("collapsed"); - icon.removeClass("fa-angle-down").addClass("fa-angle-up"); - }); + let li = $(event.currentTarget).parents(".item"), + item = this.actor.getOwnedItem(li.data("item-id")), + description = TextEditor.enrichHTML(item.data.data.description); + // Toggle summary + if ( li.hasClass("expanded") ) { + let summary = li.parents('.item-entry').children(".item-summary"); + summary.slideUp(200, () => summary.remove()); + } else { + let div = $(`
${description}
`); + li.parents('.item-entry').append(div.hide()); + div.slideDown(200); } + li.toggleClass("expanded"); } /* -------------------------------------------- */ diff --git a/src/scss/monster.scss b/src/scss/monster.scss index e5fb811..96cb216 100644 --- a/src/scss/monster.scss +++ b/src/scss/monster.scss @@ -12,4 +12,10 @@ overflow: auto; } } + .attribute-row { + padding: 2px; + .abilities { + margin: 2px; + } + } } diff --git a/src/template.json b/src/template.json index 929159e..bf2f7e1 100644 --- a/src/template.json +++ b/src/template.json @@ -125,6 +125,9 @@ "value": 0, "mod": 0 }, + "attacks": { + "value": 1 + }, "movement": { "base": 0, "encounter": 0 diff --git a/src/templates/actors/partials/monster-attributes-tab.html b/src/templates/actors/partials/monster-attributes-tab.html index 701bed4..8593a84 100644 --- a/src/templates/actors/partials/monster-attributes-tab.html +++ b/src/templates/actors/partials/monster-attributes-tab.html @@ -1,7 +1,7 @@
-
+
{{!-- Skills and abilities --}}

{{localize 'OSE.panel.abilities'}}

@@ -60,6 +67,34 @@
+ {{!-- Equipment --}} +
+

{{localize 'OSE.panel.equipment'}}

+
    +
    + {{#each inventory as |item|}} +
  • +
    +
    +
    +

    + {{item.name~}} +

    +
    +
    + {{#if ../owner}} + + + {{/if}} +
    +
    +
  • + {{/each}} +
    +
+
{{!-- Saving throws --}}