UNPKG

enkanetwork

Version:

API wrapper for enka.network written on TypeScript which provides localization, caching and convenience

58 lines (57 loc) 2.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Character = void 0; const index_1 = require("../index"); class Character { id; name; icons; level; friendshipLevel; rarity; element; elevations; xp; stats; constellations; skills; skillSetId; skillData; weapon; reliquaries; costumeId; costumeName; constructor(assets, language, characterInfo) { const character = assets.characters.getById(characterInfo.avatarId, characterInfo.skillDepotId); const costume = characterInfo.costumeId ? assets.costumes.getById(characterInfo.costumeId) : undefined; this.id = character.id; this.name = assets.characters.getName(character, language); this.rarity = character.qualityStars; this.element = character.element; this.icons = { avatar: assets.getAssetPath(costume ? costume.iconName : character.iconName), side: assets.getAssetPath(costume ? costume.sideIconName : character.sideIconName), gacha: assets.getAssetPath(costume ? costume.gachaIcon : character.gachaIcon), }; this.weapon = new index_1.CharacterWeapon(assets, language, characterInfo.equipList.filter((x) => x.weapon)[0]); this.reliquaries = characterInfo.equipList .filter((x) => x.reliquary) .map((reliquary) => new index_1.CharacterReliquary(assets, language, reliquary)); this.stats = new index_1.CharacterStats(characterInfo.fightPropMap); this.constellations = character.talents.map((talent) => new index_1.CharacterConstellation(assets, language, talent, characterInfo.talentIdList || [])); this.skills = character.skills.map((skill) => new index_1.CharacterSkill(assets, language, skill, characterInfo.skillLevelMap[skill] || 0, characterInfo.proudSkillExtraLevelMap ?? {})); this.skillSetId = character.skillDepotId; this.skillData = characterInfo.inherentProudSkillList; this.level = Number(characterInfo.propMap["4001"].ival || 0); this.elevations = Number(characterInfo.propMap["1002"].ival || 0); this.xp = Number(characterInfo.propMap["1001"].ival || 0); this.friendshipLevel = characterInfo.fetterInfo.expLevel; this.costumeId = costume ? costume.id : null; this.costumeName = costume ? assets.costumes.getName(costume, language) : null; } } exports.Character = Character;