73 lines
1.8 KiB
Swift
73 lines
1.8 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 none = 0
|
|
case ruf = 1
|
|
case bettel = 2
|
|
case wenzGeier = 3
|
|
case solo = 4
|
|
|
|
var cost: Int {
|
|
switch self {
|
|
case .none: return 0
|
|
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 allowsWedding: Bool {
|
|
switch self {
|
|
case .none, .ruf:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
var availableGames: [GameType] {
|
|
switch self {
|
|
case .none, .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
|
|
}
|
|
}
|