enkanetwork
Version:
API wrapper for enka.network written on TypeScript which provides localization, caching and convenience
30 lines (29 loc) • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConstellationFinder = void 0;
const errors_1 = require("../../errors");
class ConstellationFinder {
data;
localization;
constructor(data, localization) {
this.data = data;
this.localization = localization;
}
// Searching for a **constellation** by his ID
getById(id) {
const constellation = this.data.find((constellation) => constellation.id === id);
if (!constellation)
throw new errors_1.NoDataAssetsFound(`There is no constellation with id = ${id}! (check the actuality of assets)`);
return constellation;
}
getName(constellation, language) {
const nameLocalizations = this.localization[constellation.nameTextMapHash];
if (!nameLocalizations)
throw new errors_1.NoLocalizationAssetsFound(`There is no localization for constellation with id = ${constellation.id}! (check the actuality of assets)`);
const name = nameLocalizations[language];
if (!name)
throw new errors_1.NoLanguageFound("This language is not downloaded! Check the AssetsUpdater settings");
return name;
}
}
exports.ConstellationFinder = ConstellationFinder;