UNPKG

genshin-manager

Version:

<div align="center"> <p> <a href="https://www.npmjs.com/package/genshin-manager"><img src="https://img.shields.io/npm/v/genshin-manager.svg?maxAge=3600" alt="npm version" /></a> <a href="https://www.npmjs.com/package/genshin-manager"><img src="https:

117 lines (116 loc) 4.78 kB
"use strict"; var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.CharacterInfo = void 0; const Client_1 = require("../../client/Client"); const OutOfRangeError_1 = require("../../errors/OutOfRangeError"); const types_1 = require("../../types"); /** * Class of information about the character. */ class CharacterInfo { /** * Create a CharacterInfo * @param characterId Character ID * @param skillDepotId Skill depot ID */ constructor(characterId, skillDepotId) { /** * Character max level */ this.maxLevel = 90; /** * Inherent skill order */ this.inherentSkillOrder = []; /** * Map of skill ID and proud ID * @key Skill ID * @value Proud ID */ this.proudMap = new Map(); this.id = characterId; const costumeDatas = Object.values(Client_1.Client._getCachedExcelBinOutputByName('AvatarCostumeExcelConfigData')); const defaultCostumeData = costumeDatas.find((k) => k.characterId === this.id && k.quality === 0); this.defaultCostumeId = defaultCostumeData.skinId; const avatarJson = Client_1.Client._getJsonFromCachedExcelBinOutput('AvatarExcelConfigData', this.id); this.depotId = skillDepotId && [10000005, 10000007].includes(this.id) ? skillDepotId : avatarJson.skillDepotId; const depotJson = Client_1.Client._getJsonFromCachedExcelBinOutput('AvatarSkillDepotExcelConfigData', this.depotId); const skillJson = depotJson.energySkill ? Client_1.Client._getJsonFromCachedExcelBinOutput('AvatarSkillExcelConfigData', depotJson.energySkill) : undefined; this.name = Client_1.Client._cachedTextMap.get(String(avatarJson.nameTextMapHash)) || ''; this.element = skillJson ? types_1.ElementKeys[skillJson.costElemType] : undefined; this.skillOrder = ([501, 701].includes(this.depotId) ? depotJson.skills.slice(0, 1) : depotJson.skills .slice(0, 2) .concat(depotJson.energySkill)).filter((skillId) => skillId !== 0 && skillId !== undefined); depotJson.inherentProudSkillOpens.forEach((k) => { if (k.proudSkillGroupId === undefined || k.proudSkillGroupId === 0) return; const proudSkillJson = Client_1.Client._getJsonFromCachedExcelBinOutput('ProudSkillExcelConfigData', k.proudSkillGroupId)[1]; if (!proudSkillJson) return; if (proudSkillJson.isHideLifeProudSkill) return; this.inherentSkillOrder.push(k.proudSkillGroupId); }); this.constellationIds = depotJson.talents.filter((constId) => constId !== 0); this.skillOrder = this.skillOrder.filter((skillId) => { const skillJson = Client_1.Client._getJsonFromCachedExcelBinOutput('AvatarSkillExcelConfigData', skillId); const proudId = skillJson.proudSkillGroupId; if (proudId) this.proudMap.set(skillId, proudId); return proudId !== undefined; }); const qualityMap = { QUALITY_ORANGE: 5, QUALITY_PURPLE: 4, QUALITY_ORANGE_SP: 0, }; this.rarity = qualityMap[avatarJson.qualityType]; this.weaponType = avatarJson.weaponType; this.bodyType = avatarJson.bodyType; } /** * Get all character IDs * @returns All character IDs */ static get allCharacterIds() { const avatarDatas = Object.values(Client_1.Client._getCachedExcelBinOutputByName('AvatarExcelConfigData')); return avatarDatas .filter((k) => !('rarity' in k)) .map((k) => k.id); } /** * Get character ID by name * @param name Character name * @returns Character ID */ static getCharacterIdByName(name) { return Client_1.Client._searchIdInExcelBinOutByText('AvatarExcelConfigData', name).map((k) => +k); } /** * Get traveler skill depot IDs * @param characterId Character ID * @returns skill depot IDs */ static getTravelerSkillDepotIds(characterId) { if (![10000005, 10000007].includes(characterId)) throw new OutOfRangeError_1.OutOfRangeError('characterId', characterId, 10000005, 10000007); const avatarData = Client_1.Client._getJsonFromCachedExcelBinOutput('AvatarExcelConfigData', characterId); return avatarData.candSkillDepotIds; } } exports.CharacterInfo = CharacterInfo; _a = CharacterInfo; (() => { Client_1.Client._addExcelBinOutputKeyFromClassPrototype(_a.prototype); })();