Add card dealing

This commit is contained in:
Christoph Hagen
2021-12-01 22:49:54 +01:00
parent 1ee3fbc0ab
commit cdf079698e
10 changed files with 499 additions and 8 deletions

View File

@@ -1,10 +1,19 @@
import Foundation
struct CardInfo: Codable {
struct CardInfo: ClientMessage {
static let type: ClientMessageType = .cardInfo
struct HandCard: Codable {
let card: CardId
let playable: Bool
}
/// The cards for a player
let cards: [CardId]
let cards: [HandCard]
/// Indicates if the card can be played
let playable: [Bool]
// The cards on the table, as seen from the players perspective
let tableCards: [CardId]
}

View File

@@ -1,6 +1,6 @@
import Foundation
enum GameType {
enum GameType: Codable {
case rufEichel
case rufBlatt
@@ -52,5 +52,37 @@ enum GameType {
return 20
}
}
var sortingType: CardSortingStrategy {
switch self {
case .wenz:
return .wenz
case .geier:
return .geier
case .soloEichel:
return .soloEichel
case .soloBlatt:
return .soloBlatt
case .soloSchelln:
return .soloSchelln
default:
return .normal
}
}
}
enum CardSortingStrategy {
/// The sorting for most games, where heart is trump
case normal
case wenz
case geier
case soloEichel
case soloBlatt
case soloSchelln
}

View File

@@ -1,9 +0,0 @@
import Foundation
enum JoinTableResult {
case invalidToken
case tableNotFound
case tableIsFull
case success
}

View File

@@ -1,14 +1,28 @@
import Foundation
struct TableInfo: Codable {
struct TableInfo: ClientMessage {
static let type: ClientMessageType = .tableInfo
let id: String
let name: String
var players: [PlayerName]
let players: [PlayerState]
var connected: [Bool]
let tableIsFull: Bool
struct PlayerState: Codable, Equatable {
let name: PlayerName
let connected: Bool
init(name: PlayerName, connected: Bool) {
self.name = name
self.connected = connected
}
}
}
extension TableInfo: Comparable {