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

43 lines
1.1 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
2021-12-22 22:12:31 +01:00
var points = 0
/// Indicates that the player is active, i.e. a session is established
var isConnected = false
2021-12-03 18:03:29 +01:00
/// The player is the next one to perform an action
var isNextActor = false
/// The card which the player added to the current trick
var playedCard: CardId? = nil
/// The height of the player card on the table stack
var positionInTrick = 0
2021-12-18 15:08:43 +01:00
/// The number of times the player doubled the game cost (initial double and raises)
var numberOfDoubles = 0
2021-12-18 15:08:43 +01:00
var state: [PlayerStateId] = []
init(name: PlayerName) {
self.name = name
}
/// Convert the property names into shorter strings for JSON encoding
enum CodingKeys: String, CodingKey {
case name = "name"
2021-12-22 22:12:31 +01:00
case points = "points"
case isConnected = "connected"
case isNextActor = "active"
case playedCard = "card"
case positionInTrick = "position"
2021-12-18 15:08:43 +01:00
case numberOfDoubles = "doubles"
2021-12-23 12:52:13 +01:00
case state = "state"
2021-12-03 18:03:29 +01:00
}
}