Added special suppitem case (fix #8)
All checks were successful
pipeline / build-and-push-images (push) Successful in 32s
pipeline / deploy (push) Successful in 6s

This commit is contained in:
2024-12-05 00:29:11 +01:00
parent 67d6dd5a1a
commit b181ec2f82
4 changed files with 34 additions and 8 deletions

View File

@@ -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)
}