Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RozmarinUS committed Jan 3, 2023
1 parent a866cf4 commit 392d759
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/enum/clan.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum ClanRole {
Master = 'MASTER',
Officer = 'OFFICER',
Regular = 'REGULAR',
}
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import axios from "axios";
import { Endpoint, Server } from "./enum/common.enum";
import { Clan } from "./interfaces/clan.interface";
import { Achievement } from "./interfaces/common.interface";
import { Player } from "./interfaces/player.interface";
import { Top } from "./interfaces/top.interface";
import formatService from "./services/format.service";

export class WFApi {
Expand Down Expand Up @@ -43,7 +46,7 @@ export class WFApi {
});
}

async getTop100(server: Server) {
async getTop100(server: Server): Promise<Top> {
return new Promise(async (resolve, reject) => {
if(!server) {
return reject('no_server_specified');
Expand All @@ -60,7 +63,7 @@ export class WFApi {
});
}

async getPlayer(name: string, server: Server | null = null) {
async getPlayer(name: string, server: Server | null = null): Promise<Player> {
return new Promise(async (resolve, reject) => {
if(!name) {
reject(new Error('nickname_not_specified'));
Expand Down Expand Up @@ -102,7 +105,7 @@ export class WFApi {
});
}

async getClan(name: string, server: Server | null = null) {
async getClan(name: string, server: Server | null = null): Promise<Clan> {
return new Promise(async (resolve, reject) => {
if(!name) {
reject('name_is_not_specified');
Expand Down
14 changes: 14 additions & 0 deletions src/interfaces/clan.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ClanRole } from "../enum/clan.enum";

export interface ClanMember {
nickname: string;
rank_id: string;
clan_points: string;
clan_role: ClanRole;
}

export interface Clan {
id: string;
name: string;
members: ClanMember[];
}
34 changes: 34 additions & 0 deletions src/interfaces/player.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Achievement } from "./common.interface";

export interface Player {
user_id?: string;
nickname?: string;
experience?: number;
rank_id?: number;
clan_id?: number;
clan_name?: string;
kill?: number;
friendly_kills?: number;
kills?: number;
death?: number;
pvp?: number;
pve_kill?: number;
pve_friendly_kills?: number;
pve_kills?: number;
pve_death?: number;
pve?: number;
playtime?: number;
playtime_h?: number;
playtime_m?: number;
favoritPVP?: string;
favoritPVE?: string;
pve_wins?: number;
pvp_wins?: number;
pvp_lost?: number;
pve_lost?: number;
pve_all?: number;
pvp_all?: number;
pvp_wl?: number;
full_player?: Record<string, unknown>;
achievements?: Achievement[];
}
6 changes: 6 additions & 0 deletions src/interfaces/top.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface Top {
nickname: string;
clan: string;
class: string;
shard: string;
}
6 changes: 4 additions & 2 deletions src/services/format.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Server } from "../enum/common.enum";
import { Achievement } from "../interfaces/common.interface";
import { Player } from "../interfaces/player.interface";

export class formatService {
getMatch(el: any, regexp: any) {
return el.match(regexp)[0].trim();
}

format(playerData: any, achievements: any, server: Server) {
format(playerData: Partial<Player>, achievements: Achievement[], server: Server) {
let player = playerData;
const full_player = parseFullResponse(player['full_response']);
delete player['full_response'];
Expand All @@ -14,7 +16,7 @@ export class formatService {
server,
player,
full_player,
achievements
achievements,
};
}

Expand Down

0 comments on commit 392d759

Please sign in to comment.