import Foundation struct PlayerInfo: Codable, Equatable { /// The name of the player let name: PlayerName /// Indicates that the player is active, i.e. a session is established let isConnected: Bool /// The player is the next one to perform an action let isNextActor: Bool /// The card which the player added to the current trick let playedCard: CardId? /// The height of the player card on the table stack let positionInTrick: Int /// The number of times the player doubled the game cost (initial double and raises) let numberOfDoubles: Int let leadsGame: Bool let points: Int? init(player: Player, position: Int) { self.name = player.name self.isConnected = player.isConnected self.isNextActor = player.isNextActor self.positionInTrick = position self.playedCard = player.playedCard?.id self.numberOfDoubles = player.numberOfDoubles self.leadsGame = player.leadsGame self.points = player.points } /// Convert the property names into shorter strings for JSON encoding enum CodingKeys: String, CodingKey { case name = "name" case isConnected = "connected" case isNextActor = "active" case playedCard = "card" case positionInTrick = "position" case numberOfDoubles = "doubles" case leadsGame = "leads" case points = "points" } }