Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorted players by team_slot on RealTimeStats #374

Merged
merged 2 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading