From 35b452e495ab4208cfe864ca2a5742b7e29d16f3 Mon Sep 17 00:00:00 2001 From: Adam Kostandy Date: Sun, 25 Aug 2024 11:43:15 -0400 Subject: [PATCH] fixed issue in prepare items, added in 2 arrays for context with item, agenda, and blasphemies. each now stored in their own array. --- module/cain.mjs | 4 -- module/sheets/actor-sheet.mjs | 33 ++++-------- system.json | 2 +- templates/actor/parts/actor-abilities.hbs | 62 +++++++++-------------- 4 files changed, 34 insertions(+), 67 deletions(-) diff --git a/module/cain.mjs b/module/cain.mjs index 49676b0..887ddbc 100644 --- a/module/cain.mjs +++ b/module/cain.mjs @@ -122,10 +122,6 @@ Handlebars.registerHelper('hasItemsOfType', function(items, type, options) { return hasItems ? options.fn(this) : options.inverse(this); }); -Handlebars.registerHelper('set', function(context, key, value, options) { - context[key] = value; -}); - Handlebars.registerHelper('calcPercentage', function(curr, max) { return (curr / max) * 100; }); diff --git a/module/sheets/actor-sheet.mjs b/module/sheets/actor-sheet.mjs index 3de194b..db950c6 100644 --- a/module/sheets/actor-sheet.mjs +++ b/module/sheets/actor-sheet.mjs @@ -75,36 +75,23 @@ export class CainActorSheet extends ActorSheet { _prepareItems(context) { const gear = []; - const features = []; - const spells = { - 0: [], - 1: [], - 2: [], - 3: [], - 4: [], - 5: [], - 6: [], - 7: [], - 8: [], - 9: [], - }; - + const agendas = []; + const blasphemies = []; + for (let i of context.items) { i.img = i.img || Item.DEFAULT_ICON; if (i.type === 'item') { gear.push(i); - } else if (i.type === 'feature') { - features.push(i); - } else if (i.type === 'spell') { - if (i.system.spellLevel != undefined) { - spells[i.system.spellLevel].push(i); - } + } else if (i.type === 'agenda') { + agendas.push(i); + } else if (i.type === 'blasphemy') { + blasphemies.push(i); } } - + context.gear = gear; - context.features = features; - context.spells = spells; + context.agendas = agendas; + context.blasphemies = blasphemies; } _calculateRanges(context) { diff --git a/system.json b/system.json index d9d6171..51bfd79 100644 --- a/system.json +++ b/system.json @@ -20,7 +20,7 @@ "thumbnail": "systems/cain/assets/cain.png" } ], - "version": "1.0.16", + "version": "1.0.17", "compatibility": { "minimum": 11, "verified": "12" diff --git a/templates/actor/parts/actor-abilities.hbs b/templates/actor/parts/actor-abilities.hbs index 4db0cad..cf197b4 100644 --- a/templates/actor/parts/actor-abilities.hbs +++ b/templates/actor/parts/actor-abilities.hbs @@ -87,16 +87,12 @@
- -
-

Agendas

- {{#each items as |item|}} - {{#if (eq item.type "agenda")}} - {{#unless agendaFound}} - {{#set this "agendaFound" true}} -
    - {{/set}} - {{/unless}} + +
    +

    Agendas

    + {{#if agendas.length}} +
      + {{#each agendas as |item|}}
    1. @@ -130,26 +126,19 @@
    2. - {{/if}} - {{/each}} - {{#unless agendaFound}} -

      Drag agenda onto your sheet.

      - {{/unless}} - {{#if agendaFound}} -
    - {{/if}} -
    + {{/each}} +
+ {{else}} +

Drag agenda onto your sheet.

+ {{/if}} +
- -
-

Blasphemy Powers

- {{#each items as |item|}} - {{#if (eq item.type "blasphemy")}} - {{#unless blasphemyFound}} - {{#set this "blasphemyFound" true}} -
    - {{/set}} - {{/unless}} + +
    +

    Blasphemy Powers

    + {{#if blasphemies.length}} +
      + {{#each blasphemies as |item|}}
    1. @@ -183,17 +172,12 @@
    2. - {{/if}} - {{/each}} - {{#unless blasphemyFound}} -

      Drag blasphemies onto your sheet

      - {{/unless}} - {{#if blasphemyFound}} -
    - {{/if}} -
    + {{/each}} +
+ {{else}} +

Drag blasphemies onto your sheet

+ {{/if}}
-