diff --git a/lang/en.json b/lang/en.json index 76a6418..31d05ed 100644 --- a/lang/en.json +++ b/lang/en.json @@ -288,6 +288,14 @@ "TYPES.Item.gear": "Gear", "TYPES.Item.motivation": "Motivation", "TYPES.Item.weapon": "Weapon", + "TYPES.Item.tome": "Tome", + "TYPES.Item.ritual": "Ritual", + + "DG.Gear.Tomes": "TOMES", + "DG.Gear.Rituals": "RITUALS", + + "DG.Tomes.Name": "Name", + "DG.Ritual.Name": "Name", "DG.Tome.Name": "Name", "DG.ItemWindow.Tome.Description": "Description", diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index c8a0800..1047198 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -145,6 +145,8 @@ export default class DeltaGreenActorSheet extends ActorSheet { const armor = []; const weapons = []; const gear = []; + const tomes = []; + const rituals = []; // Iterate through items, allocating to containers // let totalWeight = 0; @@ -158,6 +160,10 @@ export default class DeltaGreenActorSheet extends ActorSheet { weapons.push(i); } else if (i.type === "gear") { gear.push(i); + } else if (i.type === "tome") { + tomes.push(i); + } else if (i.type === "ritual") { + rituals.push(i); } } @@ -215,10 +221,48 @@ export default class DeltaGreenActorSheet extends ActorSheet { }); } + if (actorData.system.settings.sorting.tomeSortAlphabetical) { + tomes.sort(function (a, b) { + let x = a.name.toLowerCase(); + let y = b.name.toLowerCase(); + if (x < y) { + return -1; + } + if (x > y) { + return 1; + } + return 0; + }); + } else { + tomes.sort(function (a, b) { + return a.sort - b.sort; + }); + } + + if (actorData.system.settings.sorting.ritualSortAlphabetical) { + rituals.sort(function (a, b) { + let x = a.name.toLowerCase(); + let y = b.name.toLowerCase(); + if (x < y) { + return -1; + } + if (x > y) { + return 1; + } + return 0; + }); + } else { + rituals.sort(function (a, b) { + return a.sort - b.sort; + }); + } + // Assign and return actorData.armor = armor; actorData.weapons = weapons; actorData.gear = gear; + actorData.rituals = rituals; + actorData.tomes = tomes; } // Can add extra buttons to form header here if necessary @@ -566,6 +610,16 @@ export default class DeltaGreenActorSheet extends ActorSheet { "system.settings.sorting.gearSortAlphabetical": !this.actor.system.settings.sorting.gearSortAlphabetical, }); + } else if (itemType === "tome") { + this.actor.update({ + "system.settings.sorting.tomeSortAlphabetical": + !this.actor.system.settings.sorting.tomeSortAlphabetical, + }); + } else if (itemType === "ritual") { + this.actor.update({ + "system.settings.sorting.ritualSortAlphabetical": + !this.actor.system.settings.sorting.ritualSortAlphabetical, + }); } }); } diff --git a/template.json b/template.json index 81ef08b..3fa41b2 100644 --- a/template.json +++ b/template.json @@ -45,7 +45,9 @@ "sorting": { "weaponSortAlphabetical": false, "armorSortAlphabetical": false, - "gearSortAlphabetical": false + "gearSortAlphabetical": false, + "tomeSortAlphabetical": false, + "ritualSortAlphabetical": false }, "rolling": { "defaultPercentileModifier": 20 diff --git a/templates/actor/partials/equipment-partial.html b/templates/actor/partials/equipment-partial.html index cc09a90..32881ea 100644 --- a/templates/actor/partials/equipment-partial.html +++ b/templates/actor/partials/equipment-partial.html @@ -211,4 +211,102 @@ + + +{{!-- TOMES --}} + +
+ +
+ {{localize 'DG.Gear.Tomes'}} +
+ +
    + +
  1. + +
    + {{#if actor.system.settings.sorting.tomeSortAlphabetical}} + + {{else}} + + {{/if}} +
    + +
    {{localize 'DG.Tomes.Name'}}
    + + + +
  2. + + {{#each actor.tomes as |item id|}} + +
  3. + +
    + +

    {{item.name}}

    + +
    + + +
    + +
  4. + + {{/each}} + +
+ +
+ +{{!-- RITUALS --}} + +
+ +
+ {{localize 'DG.Gear.Rituals'}} +
+ +
    + +
  1. + +
    + {{#if actor.system.settings.sorting.ritualSortAlphabetical}} + + {{else}} + + {{/if}} +
    + +
    {{localize 'DG.Ritual.Name'}}
    + + + +
  2. + + {{#each actor.rituals as |item id|}} + +
  3. + +
    + +

    {{item.name}}

    + +
    + + +
    + +
  4. + + {{/each}} + +
+
\ No newline at end of file