Schafkopf-Server/Sources/App/Infos/TableInfo.swift

38 lines
854 B
Swift
Raw Normal View History

2021-11-27 11:59:13 +01:00
import Foundation
2021-12-03 18:03:29 +01:00
struct TableInfo: Codable {
2021-12-01 22:49:54 +01:00
2021-11-27 11:59:13 +01:00
let id: String
let name: String
2021-12-03 18:03:29 +01:00
let player: PlayerInfo
let playerLeft: PlayerInfo?
let playerAcross: PlayerInfo?
let playerRight: PlayerInfo?
init(_ table: Table, forPlayerAt playerIndex: Int) {
self.id = table.id
self.name = table.name
self.player = table.player(at: playerIndex)!.info(masked: false)
self.playerLeft = table.player(leftOf: playerIndex)?.info(masked: true)
self.playerAcross = table.player(acrossOf: playerIndex)?.info(masked: true)
self.playerRight = table.player(rightOf: playerIndex)?.info(masked: true)
2021-12-01 22:49:54 +01:00
}
2021-11-27 11:59:13 +01:00
}
2021-12-03 18:03:29 +01:00
extension TableInfo {
}
2021-11-27 11:59:13 +01:00
extension TableInfo: Comparable {
static func < (lhs: TableInfo, rhs: TableInfo) -> Bool {
lhs.name < rhs.name
}
}