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

57 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
2021-12-09 11:18:26 +01:00
let actions: [ActionId]
let playerSelectsGame: Bool
init(id: String, name: String,
own: PlayerInfo, left: PlayerInfo?,
across: PlayerInfo?, right: PlayerInfo?,
2021-12-09 11:17:11 +01:00
games: [GameType] = [], 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
2021-12-09 11:17:11 +01:00
self.playableGames = games.map { $0.id }
2021-12-09 11:18:26 +01:00
self.actions = actions.map { $0.id }
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
}
}