From c21f2f66b3585db82b86b600eaf8507b87e01c27 Mon Sep 17 00:00:00 2001 From: Bill Date: Mon, 6 Sep 2021 02:33:03 -0400 Subject: [PATCH] Add badgePointLimit to localization --- .../localization/INitroLocalizationManager.ts | 1 + .../localization/NitroLocalizationManager.ts | 25 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/nitro/localization/INitroLocalizationManager.ts b/src/nitro/localization/INitroLocalizationManager.ts index 450f1211..5b759307 100644 --- a/src/nitro/localization/INitroLocalizationManager.ts +++ b/src/nitro/localization/INitroLocalizationManager.ts @@ -11,4 +11,5 @@ export interface INitroLocalizationManager extends INitroManager registerParameter(key: string, parameter: string, value: string): void; getBadgeName(key: string): string; getBadgeDesc(key: string): string; + setBadgePointLimit(badge: string, point: number): void; } diff --git a/src/nitro/localization/NitroLocalizationManager.ts b/src/nitro/localization/NitroLocalizationManager.ts index a1183edb..47d987cb 100644 --- a/src/nitro/localization/NitroLocalizationManager.ts +++ b/src/nitro/localization/NitroLocalizationManager.ts @@ -8,6 +8,7 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca { private _definitions: Map; private _parameters: Map>; + private _badgePointLimits: Map; private _romanNumerals: string[]; private _pendingUrls: string[]; @@ -17,6 +18,7 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca this._definitions = new Map(); this._parameters = new Map(); + this._badgePointLimits = new Map(); this._romanNumerals = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII', 'XIV', 'XV', 'XVI', 'XVII', 'XVIII', 'XIX', 'XX', 'XXI', 'XXII', 'XXIII', 'XXIV', 'XXV', 'XXVI', 'XXVII', 'XXVIII', 'XXIX', 'XXX']; this._pendingUrls = []; } @@ -84,6 +86,16 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca return true; } + public getBadgePointLimit(badge: string): number + { + return this._badgePointLimits.get(badge); + } + + public setBadgePointLimit(badge: string, point: number): void + { + this._badgePointLimits.set(badge, point); + } + public getRomanNumeral(number: number): string { return this._romanNumerals[Math.max(0, (number - 1))]; @@ -263,7 +275,11 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca const badge = new BadgeBaseAndLevel(key); const keys = [ 'badge_name_' + key, 'badge_name_' + badge.base ]; - return this._Str_2103(this.getExistingKey(keys)).replace('%roman%', this.getRomanNumeral(badge.level)); + let name = this._Str_2103(this.getExistingKey(keys)); + + name = name.replace('%roman%', this.getRomanNumeral(badge.level)); + + return name; } public getBadgeDesc(key: string): string @@ -271,7 +287,12 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca const badge = new BadgeBaseAndLevel(key); const keys = [ 'badge_desc_' + key, 'badge_desc_' + badge.base ]; - return this._Str_2103(this.getExistingKey(keys)).replace('%roman%', this.getRomanNumeral(badge.level)); + let desc = this._Str_2103(this.getExistingKey(keys)); + + desc = desc.replace('%limit$', this.getBadgePointLimit(key).toString()); + desc = desc.replace('%roman%', this.getRomanNumeral(badge.level)); + + return desc; } private getExistingKey(keys: string[]): string