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

41 lines
1.0 KiB
Swift
Raw Normal View History

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
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]
let playedCard: CardId?
/// The height of the player card on the table stack
let position: Int
2021-12-03 18:03:29 +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
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 }
}
}
}