Skip to content

Commit

Permalink
Updated aoe4 ranked api to use aoe4world ranked 1v1 ladder
Browse files Browse the repository at this point in the history
  • Loading branch information
erin-fitzpatric committed Apr 22, 2022
1 parent b8676b1 commit 01b7e46
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/core/plugins/aoe4.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,30 +196,24 @@ module.exports = {
rejectUnauthorized: false
});

let response = await axios.get('https://aoeiv.net/api/leaderboard', {
let response = await axios.get('https://aoe4world.com/api/v0/players/search', {
httpsAgent: agent,
params: {
game: "aoe4",
leaderboard_id: 17,
search: playerName
query: playerName,
}
})


if (response.data.leaderboard && response.data.leaderboard.length) {
let result = response.data.leaderboard.find((player) => {
return player.name.toLowerCase() === playerName.toLowerCase();
});
result = (result || response.data.leaderboard[0]);
if (response.data) {
let leaderboard = response.data.players[0].leaderboards.rm_1v1;

let formattedResult = {};
formattedResult.userName = result.name;
formattedResult.elo = result.rating;
formattedResult.rank = result.rank;
formattedResult.winPercent = ((result.wins / result.games) * 100).toFixed(2);
formattedResult.wins = result.wins;
formattedResult.losses = result.losses;
formattedResult.streak = result.streak;
formattedResult.userName = response.data.players[0].name;
formattedResult.elo = leaderboard.rating;
formattedResult.rank = leaderboard.rank;
formattedResult.winPercent = leaderboard.win_rate;
formattedResult.wins = leaderboard.wins_count;
formattedResult.losses = leaderboard.losses_count;
formattedResult.streak = leaderboard.streak;

let playerStatString = `⚔️ ${formattedResult.userName} ⚔️ Rank: ${formattedResult.rank} - Elo: ${formattedResult.elo} - Win Rate: ${formattedResult.winPercent}% - W/L: ${formattedResult.wins}/${formattedResult.losses} - Streak: ${formattedResult.streak}`;

Expand Down

0 comments on commit 01b7e46

Please sign in to comment.