From 46b691d5259582989f16342d8ea01417a80c1296 Mon Sep 17 00:00:00 2001 From: Antho Date: Thu, 17 Jun 2021 23:56:01 -0400 Subject: [PATCH] Add Loot Sheet as actor sheet --- module/sheets/WitcherActorSheet.js | 13 ++- scripts/TheWitcherTRPG.js | 1 + styles/system-styles.css | 6 ++ system.json | 2 +- template.json | 7 +- templates/partials/tab-inventory.html | 8 +- templates/sheets/actor/actor-sheet.html | 3 + templates/sheets/actor/loot-sheet.html | 110 ++++++++++++++++++++++++ 8 files changed, 143 insertions(+), 7 deletions(-) create mode 100644 templates/sheets/actor/loot-sheet.html diff --git a/module/sheets/WitcherActorSheet.js b/module/sheets/WitcherActorSheet.js index 417b1288..be9a79f5 100644 --- a/module/sheets/WitcherActorSheet.js +++ b/module/sheets/WitcherActorSheet.js @@ -34,6 +34,7 @@ export default class WitcherActorSheet extends ActorSheet { data.weapons = data.items.filter(function(item) {return item.type=="weapon"}); data.armors = data.items.filter(function(item) {return item.type=="armor" || item.type == "enhancement"}); data.components = data.items.filter(function(item) {return item.type=="component" && item.data.type!="substances"}); + data.allComponents = data.items.filter(function(item) {return item.type=="component"}); data.valuables = data.items.filter(function(item) {return item.type=="valuable" || item.type == "mount" || item.type =="alchemical" || item.type =="mutagen" }); data.diagrams = data.items.filter(function(item) {return item.type=="diagrams"}); data.spells = data.items.filter(function(item) {return item.type=="spell"}); @@ -62,6 +63,15 @@ export default class WitcherActorSheet extends ActorSheet { } return Math.ceil(total) } + Array.prototype.cost = function () { + var total = 0 + for ( var i = 0, _len = this.length; i < _len; i++ ) { + if (this[i]["data"]["cost"] && this[i]["data"]["quantity"]){ + total += Number(this[i]["data"]["quantity"]) * Number(this[i]["data"]["cost"]) + } + } + return Math.ceil(total) + } data.totalStats = this.calc_total_stats(data) data.totalSkills = this.calc_total_skills(data) @@ -89,7 +99,8 @@ export default class WitcherActorSheet extends ActorSheet { data.loots = data.items.filter(function(item) {return item.type=="component" || item.type == "valuable" || item.type=="diagrams" || item.type=="armor" || item.type=="alchemical"}); data.notes = data.items.filter(function(item) {return item.type=="note"}); - data.TotalWeight = data.items.weight(); + data.totalWeight = data.items.weight(); + data.totalCost = data.items.cost(); data.noviceSpells = data.items.filter(function(item) {return item.type=="spell" && item.data.level=="novice" && (item.data.class=="Spells" || item.data.class=="Invocations" || item.data.class=="Witcher")}); data.journeymanSpells = data.items.filter(function(item) {return item.type=="spell" && item.data.level=="journeyman" && (item.data.class=="Spells" || item.data.class=="Invocations" || item.data.class=="Witcher")}); diff --git a/scripts/TheWitcherTRPG.js b/scripts/TheWitcherTRPG.js index d6e838aa..97ee5d58 100644 --- a/scripts/TheWitcherTRPG.js +++ b/scripts/TheWitcherTRPG.js @@ -9,6 +9,7 @@ async function preloadHandlebarsTemplates(){ const templatePath =[ "systems/TheWitcherTRPG/templates/sheets/actor/character-sheet.html", "systems/TheWitcherTRPG/templates/sheets/actor/monster-sheet.html", + "systems/TheWitcherTRPG/templates/sheets/actor/loot-sheet.html", "systems/TheWitcherTRPG/templates/partials/character-header.html", "systems/TheWitcherTRPG/templates/partials/tab-skills.html", "systems/TheWitcherTRPG/templates/partials/tab-profession.html", diff --git a/styles/system-styles.css b/styles/system-styles.css index b3c87296..16d21478 100644 --- a/styles/system-styles.css +++ b/styles/system-styles.css @@ -690,4 +690,10 @@ input.luck-value { .spacer { height: 55px; +} + +.left-loot-border { + border-right: solid 1px; + width: 150px; + height: 100%; } \ No newline at end of file diff --git a/system.json b/system.json index 183c839b..9abd14b1 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "name": "TheWitcherTRPG", "title": "TheWitcherTRPG - fvtt", "description": "Many details here.", - "version": 0.19, + "version": 0.20, "author": "TechAntho", "scripts": [ ], diff --git a/template.json b/template.json index 2b74de2e..cda09fa6 100644 --- a/template.json +++ b/template.json @@ -2,7 +2,8 @@ "Actor": { "types": [ "character", - "monster" + "monster", + "loot" ], "templates":{ "baseActor": { @@ -589,6 +590,10 @@ "monsterLore": "", "monsterLoreSkillValue": "", "customStat": false + }, + "loot": { + "templates": ["baseActor"], + "description":"" } }, "Item": { diff --git a/templates/partials/tab-inventory.html b/templates/partials/tab-inventory.html index 431c8290..3cefaa9f 100644 --- a/templates/partials/tab-inventory.html +++ b/templates/partials/tab-inventory.html @@ -322,12 +322,12 @@

Components - {{TotalWeight}}/{{data.coreStats.enc.value}} + {{totalWeight}}/{{data.coreStats.enc.value}} -{{#if (gte TotalWeight data.coreStats.enc.value)}} +{{#if (gte totalWeight data.coreStats.enc.value)}}
{{/if}} -{{#if (lt TotalWeight data.coreStats.enc.value)}} - +{{#if (lt totalWeight data.coreStats.enc.value)}} + {{/if}} \ No newline at end of file diff --git a/templates/sheets/actor/actor-sheet.html b/templates/sheets/actor/actor-sheet.html index feddf202..1f141f59 100644 --- a/templates/sheets/actor/actor-sheet.html +++ b/templates/sheets/actor/actor-sheet.html @@ -5,5 +5,8 @@ {{#if (eq actor.type "monster")}} {{> "systems/TheWitcherTRPG/templates/sheets/actor/monster-sheet.html"}} {{/if}} + {{#if (eq actor.type "loot")}} + {{> "systems/TheWitcherTRPG/templates/sheets/actor/loot-sheet.html"}} + {{/if}} \ No newline at end of file diff --git a/templates/sheets/actor/loot-sheet.html b/templates/sheets/actor/loot-sheet.html new file mode 100644 index 00000000..0846e725 --- /dev/null +++ b/templates/sheets/actor/loot-sheet.html @@ -0,0 +1,110 @@ +

+
+
+
+
+ +
+
+ {{totalWeight}} +
+
+ +
+
+ {{totalCost}} +
+
+
+ +

Weapons

+ + + + + + + + + + + {{#each weapons as |item id|}} + + + + + + + + + + + + {{/each}} +
QtyNameWeightCost
+

Armors

+ + {{#each armors as |item id|}} + + + + + + + + + + + + {{/each}} +
+

Valuables

+ + {{#each valuables as |item id|}} + + + + + + + + + + + + {{/each}} +
+

Diagrams

+ + {{#each diagrams as |item id|}} + + + + + + + + + + + + {{/each}} +
+

Components

+ + {{#each allComponents as |item id|}} + + + + + + + + + + + + {{/each}} +
+ +
\ No newline at end of file