diff --git a/frontend/components/item/Box.vue b/frontend/components/item/Box.vue index 9d0d9b5..4cd6dfb 100644 --- a/frontend/components/item/Box.vue +++ b/frontend/components/item/Box.vue @@ -1,12 +1,13 @@ - + {{ title }} + - + + + + + + + {{ (item.count/builds.tree.count * 100).toFixed(0) }}% + + + + diff --git a/frontend/types/api.ts b/frontend/types/api.ts index 38bb5fb..9fe21c3 100644 --- a/frontend/types/api.ts +++ b/frontend/types/api.ts @@ -10,6 +10,7 @@ declare global { bootsFirst: number boots: Array<{count: number, data: number}> lateGame: Array<{count: number, data: number}> + suppItems?: Array<{count: number, data: number}> } type Rune = { count: number diff --git a/match_collector/champion_stat.ts b/match_collector/champion_stat.ts index 7ef7822..92e285f 100644 --- a/match_collector/champion_stat.ts +++ b/match_collector/champion_stat.ts @@ -40,6 +40,7 @@ type Builds = { bootsFirst: number boots: Array<{data: number, count: number}> lateGame: Array<{data: number, count: number}> + suppItems?: Array<{data: number, count: number}> } type Champion = { id: Number @@ -102,14 +103,15 @@ function handleMatchItems(timeline, participant: any, participantIndex : number, || x == participant.item4 || x == participant.item5 || x == participant.item6 ) - if(suppItem != undefined) - items.push(suppItem) + if(suppItem != undefined) { + const already = builds.suppItems.find((x) => x.data == suppItem) + if(already == undefined) builds.suppItems.push({count:1, data: suppItem}) + else already.count += 1 + } } } if(event.type != "ITEM_PURCHASED") continue; - - // Handle boots differently if(itemInfo.categories.includes("Boots")){ if(itemInfo.to.length == 0 || event.itemId == 3006) { @@ -185,7 +187,7 @@ async function championInfos(client, patch: number, champion: Champion) { // Lanes let lane = lanes.find((x) => x.data == participant.teamPosition) if(lane == undefined) { - const builds : Builds = {tree:treeInit(), start: [], bootsFirst: 0, boots: [], lateGame: []} + const builds : Builds = {tree:treeInit(), start: [], bootsFirst: 0, boots: [], lateGame: [], suppItems: []} lane = {count:1, data: participant.teamPosition, runes:[], builds:builds, winningMatches: 0, losingMatches: 0, winrate: 0, pickrate: 0} lanes.push(lane) } @@ -242,6 +244,15 @@ async function championInfos(client, patch: number, champion: Champion) { builds.boots.sort((a, b) => b.count - a.count) builds.bootsFirst /= lane.count + + // Cut supp items below 2 and percentage threshold + arrayRemovePercentage(builds.suppItems, lane.count, 0.05) + builds.suppItems.sort((a, b) => b.count - a.count) + if(builds.suppItems.length > 2) + builds.suppItems.splice(2, builds.suppItems.length - 2) + + // Delete supp items if empty + if(builds.suppItems.length == 0) delete builds.suppItems builds.lateGame.sort((a, b) => b.count - a.count) }