diff --git a/Sources/App/Infos/BiddingInfo.swift b/Sources/App/Infos/BiddingInfo.swift new file mode 100644 index 0000000..dfde24a --- /dev/null +++ b/Sources/App/Infos/BiddingInfo.swift @@ -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] +} diff --git a/Sources/App/Infos/Card.swift b/Sources/App/Infos/Card.swift new file mode 100644 index 0000000..96ed063 --- /dev/null +++ b/Sources/App/Infos/Card.swift @@ -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 + } +} + diff --git a/Sources/App/Infos/CardInfo.swift b/Sources/App/Infos/CardInfo.swift new file mode 100644 index 0000000..d6bb463 --- /dev/null +++ b/Sources/App/Infos/CardInfo.swift @@ -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] +} diff --git a/Sources/App/Infos/GameType.swift b/Sources/App/Infos/GameType.swift new file mode 100644 index 0000000..1aa50d5 --- /dev/null +++ b/Sources/App/Infos/GameType.swift @@ -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 + } + } +} + diff --git a/Sources/App/Infos/JoinTableResult.swift b/Sources/App/Infos/JoinTableResult.swift new file mode 100644 index 0000000..fd1c7b8 --- /dev/null +++ b/Sources/App/Infos/JoinTableResult.swift @@ -0,0 +1,9 @@ +import Foundation + + +enum JoinTableResult { + case invalidToken + case tableNotFound + case tableIsFull + case success +} diff --git a/Sources/App/Model/ClientInfos.swift b/Sources/App/Infos/TableInfo.swift similarity index 100% rename from Sources/App/Model/ClientInfos.swift rename to Sources/App/Infos/TableInfo.swift diff --git a/Sources/App/Model/TableManagement.swift b/Sources/App/Model/TableManagement.swift index 00ad2f3..4f2a809 100644 --- a/Sources/App/Model/TableManagement.swift +++ b/Sources/App/Model/TableManagement.swift @@ -102,10 +102,4 @@ final class TableManagement { func disconnect(player: PlayerName) { fatalError() } - - enum JoinTableResult { - case tableNotFound - case tableIsFull - case success - } }