Skip to content

Commit

Permalink
add README and fix many names.
Browse files Browse the repository at this point in the history
  • Loading branch information
kravetsone committed Sep 17, 2022
1 parent c38865a commit a1762bf
Show file tree
Hide file tree
Showing 14 changed files with 234 additions and 65 deletions.
179 changes: 176 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
<div align='center'>
<a href='https://github.com/kravetsone/enkaNetwork/tree/main/examples'><b>examples</b></a>
<span>&nbsp;&nbsp;</span>
<a href='#changelog'><b>changelog</b></a>
<a href='#-response-structure'><b>structure</b></a>
</div>
<br>

<div align='center'>
<img src="https://img.shields.io/npm/dt/enkaNetwork.svg" alt="Downloads" href="https://npmjs.com/package/enkaNetwork" />
<img src="https://img.shields.io/npm/dm/enkaNetwork.svg" alt="Downloads/month" href="https://npmjs.com/package/enkaNetwork" />
Expand All @@ -21,4 +20,178 @@
<img src="https://img.shields.io/npm/v/enkaNetwork.svg" alt="npm" href="https://npmjs.com/package/enkaNetwork" />
</div>

## Soon...
## 📦 Download

- **используя `npm`**
```shell
npm i enkanetwork
```
- **используя `Yarn`**
```shell
yarn add enkanetwork
```
# 🛠️ Usage

```js
const { enkaNetwork } = require("enkanetwork"); //import { enkaNetwork } from "enkanetwork";
const enka = new enkaNetwork({language: "EN"});
```
| Key | In API | Type | Description | Required? |
| --------- | ------ | ------ | -------------------------------------------------------------------------------------------------------------- | ------------ |
| language | - | number | The language to be used in the localization of names (characters, artifacts, etc.). Default is «EN» | - |
```js
const user = await enka.fetchUser(700832641);
```
| Key | In API | Type | Description | Required? |
| --------- | ------ | ------ | ------------------------ | ------------ |
| UID | - | number | `UID` from the game | + |
# ⚙ Response structure
## FetchUser
| Key | In API | Type | Description |
| --------- | ---------- | ------ | ------------------------------ |
| player | playerInfo | object | See [Player](#player) |
| characters | avatarInfoList | array | See [Characters](#characters) |
| ttl | ttl | number | Cache lifetime in milliseconds |
## Player
| Key | In API | Type | Description |
| ----------------- | -------------------- | ------ | ------------------------------------------------ |
| nickname | nickname | string | Profile nickname |
| signature | signature | string | Profile description |
| level | level | number | User rank level |
| worldLevel | worldLevel | number | User world level |
| nameCard | - | object | See [NameCard](#namecard) |
| achievements | finishAchievementNum | number | Achievements count |
| abyssFloor | towerFloorIndex | number | The floor of the abyss passed by the player |
| abyssLevel | towerLevelIndex | number | The hall of the abyss floor passed by the player |
| charactersPreview | showAvatarInfoList | array | See [CharacterPreview](#characterpreview) |
| nameCardsPreview | showNameCardIdList | array | See [NameCard](#namecard) |
| profilePicture | profilePicture | object | See [ProfilePicture](#profilepicture) |
### NameCard
| Key | In API | Type | Description |
| --------- | ---------- | ------ | ------------------------------ |
| id | nameCardId | number | Namecard id |
| name | - | string | Localized namecard name |
| icon | - | string | URL to get the icon |
| banner | - | string | URL to get the icon banner |
| navbar | - | string | URL to get the icon navbar |
### CharacterPreview
| Key | In API | Type | Description |
| --------- | ---------- | ------ | ------------------------------ |
| id | avatarId | number | Character id |
| name | - | string | Localized character name |
| icon | - | string | URL to get the character icon |
| level | level | number | Character level |
### ProfilePicture
| Key | In API | Type | Description |
| --------- | ---------- | ------ | ------------------------------ |
| id | avatarId | number | Character id |
| name | - | string | Localized character name |
| icon | - | string | URL to get the character icon |
## Characters
| Key | In API | Type | Description |
| ----------------- | ---------------------- | ------ | ----------------------------------------------------- |
| id | avatarId | number | Character id |
| name | - | string | Localized character name |
| icons | - | object | See [Icons](#icons) |
| rarity | - | number | Character rarity (5 or 4) |
| element | - | string | See [ElementType](#elementtype) |
| level | propMap["4001"] | number | Character level |
| elevations | propMap["1002"] | number | Character elevations |
| xp | propMap["1001"] | number | Character expiriance |
| constellation | talents | array | See [CharacterConstellation](#characterconstellation) |
| skills | skills | array | See [CharacterSkill](#characterskill) |
| skillSetId | skillDepotId | number | Character Skill Set ID |
| skillData | inherentProudSkillList | array | List of Unlocked Skill Ids |
| stats | fightPropMap | array | Character stats |
| weapon | equipList | number | See [CharacterWeapon](#characterweapon) |
| reluquary | equipList | number | See [ProfilePicture](#profilepicture) |
### Icons
| Key | In API | Type | Description |
| --------- | ---------- | ------ | ------------------------------ |
| avatar | - | string | Character avatar icon |
| side | - | string | Character side avatar icon |
### ElementType
| Key | In API |
| -------------- | -------------- |
| Cryo | Ice |
| Hydro | Water |
| Anemo | Wind |
| Pyro | Fire |
| Geo | Rock |
| Electro | Electric |
### CharacterConstellation
| Key | In API | Type | Description |
| --------- | -------------- | ------- | -------------------------------------------- |
| id | talent | number | Character constellation id |
| name | - | string | Character constellation name |
| icon | - | string | URL to get the character constellation icon |
| unlocked | - | boolean | Character constellation unlocked? |
### CharacterSkill
| Key | In API | Type | Description |
| --------- | -------------- | ------- | -------------------------------------------- |
| id | skill | number | Character skill id |
| name | - | string | Character skill name |
| icon | - | string | URL to get the character skill icon |
| level | level | number | Character skill level |
### CharacterWeapon
| Key | In API | Type | Description |
| ----------- | ------------------- | ------- | -------------------------------------------- |
| id | itemId | number | Character weapon id |
| name | - | string | Character weapon name |
| icon | - | string | URL to get the character weapon icon |
| level | level | number | Character weapon level |
| elevations | weapon.promoteLevel | number | Character weapon elevations |
| improvement | weapon.affixMap | number | Character weapon improvement |
| rarity | flat.rankLevel | number | Character weapon rarity |
| mainStat | flat.weaponStats[0] | object | Character weapon main stat |
| subStat | flat.weaponStats[1] | object | Character weapon sub stat |
### CharacterReluquary
| Key | In API | Type | Description |
| ----------- | ---------------------- | ------- | -------------------------------------------- |
| id | itemId | number | Character reluquary id |
| name | - | string | Character reluquary name |
| setName | - | string | Character reluquary set name |
| icon | - | string | URL to get the character reluquary icon |
| type | - | string | See [ReliquaryType](#characterreluquary) |
| level | reliquary.level | number | Character reluquary level |
| rarity | flat.rankLevel | number | Character reluquary rarity |
| mainStat | flat.reliquaryMainstat | object | Character reluquary main stat |
| subStat | flat.reliquarySubstats | object | Character reluquary sub stat |
### ReliquaryType
| Key | In API |
| -------------- | -------------- |
| Flower | EQUIP_BRACER |
| Feather | EQUIP_NECKLACE |
| Sands | EQUIP_SHOES |
| Goblet | EQUIP_RING |
| Circlet | EQUIP_DRESS |
For assets thanks [enkanetwork.py-data](https://github.com/mrwan200/enkanetwork.py-data/)
Binary file modified assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions dist/models/character.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ export declare class character {
element: string;
elevations: number;
xp: number;
constellation: characterConstellation[];
stats: characterStats;
skills: characterSkills[];
constellation: characterConstellation[];
skills: characterSkill[];
skillSetId: number;
skillData: number[];
weapon: any;
reluquary: characterReluquary;
weapon: characterWeapon;
reluquary: characterReluquary[];
constructor(lang: string, character: any);
}
export declare class characterReluquary {
id: number;
level: number;
raity: number;
rarity: number;
mainStats: {
appendPropId: string;
statValue: number;
Expand All @@ -43,12 +43,12 @@ export declare class characterWeapon {
level: number;
elevations: number;
improvement: number;
raity: number;
rarity: number;
mainStat: {
appendPropId: string;
statValue: number;
};
subStat: {
subStat?: {
appendPropId: string;
statValue: number;
};
Expand All @@ -63,7 +63,7 @@ export declare class characterConstellation {
unlocked: boolean;
constructor(lang: string, talent: number, talents: number[]);
}
export declare class characterSkills {
export declare class characterSkill {
id: number;
icon: string;
name: string;
Expand Down
18 changes: 9 additions & 9 deletions dist/models/character.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.characterStats = exports.characterSkills = exports.characterConstellation = exports.characterWeapon = exports.characterReluquary = exports.character = void 0;
exports.characterStats = exports.characterSkill = exports.characterConstellation = exports.characterWeapon = exports.characterReluquary = exports.character = void 0;
const getAssetUrl_1 = require("../helpers/getAssetUrl");
const getNormalElement_1 = require("../helpers/getNormalElement");
// @ts-ignore: Json Import
Expand Down Expand Up @@ -47,7 +47,7 @@ class character {
this.reluquary = character.equipList.filter((x) => x.reliquary).map((reliquary) => new characterReluquary(lang, reliquary));
this.stats = new characterStats(character.fightPropMap);
this.constellation = characterAsset.talents.map((talent) => { return new characterConstellation(lang, talent, (character === null || character === void 0 ? void 0 : character.talentIdList) || []); });
this.skills = characterAsset.skills.map((skill) => { return new characterSkills(lang, skill, (character === null || character === void 0 ? void 0 : character.skillLevelMap[skill]) || 0); });
this.skills = characterAsset.skills.map((skill) => { return new characterSkill(lang, skill, (character === null || character === void 0 ? void 0 : character.skillLevelMap[skill]) || 0); });
this.skillSetId = character.skillDepotId;
this.skillData = character.inherentProudSkillList;
this.level = Number(((_a = character.propMap["4001"]) === null || _a === void 0 ? void 0 : _a.ival) || 0);
Expand All @@ -72,7 +72,7 @@ class characterReluquary {
this.icon = (0, getAssetUrl_1.getAssetUrl)(equipment.flat.icon);
this.type = reluquaryTypes[equipment.flat.equipType];
this.level = --equipment.reliquary.level;
this.raity = equipment.flat.rankLevel;
this.rarity = equipment.flat.rankLevel;
this.mainStats = equipment.flat.reliquaryMainstat;
this.subStats = equipment.flat.reliquarySubstats;
}
Expand All @@ -84,11 +84,11 @@ class characterWeapon {
this.name = charactersWeaponLocalizations[equipment.flat.nameTextMapHash][lang];
this.icon = (0, getAssetUrl_1.getAssetUrl)(equipment.flat.icon);
this.level = equipment.weapon.level;
this.elevations = equipment.weapon.promoteLevel;
this.improvement = equipment.weapon.affixMap[Object.keys(equipment.weapon.affixMap)[0]] + 1;
this.raity = equipment.flat.rankLevel;
this.elevations = equipment.weapon.promoteLevel || 0;
this.improvement = equipment.weapon.affixMap ? equipment.weapon.affixMap[Object.keys(equipment.weapon.affixMap)[0]] + 1 : 1;
this.rarity = equipment.flat.rankLevel;
this.mainStat = equipment.flat.weaponStats[0];
this.subStat = equipment.flat.weaponStats[1];
this.subStat = equipment.flat.weaponStats[1] || false;
}
}
exports.characterWeapon = characterWeapon;
Expand All @@ -103,7 +103,7 @@ class characterConstellation {
}
}
exports.characterConstellation = characterConstellation;
class characterSkills {
class characterSkill {
constructor(lang, skill, level) {
const charactersSkillsAsset = charactersSkillsAssets[skill];
const charactersSkillsLocalization = charactersSkillsLocalizations[charactersSkillsAsset.nameTextMapHash];
Expand All @@ -113,7 +113,7 @@ class characterSkills {
this.level = level;
}
}
exports.characterSkills = characterSkills;
exports.characterSkill = characterSkill;
class characterStats {
constructor(stats) {
this.BASE_HP = stats["1"] || 0;
Expand Down
2 changes: 1 addition & 1 deletion dist/models/fetchUser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IPlayerInfo } from "../types/index";
import { playerInfo } from "./playerInfo";
import { character } from "./character";
export declare class fetchUser {
playerInfo: playerInfo;
player: playerInfo;
characters: character[];
ttl: number;
constructor(language: string, data: {
Expand Down
2 changes: 1 addition & 1 deletion dist/models/fetchUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const playerInfo_1 = require("./playerInfo");
const character_1 = require("./character");
class fetchUser {
constructor(language, data) {
this.playerInfo = new playerInfo_1.playerInfo(language, data.playerInfo);
this.player = new playerInfo_1.playerInfo(language, data.playerInfo);
this.characters = data.avatarInfoList.map(avatar => { return new character_1.character(language, avatar); });
this.ttl = data.ttl;
}
Expand Down
8 changes: 3 additions & 5 deletions dist/models/playerInfo.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ export declare class playerInfo {
signature: string;
level: number;
worldLevel: number;
nameCardId: number;
nameCard: nameCard;
finishAchievementNum: number;
towerFloorIndex: number;
towerLevelIndex: number;
achievements: number;
abyssFloor: number;
abyssLevel: number;
charactersPreview: characterPreview[];
nameCardsPreview: nameCard[];
showNameCardIdList: number[];
profilePicture: profilePicture;
constructor(language: string, data: IPlayerInfo);
}
6 changes: 3 additions & 3 deletions dist/models/playerInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class playerInfo {
this.level = data.level;
this.worldLevel = data.worldLevel;
this.nameCard = new nameCard_1.nameCard(language, data.nameCardId);
this.finishAchievementNum = data.finishAchievementNum;
this.towerFloorIndex = data.towerFloorIndex;
this.towerLevelIndex = data.towerLevelIndex;
this.achievements = data.finishAchievementNum;
this.abyssFloor = data.towerFloorIndex;
this.abyssLevel = data.towerLevelIndex;
this.charactersPreview = data.showAvatarInfoList.map((character) => {
return new characterPreview_1.characterPreview(language, character);
});
Expand Down
6 changes: 3 additions & 3 deletions dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ export interface ICharacterConstellationAsset {
nameTextMapHash: number;
icon: string;
}
export interface ICharacterSkillsAssets {
[key: string]: ICharacterSkillsAsset;
export interface ICharacterSkillAssets {
[key: string]: ICharacterSkillAsset;
}
export interface ICharacterSkillsAsset {
export interface ICharacterSkillAsset {
nameTextMapHash: number;
skillIcon: string;
}
Expand Down
Loading

0 comments on commit a1762bf

Please sign in to comment.