UNPKG

enka-network-api

Version:

Enka-network API wrapper for Genshin Impact.

34 lines (33 loc) 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Skill = 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 DynamicTextAssets_1 = require("../../assets/DynamicTextAssets"); const ExcelTransformer_1 = require("../../../client/ExcelTransformer"); /** * Normal Attack, Elemental Skill, and Elemental Burst. Not including Passive Talents. */ class Skill { constructor(data, enka) { this.enka = enka; this._data = data; const json = new config_file_js_1.JsonReader(ExcelTransformer_1.excelJsonOptions, this._data); this.id = json.getAsNumber("id"); this.name = new TextAssets_1.TextAssets(json.getAsNumber("nameTextMapHash"), enka); this.description = new DynamicTextAssets_1.DynamicTextAssets(json.getAsNumber("descTextMapHash"), {}, enka); this.icon = new ImageAssets_1.ImageAssets(json.getAsString("skillIcon"), enka); } static getById(id, enka) { return new Skill(this._getJsonObjectById(id, enka), enka); } static _getJsonObjectById(id, enka) { const data = enka.cachedAssetsManager.getExcelData("AvatarSkillExcelConfigData", id); if (!data) throw new AssetsNotFoundError_1.AssetsNotFoundError("Skill", id); return data; } } exports.Skill = Skill;