From f6480ef03358e4c0486572612b4f9a00d4734e58 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Wed, 26 May 2021 20:18:08 +0200 Subject: [PATCH] Don't fail on characters with hidden mounts/minions --- create-card.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/create-card.js b/create-card.js index 25731d9..ad8d07d 100644 --- a/create-card.js +++ b/create-card.js @@ -214,8 +214,15 @@ class CardCreator { } // Minion & Mount percentages - const mountsPct = Math.ceil((data.Mounts.length / this.countMount) * 100); - const minionsPct = Math.ceil((data.Minions.length / this.countMinion) * 100); + var mountsPct = '??'; + if (data.Mounts !== null) { + mountsPct = Math.ceil((data.Mounts.length / this.countMount) * 100); + } + + var minionsPct = '??'; + if (data.Minions !== null) { + minionsPct = Math.ceil((data.Minions.length / this.countMinion) * 100); + } const mountsMeasure = ctx.measureText(`${mountsPct}%`); const minionsMeasure = ctx.measureText(`${minionsPct}%`);