data in a useable state
This commit is contained in:
parent
341893fdb7
commit
902e8775a7
1 changed files with 53 additions and 14 deletions
67
index.mjs
67
index.mjs
|
@ -65,25 +65,64 @@ console.log(`Common Game Data Found: ${commonGameIds.length}`);
|
|||
|
||||
commonGames.reverse();
|
||||
|
||||
commonGames
|
||||
let gameData = commonGames
|
||||
.map(({ info, metadata }) => ({
|
||||
id: metadata.matchId,
|
||||
queueId: info.queueId,
|
||||
data: info.participants
|
||||
.filter(({ puuid }) => puuid === ice.puuid || puuid === val.puuid)
|
||||
.map(({ championId, championName, summonerName, lane }) => ({
|
||||
championId,
|
||||
championName,
|
||||
summonerName,
|
||||
lane,
|
||||
})),
|
||||
.map(
|
||||
({
|
||||
championName,
|
||||
summonerName,
|
||||
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 }) => {
|
||||
// const lanes = data.map((s) => s.lane);
|
||||
// return lanes.includes("BOTTOM") && lanes.includes("SUPPORT");
|
||||
// })
|
||||
.forEach((g) => console.log(g));
|
||||
.filter(({ data }) =>
|
||||
data
|
||||
.map(({ positionEstimate }) => positionEstimate)
|
||||
.every((estimates) => estimates === "BOTTOM" || estimates === "UTILITY"),
|
||||
)
|
||||
.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
|
||||
|
|
Loading…
Reference in a new issue