diff --git a/packages/dota/src/types.ts b/packages/dota/src/types.ts index d7214395..265b53bc 100644 --- a/packages/dota/src/types.ts +++ b/packages/dota/src/types.ts @@ -514,6 +514,7 @@ export interface DelayedGames { items: number[] heroid: number accountid: string + team_slot: number }[] }[] } diff --git a/packages/steam/src/steam.ts b/packages/steam/src/steam.ts index b711ab97..5982c1da 100644 --- a/packages/steam/src/steam.ts +++ b/packages/steam/src/steam.ts @@ -137,6 +137,12 @@ function hasSteamData(game?: DelayedGames | null) { return { hasAccountIds, hasPlayers, hasHeroes } } +function sortPlayersBySlot(game: DelayedGames) { + for (const team of game.teams) { + team.players.sort((a, b) => a.team_slot - b.team_slot) + } +} + class Dota { private static instance: Dota private cache: Map = new Map() @@ -510,6 +516,9 @@ class Dota { const retryAttempt2 = waitForHeros && !hasHeroes ? new Error() : undefined if (operation.retry(retryAttempt2)) return + // sort players by team_slot + sortPlayersBySlot(game) + // 2-minute delay gives "0" match id, so we use the gsi match id instead game.match.match_id = match_id game.match.server_steam_id = steam_server_id diff --git a/packages/steam/src/types/index.ts b/packages/steam/src/types/index.ts index f5a253fe..ffd439dd 100644 --- a/packages/steam/src/types/index.ts +++ b/packages/steam/src/types/index.ts @@ -514,6 +514,7 @@ export interface DelayedGames { items: number[] heroid: number accountid: string + team_slot: number }[] }[] }