From 01b7e4653eec2ef3fecae4293888cfeff7b558f5 Mon Sep 17 00:00:00 2001 From: Erin Fitzpatric Date: Fri, 22 Apr 2022 03:11:52 -0400 Subject: [PATCH 1/2] Updated aoe4 ranked api to use aoe4world ranked 1v1 ladder --- src/core/plugins/aoe4.js | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/core/plugins/aoe4.js b/src/core/plugins/aoe4.js index 7059e047..f341b1d2 100644 --- a/src/core/plugins/aoe4.js +++ b/src/core/plugins/aoe4.js @@ -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}`; From 247a4e4ad922e4ecc1ba86f69bb01416b631a2b1 Mon Sep 17 00:00:00 2001 From: Erin Fitzpatric Date: Tue, 17 May 2022 17:11:28 -0400 Subject: [PATCH 2/2] added comment --- src/core/plugins/aoe4.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/plugins/aoe4.js b/src/core/plugins/aoe4.js index f341b1d2..d2b55f3e 100644 --- a/src/core/plugins/aoe4.js +++ b/src/core/plugins/aoe4.js @@ -224,6 +224,7 @@ module.exports = { } }, + //TODO - needs to be updated to new API async getAoe4Top3() { let response = await axios.post('https://api.ageofempires.com/api/ageiv/Leaderboard', { region: 7,