Skip to content

Commit

Permalink
Sorted players by team_slot on RealTimeStats (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geczy committed Dec 2, 2023
2 parents be4fa0f + 146808a commit 8288c78
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/dota/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ export interface DelayedGames {
items: number[]
heroid: number
accountid: string
team_slot: number
}[]
}[]
}
Expand Down
9 changes: 9 additions & 0 deletions packages/steam/src/steam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number, CacheEntry> = new Map()
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/steam/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ export interface DelayedGames {
items: number[]
heroid: number
accountid: string
team_slot: number
}[]
}[]
}
Expand Down

0 comments on commit 8288c78

Please sign in to comment.