import Foundation struct PlayerInfo: Codable, Equatable { let name: PlayerName let connected: Bool /// The player is the next one to perform an action let active: Bool let selectsGame: Bool /// The cards in the hand of the player let cards: [CardInfo] /// The action the player can perform let actions: [String] let playedCard: CardId? /// The height of the player card on the table stack let position: Int init(player: Player, isMasked: Bool, trickPosition: Int) { self.name = player.name self.connected = player.isConnected self.active = player.isNextActor self.selectsGame = player.selectsGame self.playedCard = player.playedCard?.id self.position = trickPosition if isMasked { self.cards = [] self.actions = [] } else { self.actions = player.actions.map { $0.path } self.cards = player.handCards.map { $0.cardInfo } } } }