Added special suppitem case (fix #8)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user