2021-12-03 18:03:29 +01:00
|
|
|
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
|
2021-12-06 18:28:35 +01:00
|
|
|
|
|
|
|
let selectsGame: Bool
|
2021-12-03 18:03:29 +01:00
|
|
|
|
|
|
|
/// The cards in the hand of the player
|
|
|
|
let cards: [CardInfo]
|
|
|
|
|
|
|
|
/// The action the player can perform
|
|
|
|
let actions: [String]
|
2021-12-06 18:28:35 +01:00
|
|
|
|
|
|
|
let playedCard: CardId?
|
|
|
|
|
|
|
|
/// The height of the player card on the table stack
|
|
|
|
let position: Int
|
2021-12-03 18:03:29 +01:00
|
|
|
|
2021-12-06 18:28:35 +01:00
|
|
|
init(player: Player, isMasked: Bool, trickPosition: Int) {
|
2021-12-03 18:03:29 +01:00
|
|
|
self.name = player.name
|
|
|
|
self.connected = player.isConnected
|
|
|
|
self.active = player.isNextActor
|
2021-12-06 18:28:35 +01:00
|
|
|
self.selectsGame = player.selectsGame
|
|
|
|
self.playedCard = player.playedCard?.id
|
|
|
|
self.position = trickPosition
|
2021-12-03 18:03:29 +01:00
|
|
|
if isMasked {
|
|
|
|
self.cards = []
|
|
|
|
self.actions = []
|
|
|
|
} else {
|
|
|
|
self.actions = player.actions.map { $0.path }
|
|
|
|
self.cards = player.handCards.map { $0.cardInfo }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|