Add connection state to table info
This commit is contained in:
parent
47e2eeb9ce
commit
e1943317f2
@ -6,7 +6,9 @@ struct TableInfo: Codable {
|
|||||||
|
|
||||||
let name: String
|
let name: String
|
||||||
|
|
||||||
var players: [String]
|
var players: [PlayerName]
|
||||||
|
|
||||||
|
var connected: [Bool]
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TableInfo: Comparable {
|
extension TableInfo: Comparable {
|
@ -48,7 +48,13 @@ final class TableManagement {
|
|||||||
|
|
||||||
func getPublicTableInfos() -> [TableInfo] {
|
func getPublicTableInfos() -> [TableInfo] {
|
||||||
publicTables.map { tableId in
|
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()
|
}.sorted()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user