fix/mathc_collector: fix splitting of boots and first backs
This commit is contained in:
@@ -177,7 +177,7 @@ function handleMatchBuilds(
|
||||
participantIndex: number,
|
||||
builds: Builds,
|
||||
platform?: string
|
||||
): Build {
|
||||
): { build: Build; startItemId: number | undefined } {
|
||||
const timeline: Timeline = match.timeline
|
||||
|
||||
// Find or create the build for this participant's rune configuration
|
||||
@@ -185,6 +185,7 @@ function handleMatchBuilds(
|
||||
build.count += 1
|
||||
|
||||
const items: Array<{ itemId: number; goldAdvantage: GoldAdvantageTag; platform?: string }> = []
|
||||
let startItemId: number | undefined = undefined
|
||||
for (const frame of timeline.info.frames) {
|
||||
for (const event of frame.events) {
|
||||
if (event.participantId != participantIndex) continue
|
||||
@@ -267,9 +268,11 @@ function handleMatchBuilds(
|
||||
// This tree includes start item as the root, then branching paths
|
||||
if (items.length > 0) {
|
||||
treeMerge(build.items, items)
|
||||
// The first item is the starter item
|
||||
startItemId = items[0].itemId
|
||||
}
|
||||
|
||||
return build
|
||||
return { build, startItemId }
|
||||
}
|
||||
|
||||
function handleMatch(match: Match, champions: Map<number, ChampionData>, platform?: string) {
|
||||
@@ -365,14 +368,22 @@ function handleMatch(match: Match, champions: Map<number, ChampionData>, platfor
|
||||
}
|
||||
|
||||
// Items and runes (builds)
|
||||
const build = handleMatchBuilds(match, participant, participantIndex, lane.builds, platform)
|
||||
const { build, startItemId } = handleMatchBuilds(
|
||||
match,
|
||||
participant,
|
||||
participantIndex,
|
||||
lane.builds,
|
||||
platform
|
||||
)
|
||||
|
||||
// First back data - store at build level
|
||||
// First back data - store at build level with start item tracking
|
||||
const firstBackData = extractFirstBackFromMatch(match, participantIndex)
|
||||
if (firstBackData) {
|
||||
if (!build.firstBacksRaw) {
|
||||
build.firstBacksRaw = []
|
||||
}
|
||||
// Include the starter item ID for proper filtering when splitting builds
|
||||
firstBackData.startItemId = startItemId
|
||||
build.firstBacksRaw.push(firstBackData)
|
||||
}
|
||||
}
|
||||
@@ -445,16 +456,44 @@ function splitMergeOnStarterItem(build: Build, championName: string): BuildWithS
|
||||
console.log(`Warning: for champion ${championName}, start item splits build variant.`)
|
||||
const builds = []
|
||||
for (const c of build.items.children) {
|
||||
// Calculate the ratio for proportional distribution
|
||||
const ratio = c.count / build.count
|
||||
|
||||
// Proportionally distribute boots counts
|
||||
const scaledBoots = build.boots.map(b => ({
|
||||
data: b.data,
|
||||
count: Math.round(b.count * ratio)
|
||||
}))
|
||||
|
||||
// Proportionally distribute suppItems counts
|
||||
const scaledSuppItems = build.suppItems.map(s => ({
|
||||
data: s.data,
|
||||
count: Math.round(s.count * ratio)
|
||||
}))
|
||||
|
||||
// Proportionally distribute bootsFirstCount
|
||||
const scaledBootsFirstCount = Math.round(build.bootsFirstCount * ratio)
|
||||
|
||||
// Filter firstBacksRaw by starter item
|
||||
let filteredFirstBacksRaw: FirstBackData[] | undefined
|
||||
if (build.firstBacksRaw && build.firstBacksRaw.length > 0) {
|
||||
// Filter by the starter item ID that was tracked when storing firstBacksRaw
|
||||
filteredFirstBacksRaw = build.firstBacksRaw.filter(fb => fb.startItemId === c.data)
|
||||
if (filteredFirstBacksRaw.length === 0) {
|
||||
filteredFirstBacksRaw = undefined
|
||||
}
|
||||
}
|
||||
|
||||
builds.push({
|
||||
runeKeystone: build.runeKeystone,
|
||||
runes: build.runes,
|
||||
items: c,
|
||||
bootsFirstCount: build.bootsFirstCount,
|
||||
bootsFirstCount: scaledBootsFirstCount,
|
||||
count: c.count,
|
||||
startItems: [{ data: c.data!, count: c.count }],
|
||||
suppItems: build.suppItems,
|
||||
boots: build.boots,
|
||||
firstBacksRaw: build.firstBacksRaw
|
||||
suppItems: scaledSuppItems,
|
||||
boots: scaledBoots,
|
||||
firstBacksRaw: filteredFirstBacksRaw
|
||||
})
|
||||
c.data = undefined
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ export interface ItemSet {
|
||||
export interface FirstBackData {
|
||||
timestamp: number
|
||||
itemSet: ItemSet
|
||||
startItemId?: number
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user