data in a useable state

main
Zynh0722 2024-02-08 18:22:32 -08:00
parent 341893fdb7
commit 902e8775a7
1 changed files with 53 additions and 14 deletions

View File

@ -65,25 +65,64 @@ console.log(`Common Game Data Found: ${commonGameIds.length}`);
commonGames.reverse(); commonGames.reverse();
commonGames let gameData = commonGames
.map(({ info, metadata }) => ({ .map(({ info, metadata }) => ({
id: metadata.matchId, id: metadata.matchId,
queueId: info.queueId,
data: info.participants data: info.participants
.filter(({ puuid }) => puuid === ice.puuid || puuid === val.puuid) .filter(({ puuid }) => puuid === ice.puuid || puuid === val.puuid)
.map(({ championId, championName, summonerName, lane }) => ({ .map(
championId, ({
championName, championName,
summonerName, summonerName,
lane, individualPosition,
})), teamPosition,
win,
}) => ({
championName,
summonerName,
individualPosition,
teamPosition,
win,
}),
)
.map(({ individualPosition, teamPosition, ...rest }) => {
const estimates = [...new Set([individualPosition, teamPosition])];
/** @type {string} */
let positionEstimate;
if (estimates.length === 1) {
positionEstimate = estimates[0];
} else if (estimates.length > 1) {
positionEstimate =
estimates.find((e) => e === "BOTTOM" || e === "UTILITY") ||
estimates[0];
} else {
positionEstimate = "NONE";
}
return {
...rest,
positionEstimate,
};
}),
})) }))
.filter((g) => g.queueId !== 400) .filter(({ data }) =>
// .filter(({ data }) => { data
// const lanes = data.map((s) => s.lane); .map(({ positionEstimate }) => positionEstimate)
// return lanes.includes("BOTTOM") && lanes.includes("SUPPORT"); .every((estimates) => estimates === "BOTTOM" || estimates === "UTILITY"),
// }) )
.forEach((g) => console.log(g)); .map(({ data, ...rest }) => {
return {
...rest,
win: data[0].win,
data: data.reduce((acc, playerData) => {
acc[playerData.summonerName] = playerData.positionEstimate;
return acc;
}, {}),
};
});
gameData.forEach((g) => console.log(JSON.stringify(g, null, " ")));
/** /**
* @param {string} puuid * @param {string} puuid