import Foundation struct TableInfo: Codable { let id: String let name: String let player: PlayerInfo let playerLeft: PlayerInfo? let playerAcross: PlayerInfo? let playerRight: PlayerInfo? let playableGames: [GameId] /// The cards in the hand of the player let cards: [CardInfo] /// The action the player can perform let actions: [String] let playerSelectsGame: Bool init(id: String, name: String, own: PlayerInfo, left: PlayerInfo?, across: PlayerInfo?, right: PlayerInfo?, games: [GameType] = [], actions: [PlayerAction], cards: [PlayableCard], selectGame: Bool = false) { self.id = id self.name = name self.player = own self.playerLeft = left self.playerAcross = across self.playerRight = right self.playableGames = games.map { $0.id } self.actions = actions.map { $0.path } self.cards = cards.map { $0.cardInfo } self.playerSelectsGame = selectGame } } extension TableInfo { } extension TableInfo: Comparable { static func < (lhs: TableInfo, rhs: TableInfo) -> Bool { lhs.name < rhs.name } }