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

37 lines
1.0 KiB
Swift
Raw Normal View History

2021-12-03 18:03:29 +01:00
import Foundation
struct PlayerInfo: Codable, Equatable {
/// The name of the player
2021-12-03 18:03:29 +01:00
let name: PlayerName
/// Indicates that the player is active, i.e. a session is established
let isConnected: Bool
2021-12-03 18:03:29 +01:00
/// 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
init(player: Player, isNextActor: Bool, position: Int) {
2021-12-03 18:03:29 +01:00
self.name = player.name
self.isConnected = player.isConnected
self.isNextActor = isNextActor
self.positionInTrick = position
self.playedCard = player.playedCard?.id
}
/// 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"
2021-12-03 18:03:29 +01:00
}
}