Add connection state to table info

This commit is contained in:
Christoph Hagen 2021-11-30 11:29:41 +01:00
parent 47e2eeb9ce
commit e1943317f2
2 changed files with 10 additions and 2 deletions

View File

@ -6,7 +6,9 @@ struct TableInfo: Codable {
let name: String
var players: [String]
var players: [PlayerName]
var connected: [Bool]
}
extension TableInfo: Comparable {

View File

@ -48,7 +48,13 @@ final class TableManagement {
func getPublicTableInfos() -> [TableInfo] {
publicTables.map { tableId in
TableInfo(id: tableId, name: tableNames[tableId]!, players: tablePlayers[tableId]!)
let players = tablePlayers[tableId]!
let connected = players.map { playerConnections[$0] != nil }
return TableInfo(
id: tableId,
name: tableNames[tableId]!,
players: players,
connected: connected)
}.sorted()
}