62 lines
1.5 KiB
Swift
62 lines
1.5 KiB
Swift
|
import Foundation
|
||
|
|
||
|
typealias GameId = String
|
||
|
|
||
|
extension GameType {
|
||
|
|
||
|
var gameClass: GameClass {
|
||
|
switch self {
|
||
|
case .rufEichel, .rufBlatt, .rufSchelln, .hochzeit:
|
||
|
return .ruf
|
||
|
case .bettel:
|
||
|
return .bettel
|
||
|
case .wenz, .geier:
|
||
|
return .wenzGeier
|
||
|
case .soloEichel, .soloBlatt, .soloHerz, .soloSchelln:
|
||
|
return .solo
|
||
|
}
|
||
|
}
|
||
|
|
||
|
enum GameClass: Int {
|
||
|
case ruf = 1
|
||
|
case bettel = 2
|
||
|
case wenzGeier = 3
|
||
|
case solo = 4
|
||
|
|
||
|
var cost: Int {
|
||
|
switch self {
|
||
|
case .ruf: return 5
|
||
|
case .bettel: return 15
|
||
|
case .wenzGeier, .solo: return 20
|
||
|
}
|
||
|
}
|
||
|
|
||
|
mutating func increase() {
|
||
|
guard self != .solo else {
|
||
|
return
|
||
|
}
|
||
|
self = .init(rawValue: rawValue + 1)!
|
||
|
}
|
||
|
|
||
|
var availableGames: [GameType] {
|
||
|
switch self {
|
||
|
case .ruf:
|
||
|
return GameType.allCases
|
||
|
case .bettel:
|
||
|
return [.bettel, .wenz, .geier, .soloEichel, .soloBlatt, .soloHerz, .soloSchelln]
|
||
|
case .wenzGeier:
|
||
|
return [.wenz, .geier, .soloEichel, .soloBlatt, .soloHerz, .soloSchelln]
|
||
|
case .solo:
|
||
|
return [.soloEichel, .soloBlatt, .soloHerz, .soloSchelln]
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
extension GameType.GameClass: Comparable {
|
||
|
|
||
|
static func < (lhs: GameType.GameClass, rhs: GameType.GameClass) -> Bool {
|
||
|
lhs.rawValue < rhs.rawValue
|
||
|
}
|
||
|
}
|