From b2b6ccdf1b5381381c2da335f6aa1698700e5b69 Mon Sep 17 00:00:00 2001 From: agaringer Date: Thu, 21 Oct 2021 20:42:46 -0400 Subject: [PATCH] Fix cohort scale and quality calculation --- module/blades-item.js | 22 +++++++++++----------- template.json | 2 +- templates/items/cohort.html | 14 ++++++++------ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/module/blades-item.js b/module/blades-item.js index e9ec920..e1c31fb 100644 --- a/module/blades-item.js +++ b/module/blades-item.js @@ -56,14 +56,14 @@ export class BladesItem extends Item { prepareData() { super.prepareData(); - + const item_data = this.data; const data = item_data.data; if (item_data.type === "cohort") { - + this._prepareCohort(data); - + } if (item_data.type === "faction") { @@ -80,7 +80,7 @@ export class BladesItem extends Item { /** * Prepares Cohort data * - * @param {object} data + * @param {object} data */ _prepareCohort(data) { @@ -88,22 +88,22 @@ export class BladesItem extends Item { let scale = 0; // Adds Scale and Quality - if (this.actor) { - switch (data.cohort[0]) { + if (this.actor.data) { + switch (data.cohort) { case "Gang": - scale = parseInt(this.actor.data.data.tier[0]); - quality = parseInt(this.actor.data.data.tier[0]); + scale = parseInt(this.actor.data.data.tier); + quality = parseInt(this.actor.data.data.tier); break; case "Expert": - scale = 1; - quality = parseInt(this.actor.data.data.tier[0]) + 1; + scale = 0; + quality = parseInt(this.actor.data.data.tier) + 1; break; } } data.scale = scale; data.quality = quality; - + this.data.data = data; } } diff --git a/template.json b/template.json index 88abeb0..781092b 100644 --- a/template.json +++ b/template.json @@ -136,7 +136,7 @@ "name": "", "reputation": [0], "lair": "", - "tier": [0], + "tier": "", "deity": "", "hold": ["strong"], "experience": [0], diff --git a/templates/items/cohort.html b/templates/items/cohort.html index 88bc1b8..6533cae 100644 --- a/templates/items/cohort.html +++ b/templates/items/cohort.html @@ -6,7 +6,7 @@

- +
{{localize "BITD.Information"}}
@@ -56,11 +56,13 @@
{{!-- Scale and Quality if attached to Actor --}} - {{#if data.quality}} + {{#if (eq document.parent.documentName "Actor")}}
{{localize "BITD.ScaleAndQuality"}}
-
{{localize "BITD.Quality"}}: {{data.quality}}
-
{{localize "BITD.Scale"}}: {{data.scale}}
+
+ {{localize "BITD.Quality"}}: {{data.quality}} + {{localize "BITD.Scale"}}: {{data.scale}} +
{{/if}} @@ -97,7 +99,7 @@ - +
{{localize "BITD.Harm"}}
@@ -110,7 +112,7 @@
-
+