Add badgePointLimit to localization

This commit is contained in:
Bill 2021-09-06 02:33:03 -04:00
parent 25bf909d6f
commit c21f2f66b3
2 changed files with 24 additions and 2 deletions

View File

@ -11,4 +11,5 @@ export interface INitroLocalizationManager extends INitroManager
registerParameter(key: string, parameter: string, value: string): void; registerParameter(key: string, parameter: string, value: string): void;
getBadgeName(key: string): string; getBadgeName(key: string): string;
getBadgeDesc(key: string): string; getBadgeDesc(key: string): string;
setBadgePointLimit(badge: string, point: number): void;
} }

View File

@ -8,6 +8,7 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
{ {
private _definitions: Map<string, string>; private _definitions: Map<string, string>;
private _parameters: Map<string, Map<string, string>>; private _parameters: Map<string, Map<string, string>>;
private _badgePointLimits: Map<string, number>;
private _romanNumerals: string[]; private _romanNumerals: string[];
private _pendingUrls: string[]; private _pendingUrls: string[];
@ -17,6 +18,7 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
this._definitions = new Map(); this._definitions = new Map();
this._parameters = 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._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 = []; this._pendingUrls = [];
} }
@ -84,6 +86,16 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
return true; 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 public getRomanNumeral(number: number): string
{ {
return this._romanNumerals[Math.max(0, (number - 1))]; 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 badge = new BadgeBaseAndLevel(key);
const keys = [ 'badge_name_' + key, 'badge_name_' + badge.base ]; 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 public getBadgeDesc(key: string): string
@ -271,7 +287,12 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
const badge = new BadgeBaseAndLevel(key); const badge = new BadgeBaseAndLevel(key);
const keys = [ 'badge_desc_' + key, 'badge_desc_' + badge.base ]; 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 private getExistingKey(keys: string[]): string