2021-12-06 18:28:35 +01:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
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 {
|
2021-12-09 11:11:17 +01:00
|
|
|
case none = 0
|
2021-12-06 18:28:35 +01:00
|
|
|
case ruf = 1
|
|
|
|
case bettel = 2
|
|
|
|
case wenzGeier = 3
|
|
|
|
case solo = 4
|
|
|
|
|
|
|
|
var cost: Int {
|
|
|
|
switch self {
|
2021-12-09 11:11:17 +01:00
|
|
|
case .none: return 0
|
2021-12-06 18:28:35 +01:00
|
|
|
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)!
|
|
|
|
}
|
|
|
|
|
2021-12-09 11:11:17 +01:00
|
|
|
var allowsWedding: Bool {
|
|
|
|
switch self {
|
|
|
|
case .none, .ruf:
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-06 18:28:35 +01:00
|
|
|
var availableGames: [GameType] {
|
|
|
|
switch self {
|
2021-12-09 11:11:17 +01:00
|
|
|
case .none, .ruf:
|
2021-12-06 18:28:35 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|