Add client info definitions
This commit is contained in:
parent
e1943317f2
commit
b5c68538e2
16
Sources/App/Infos/BiddingInfo.swift
Normal file
16
Sources/App/Infos/BiddingInfo.swift
Normal file
@ -0,0 +1,16 @@
|
||||
import Foundation
|
||||
|
||||
struct BiddingInfo: Cobable {
|
||||
|
||||
/// The bidding class (0-5) specifying the minimum game that must be played
|
||||
let highestBidClass: Int
|
||||
|
||||
/// The index of the player who currently has the highest bid
|
||||
let indexOfHighestBidder: Int
|
||||
|
||||
/// The index of the player who's turn it is to bid
|
||||
let indexOfNextBidder: Int
|
||||
|
||||
/// Indicates which players are remaining in the bidding process
|
||||
let remaingingBidders: [Bool]
|
||||
}
|
58
Sources/App/Infos/Card.swift
Normal file
58
Sources/App/Infos/Card.swift
Normal file
@ -0,0 +1,58 @@
|
||||
import Foundation
|
||||
|
||||
typealias CardId = String
|
||||
|
||||
struct Card {
|
||||
|
||||
enum Symbol: Character {
|
||||
case ass = "A"
|
||||
case zehn = "Z"
|
||||
case könig = "K"
|
||||
case ober = "O"
|
||||
case unter = "U"
|
||||
case neun = "9"
|
||||
case acht = "8"
|
||||
case sieben = "7"
|
||||
}
|
||||
|
||||
enum Suit: Character {
|
||||
case eichel = "E"
|
||||
case blatt = "B"
|
||||
case herz = "H"
|
||||
case schelln = "S"
|
||||
}
|
||||
|
||||
|
||||
let symbol: Symbol
|
||||
|
||||
let suit: Suit
|
||||
|
||||
init(suit: Suit, symbol: Symbol) {
|
||||
self.suit = suit
|
||||
self.symbol = symbol
|
||||
}
|
||||
|
||||
init?(rawValue: String) {
|
||||
guard rawValue.count == 2 else {
|
||||
return nil
|
||||
}
|
||||
guard let suit = Suit(rawValue: rawValue.first!),
|
||||
let symbol = Symbol(rawValue: rawValue.last!) else {
|
||||
return nil
|
||||
}
|
||||
self.suit = suit
|
||||
self.symbol = symbol
|
||||
}
|
||||
|
||||
var id: CardId {
|
||||
"\(suit)\(symbol)"
|
||||
}
|
||||
}
|
||||
|
||||
extension Card: CustomStringConvertible {
|
||||
|
||||
var description: String {
|
||||
id
|
||||
}
|
||||
}
|
||||
|
10
Sources/App/Infos/CardInfo.swift
Normal file
10
Sources/App/Infos/CardInfo.swift
Normal file
@ -0,0 +1,10 @@
|
||||
import Foundation
|
||||
|
||||
struct CardInfo: Codable {
|
||||
|
||||
/// The cards for a player
|
||||
let cards: [CardId]
|
||||
|
||||
/// Indicates if the card can be played
|
||||
let playable: [Bool]
|
||||
}
|
56
Sources/App/Infos/GameType.swift
Normal file
56
Sources/App/Infos/GameType.swift
Normal file
@ -0,0 +1,56 @@
|
||||
import Foundation
|
||||
|
||||
enum GameType {
|
||||
|
||||
case rufEichel
|
||||
case rufBlatt
|
||||
case rufSchelln
|
||||
case hochzeit
|
||||
case bettel
|
||||
case wenz
|
||||
case geier
|
||||
case soloEichel
|
||||
case soloBlatt
|
||||
case soloHerz
|
||||
case soloSchelln
|
||||
|
||||
var gameClass: Int {
|
||||
switch self {
|
||||
case .rufEichel, .rufBlatt, .rufSchelln:
|
||||
return 1
|
||||
case .hochzeit:
|
||||
return 2
|
||||
case .bettel:
|
||||
return 3
|
||||
case .wenz, .geier:
|
||||
return 4
|
||||
case .soloEichel, .soloBlatt, .soloHerz, .soloSchelln:
|
||||
return 5
|
||||
}
|
||||
}
|
||||
|
||||
var isSingleGame: Bool {
|
||||
switch self {
|
||||
case .rufEichel, .rufBlatt, .rufSchelln, .hochzeit:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
var basicCost: Int {
|
||||
switch self {
|
||||
case .rufEichel, .rufBlatt, .rufSchelln:
|
||||
return 5
|
||||
case .hochzeit:
|
||||
return 10
|
||||
case .bettel:
|
||||
return 15
|
||||
case .wenz, .geier:
|
||||
return 20
|
||||
case .soloEichel, .soloBlatt, .soloHerz, .soloSchelln:
|
||||
return 20
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
Sources/App/Infos/JoinTableResult.swift
Normal file
9
Sources/App/Infos/JoinTableResult.swift
Normal file
@ -0,0 +1,9 @@
|
||||
import Foundation
|
||||
|
||||
|
||||
enum JoinTableResult {
|
||||
case invalidToken
|
||||
case tableNotFound
|
||||
case tableIsFull
|
||||
case success
|
||||
}
|
@ -102,10 +102,4 @@ final class TableManagement {
|
||||
func disconnect(player: PlayerName) {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
enum JoinTableResult {
|
||||
case tableNotFound
|
||||
case tableIsFull
|
||||
case success
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user