From ff0448ad537c8751d207266dfe7f770d459f8103 Mon Sep 17 00:00:00 2001 From: Hada Ionut Date: Sun, 22 Aug 2021 16:58:54 +0300 Subject: [PATCH] Release prep --- module.json | 6 +++--- scripts/Utils/ConversionEngineNew.js | 12 ++++++------ scripts/foundry-mgl.js | 1 - 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/module.json b/module.json index 5d70bb9..62569c1 100644 --- a/module.json +++ b/module.json @@ -10,7 +10,7 @@ "url": "https://github.com/HadaIonut" } ], - "version": "1.1.4", + "version": "1.1.6", "esmodules": [ "scripts/foundry-mgl.js" ], @@ -28,7 +28,7 @@ "minimumCoreVersion": "0.8.2", "compatibleCoreVersion": "0.8.3", "url": "https://github.com/HadaIonut/Foundry-mgl", - "manifest": "https://github.com/HadaIonut/Foundry-mgl/releases/download/v1.1.4/module.json", - "download": "https://github.com/HadaIonut/Foundry-mgl/releases/download/v1.1.4/module.zip", + "manifest": "https://github.com/HadaIonut/Foundry-mgl/releases/download/v1.1.6/module.json", + "download": "https://github.com/HadaIonut/Foundry-mgl/releases/download/v1.1.6/module.zip", "changelog": "" } diff --git a/scripts/Utils/ConversionEngineNew.js b/scripts/Utils/ConversionEngineNew.js index f7d6340..b86de46 100644 --- a/scripts/Utils/ConversionEngineNew.js +++ b/scripts/Utils/ConversionEngineNew.js @@ -114,7 +114,7 @@ const convertValueToMetric = (value, unit) => { } const convertText = (text) => { - return !text ? '' : text.replace(/(\b[^\d\W]+\b )?(\b[^\d\W]+\b)([ -])(feet|foot)/g, (_0, wordNumber1, wordNumber2, separator, unit) => { + return text?.replace(/(\b[^\d\W]+\b )?(\b[^\d\W]+\b)([ -])(feet|foot)/g, (_0, wordNumber1, wordNumber2, separator, unit) => { const capitalized = wordNumber1 !== wordNumber1?.toLowerCase(); const selectedNumber = numberSelector(wordNumber1 ? wordNumber1?.toLowerCase().trim() : '', wordNumber2?.toLowerCase()); if (selectedNumber.number) { @@ -123,15 +123,15 @@ const convertText = (text) => { return capitalized ? `${returnText.charAt(0).toUpperCase()}${returnText.slice(1)}` : returnText; } return `${selectedNumber.text}${separator}${unit}`; - }).replace(/([0-9]+) (to|and) ([0-9]+) (feet|inch|foot|ft\.)/g, (_0, number1, separatorWord, number2, units) => { + })?.replace(/([0-9]+) (to|and) ([0-9]+) (feet|inch|foot|ft\.)/g, (_0, number1, separatorWord, number2, units) => { return `${convertValueToMetric(number1, units)} ${separatorWord} ${convertValueToMetric(number2, units)} ${convertStringFromImperialToMetric(units)}` - }).replace(/([0-9]{1,3}(,[0-9]{3})+)([ -])(feet|foot|pounds)/g, (_0, number, _1, separator, label) => { + })?.replace(/([0-9]{1,3}(,[0-9]{3})+)([ -])(feet|foot|pounds)/g, (_0, number, _1, separator, label) => { return `${convertValueToMetric(number, label)}${separator}${convertStringFromImperialToMetric(label)}`; - }).replace(/([0-9]+)\/([0-9]+) (feet|inch|foot|ft\.)/g, (_0, firstNumber, secondNumber, label) => { + })?.replace(/([0-9]+)\/([0-9]+) (feet|inch|foot|ft\.)/g, (_0, firstNumber, secondNumber, label) => { return `${convertValueToMetric(firstNumber, label)}/${convertValueToMetric(secondNumber, label)} ${convertStringFromImperialToMetric(label)}`; - }).replace(/([0-9]+)(\W| | cubic |-|){1,2}(feet|inch|foot|ft\.|pounds|lbs\.|pound|lbs|lb|ft|mile)/g, (_0, number, separator, label) => { + })?.replace(/([0-9]+)(\W| | cubic |-|){1,2}(feet|inch|foot|ft\.|pounds|lbs\.|pound|lbs|lb|ft|mile)/g, (_0, number, separator, label) => { return `${convertValueToMetric(number, label)}${separator}${convertStringFromImperialToMetric(label)}`; - }).replace(/(several \w+ )(feet|yards)/g, (_0, several, unit) => { + })?.replace(/(several \w+ )(feet|yards)/g, (_0, several, unit) => { return `${several}${convertStringFromImperialToMetric(unit)}`; }) } diff --git a/scripts/foundry-mgl.js b/scripts/foundry-mgl.js index 330460f..29c8558 100644 --- a/scripts/foundry-mgl.js +++ b/scripts/foundry-mgl.js @@ -14,7 +14,6 @@ import {consoleLog} from "./Utils/Utils.js"; * Defines distance units and sets encumbrance */ Hooks.on('init', () => { - CONFIG.debug.hooks = true; consoleLog("Changing labels 'Feet' and 'Miles' to 'Meters' and 'Kilometers'.") DND5E.distanceUnits["m"] = game.i18n.localize("metricsystem.meters"); DND5E.distanceUnits["km"] = game.i18n.localize("metricsystem.kilometers");