Skip to content

Commit

Permalink
Merge pull request #13 from diabeatz96/drag-onto-your-sheet-never-van…
Browse files Browse the repository at this point in the history
…ishes

fixed issue in prepare items, added in 2 arrays for context with item…
  • Loading branch information
diabeatz96 authored Aug 25, 2024
2 parents 014e102 + 35b452e commit e086dfb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 67 deletions.
4 changes: 0 additions & 4 deletions module/cain.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
33 changes: 10 additions & 23 deletions module/sheets/actor-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion system.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"thumbnail": "systems/cain/assets/cain.png"
}
],
"version": "1.0.16",
"version": "1.0.17",
"compatibility": {
"minimum": 11,
"verified": "12"
Expand Down
62 changes: 23 additions & 39 deletions templates/actor/parts/actor-abilities.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,12 @@
</div>
<!-- Items Section -->
<div class="items-section" style="display: flex; justify-content: space-between;">
<!-- Agendas -->
<div class="agendas" style="width: 48%;">
<h2>Agendas</h2>
{{#each items as |item|}}
{{#if (eq item.type "agenda")}}
{{#unless agendaFound}}
{{#set this "agendaFound" true}}
<ol class='items-list'>
{{/set}}
{{/unless}}
<!-- Agendas -->
<div class="agendas" style="width: 48%;">
<h2>Agendas</h2>
{{#if agendas.length}}
<ol class='items-list'>
{{#each agendas as |item|}}
<li class='item flexrow' data-item-id='{{item._id}}'>
<div class='item-name flexrow'>
<div class='item-image'>
Expand Down Expand Up @@ -130,26 +126,19 @@
</a>
</div>
</li>
{{/if}}
{{/each}}
{{#unless agendaFound}}
<p class="psychedelic-text">Drag agenda onto your sheet.</p>
{{/unless}}
{{#if agendaFound}}
</ol>
{{/if}}
</div>
{{/each}}
</ol>
{{else}}
<p class="psychedelic-text">Drag agenda onto your sheet.</p>
{{/if}}
</div>

<!-- Blasphemy Powers -->
<div class="blasphemy-powers" style="width: 48%;">
<h2>Blasphemy Powers</h2>
{{#each items as |item|}}
{{#if (eq item.type "blasphemy")}}
{{#unless blasphemyFound}}
{{#set this "blasphemyFound" true}}
<ol class='items-list'>
{{/set}}
{{/unless}}
<!-- Blasphemy Powers -->
<div class="blasphemy-powers" style="width: 48%;">
<h2>Blasphemy Powers</h2>
{{#if blasphemies.length}}
<ol class='items-list'>
{{#each blasphemies as |item|}}
<li class='item flexrow' data-item-id='{{item._id}}'>
<div class='item-name flexrow'>
<div class='item-image'>
Expand Down Expand Up @@ -183,17 +172,12 @@
</a>
</div>
</li>
{{/if}}
{{/each}}
{{#unless blasphemyFound}}
<p class="psychedelic-text">Drag blasphemies onto your sheet</p>
{{/unless}}
{{#if blasphemyFound}}
</ol>
{{/if}}
</div>
{{/each}}
</ol>
{{else}}
<p class="psychedelic-text">Drag blasphemies onto your sheet</p>
{{/if}}
</div>
</div>

<style>
.abilities-page {
Expand Down

0 comments on commit e086dfb

Please sign in to comment.