From a4606edb33c964e0cdad98ebae77df45f52caa26 Mon Sep 17 00:00:00 2001 From: vhaudiquet Date: Tue, 26 Nov 2024 17:14:36 +0100 Subject: [PATCH] Cut boots below percentage --- match_collector/champion_stat.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/match_collector/champion_stat.ts b/match_collector/champion_stat.ts index 1afe779..c13c8b4 100644 --- a/match_collector/champion_stat.ts +++ b/match_collector/champion_stat.ts @@ -15,6 +15,18 @@ async function itemList() { return list } +function arrayRemovePercentage(array: Array<{count:number}>, totalGames:number, percentage: number) { + let toRemove : Array<{count:number}> = [] + for(let item of array) { + if((item.count/totalGames) < 0.05) { + toRemove.push(item) + } + } + for(let tr of toRemove) { + array.splice(array.indexOf(tr), 1) + } +} + type Rune = { count: number primaryStyle: number @@ -175,16 +187,12 @@ async function championInfos(client, patch: number, champion: Champion) { let leastUsedItem = builds.start.reduce((a, b) => Math.min(a.count, b.count) == a.count ? a : b, {data:undefined, count: +Infinity}) builds.start.splice(builds.start.indexOf(leastUsedItem), 1) } - let toRemove : Array<{data: number, count:number}> = [] - for(let item of builds.start) { - if((item.count/(winningMatches + losingMatches)) < 0.05) { - toRemove.push(item) - } - } - for(let tr of toRemove) { - builds.start.splice(builds.start.indexOf(tr), 1) - } + arrayRemovePercentage(builds.start, (winningMatches + losingMatches), 0.05) builds.start.sort((a, b) => b.count - a.count) + + // Remove boots that are not within percentage threshold + arrayRemovePercentage(builds.boots, (winningMatches + losingMatches), 0.05) + builds.boots.sort((a, b) => b.count - a.count) builds.bootsFirst /= (winningMatches + losingMatches) builds.lateGame.sort((a, b) => b.count - a.count)