Skip to content

Commit

Permalink
basic bf1marne stats support
Browse files Browse the repository at this point in the history
  • Loading branch information
zefanjajobse committed Jan 13, 2024
1 parent 662a1c2 commit 564817d
Show file tree
Hide file tree
Showing 6 changed files with 483 additions and 35 deletions.
28 changes: 28 additions & 0 deletions src/api/GametoolsApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ export interface BF2042PlayerSearchReturn {
results: BF2042Player[];
}

export interface Bf1PlayerReturn {
userId: number;
avatar: string;
userName: string;
id: number;
}

export class ApiProvider extends JsonClient {
constructor() {
super();
Expand All @@ -175,6 +182,21 @@ export class ApiProvider extends JsonClient {
lang: lang,
platform: platform,
};

if (game == "bf1marne") {
let playerId;
if (getter !== "playerid") {
const result = await this.bf1PlayerSearch({
name: encodeURIComponent(userName),
});
playerId = result.id;
} else {
playerId = userName;
}
return await bf1MarneApi.stats({
playerId: playerId,
});
}
if (getter == "playerid") {
return await this.getJsonMethod(`/${game}/${type}/`, {
...defaultParams,
Expand Down Expand Up @@ -543,6 +565,12 @@ export class ApiProvider extends JsonClient {
});
}

async bf1PlayerSearch({ name }: { name: string }): Promise<Bf1PlayerReturn> {
return await this.getJsonMethod(`/bf1/player/`, {
name: name,
});
}

async bf2042PlayerSearch({
name,
}: {
Expand Down
2 changes: 1 addition & 1 deletion src/api/ReturnTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export type MainStats = {
scorePerMinute: number;
skill: number;
squadScore: number;
timePlayed: string;
timePlayed?: string;
secondsPlayed?: number;
totalRankProgress: number;
userName: string;
Expand Down
Loading

0 comments on commit 564817d

Please sign in to comment.