From 7be1b5642f39fc753d4345d13e358b39a0fd820f Mon Sep 17 00:00:00 2001 From: Nico Mac Date: Thu, 30 Nov 2023 23:11:25 +0800 Subject: [PATCH 1/2] Sorted players by team_slot on RealTimeStats --- packages/steam/src/steam.ts | 9 +++++++++ packages/steam/src/types/index.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/packages/steam/src/steam.ts b/packages/steam/src/steam.ts index b711ab97..08e50c2f 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 = 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 }[] }[] } From 146808a6b77fe2a8d063443b0c7e4dbb2cf019d9 Mon Sep 17 00:00:00 2001 From: Matt Gates Date: Sat, 2 Dec 2023 15:45:14 -0700 Subject: [PATCH 2/2] some sort fixes --- packages/dota/src/types.ts | 1 + packages/steam/src/steam.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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 08e50c2f..5982c1da 100644 --- a/packages/steam/src/steam.ts +++ b/packages/steam/src/steam.ts @@ -139,7 +139,7 @@ function hasSteamData(game?: DelayedGames | null) { function sortPlayersBySlot(game: DelayedGames) { for (const team of game.teams) { - team.players = team.players.sort((a, b) => a.team_slot - b.team_slot) + team.players.sort((a, b) => a.team_slot - b.team_slot) } }