From a5e240ab75c90ed4b909c5efa2a475d3bee15231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Fri, 8 Jan 2021 23:31:42 +0100 Subject: [PATCH] Localize Error Messages. --- src/lang/en.json | 4 +++- src/module/rolls/check.ts | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lang/en.json b/src/lang/en.json index 267e0b2c..a768c9f4 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -110,5 +110,7 @@ "DS4.ProfileWeight": "Weight", "DS4.ProfileEyeColor": "Eye Color", "DS4.ProfileSpecialCharacteristics": "Special Characteristics", - "DS4.WarningManageActiveEffectOnOwnedItem": "Managing Active Effects within an Owned Item is not currently supported and will be added in a subsequent update." + "DS4.WarningManageActiveEffectOnOwnedItem": "Managing Active Effects within an Owned Item is not currently supported and will be added in a subsequent update.", + "DS4.ErrorDiceCritOverlap": "There's an overlap between Fumbles and Coups", + "DS4.ErrorExplodingRecursionLimitExceeded": "Maximum recursion depth for exploding dice roll exceeded" } diff --git a/src/module/rolls/check.ts b/src/module/rolls/check.ts index 4dffa96c..e931f680 100644 --- a/src/module/rolls/check.ts +++ b/src/module/rolls/check.ts @@ -40,7 +40,7 @@ export class DS4Check extends DiceTerm { ? parseInt(parseMinCritFailure) : DS4Check.DEFAULT_MIN_CRIT_FAILURE; if (this.minCritFailure <= this.maxCritSuccess) - throw new SyntaxError("There's an overlap between Fumbles and Coups"); + throw new SyntaxError(game.i18n.localize("DS4.ErrorDiceCritOverlap")); } } @@ -98,23 +98,23 @@ export class DS4Check extends DiceTerm { this.results = (this.results as Array) .map((r) => { - const intermedResult = [r]; + const intermediateResults = [r]; let checked = 0; - while (checked < intermedResult.length) { - const r = (intermedResult as Array)[checked]; + while (checked < intermediateResults.length) { + const r = (intermediateResults as Array)[checked]; checked++; if (!r.active) continue; if (r.dice[0] <= this.maxCritSuccess) { r.exploded = true; const newRoll = this.rollWithDifferentBorders({}, true); - intermedResult.push(newRoll); + intermediateResults.push(newRoll); } - if (checked > 1000) throw new Error("Maximum recursion depth for exploding dice roll exceeded"); + if (checked > 1000) throw new Error(game.i18n.localize("DS4.ErrorExplodingRecursionLimitExceeded")); } - return intermedResult; + return intermediateResults; }) .reduce((acc, cur) => { return acc.concat(cur);