UNPKG

enka-network-api

Version:

Enka-network API wrapper for Genshin Impact.

30 lines (29 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Constellation = void 0; const config_file_js_1 = require("config_file.js"); const AssetsNotFoundError_1 = require("../../errors/AssetsNotFoundError"); const ImageAssets_1 = require("../assets/ImageAssets"); const TextAssets_1 = require("../assets/TextAssets"); const StatProperty_1 = require("../StatProperty"); const ExcelTransformer_1 = require("../../client/ExcelTransformer"); class Constellation { constructor(data, enka) { this.enka = enka; this._data = data; const json = new config_file_js_1.JsonReader(ExcelTransformer_1.excelJsonOptions, data); this.id = json.getAsNumber("talentId"); this.name = new TextAssets_1.TextAssets(json.getAsNumber("nameTextMapHash"), enka); this.description = new TextAssets_1.TextAssets(json.getAsNumber("descTextMapHash"), enka); this.icon = new ImageAssets_1.ImageAssets(json.getAsString("icon"), enka); this.addProps = StatProperty_1.StatProperty.parseAddProps(json.get("addProps"), enka); this.paramList = json.has("paramList") ? json.get("paramList").mapArray((_, p) => p.getAsNumber()) : []; } static getById(id, enka) { const data = enka.cachedAssetsManager.getExcelData("AvatarTalentExcelConfigData", id); if (!data) throw new AssetsNotFoundError_1.AssetsNotFoundError("Constellation", id); return new Constellation(data, enka); } } exports.Constellation = Constellation;