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?
|
2021-12-06 18:28:35 +01:00
|
|
|
|
|
|
|
let playableGames: [GameId]
|
2021-12-09 11:11:17 +01:00
|
|
|
|
|
|
|
/// 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
|
|
|
|
}
|
|
|
|
}
|