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

56 lines
1.2 KiB
Swift
Raw Normal View History

2021-11-27 11:59:13 +01:00
import Foundation
2021-12-03 18:03:29 +01:00
struct TableInfo: Codable {
2021-12-01 22:49:54 +01:00
2021-11-27 11:59:13 +01:00
let id: String
let name: String
2021-12-03 18:03:29 +01:00
let player: PlayerInfo
let playerLeft: PlayerInfo?
let playerAcross: PlayerInfo?
let playerRight: PlayerInfo?
let playableGames: [GameId]
/// The cards in the hand of the player
let cards: [CardInfo]
/// The action the player can perform
let actions: [String]
let playerSelectsGame: Bool
init(id: String, name: String,
own: PlayerInfo, left: PlayerInfo?,
across: PlayerInfo?, right: PlayerInfo?,
games: [GameId] = [], actions: [PlayerAction],
cards: [PlayableCard], selectGame: Bool = false) {
self.id = id
self.name = name
self.player = own
self.playerLeft = left
self.playerAcross = across
self.playerRight = right
self.playableGames = games
self.actions = actions.map { $0.path }
self.cards = cards.map { $0.cardInfo }
self.playerSelectsGame = selectGame
2021-12-01 22:49:54 +01:00
}
2021-11-27 11:59:13 +01:00
}
2021-12-03 18:03:29 +01:00
extension TableInfo {
}
2021-11-27 11:59:13 +01:00
extension TableInfo: Comparable {
static func < (lhs: TableInfo, rhs: TableInfo) -> Bool {
lhs.name < rhs.name
}
}