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:
|
2021-12-18 15:08:43 +01:00
|
|
|
return .wenz
|
2021-12-06 18:28:35 +01:00
|
|
|
case .soloEichel, .soloBlatt, .soloHerz, .soloSchelln:
|
|
|
|
return .solo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-18 15:08:43 +01:00
|
|
|
enum GameClass: String {
|
|
|
|
case none = "none"
|
|
|
|
case ruf = "ruf"
|
|
|
|
case hochzeit = "hochzeit"
|
|
|
|
case bettel = "bettel"
|
|
|
|
case wenz = "wenz"
|
|
|
|
case geier = "geier"
|
|
|
|
case solo = "solo"
|
2021-12-06 18:28:35 +01:00
|
|
|
|
|
|
|
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
|
2021-12-18 15:08:43 +01:00
|
|
|
case .hochzeit: return 10
|
2021-12-06 18:28:35 +01:00
|
|
|
case .bettel: return 15
|
2021-12-18 15:08:43 +01:00
|
|
|
case .wenz, .geier, .solo: return 20
|
2021-12-06 18:28:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-18 15:08:43 +01:00
|
|
|
@discardableResult
|
|
|
|
mutating func increase() -> Bool {
|
|
|
|
switch self {
|
|
|
|
case .none:
|
|
|
|
self = .ruf
|
|
|
|
case .ruf:
|
|
|
|
self = .bettel
|
|
|
|
case .hochzeit:
|
|
|
|
self = .bettel
|
|
|
|
case .bettel:
|
|
|
|
self = .wenz
|
|
|
|
case .wenz, .geier:
|
|
|
|
self = .solo
|
|
|
|
case .solo:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func increased() -> GameClass? {
|
|
|
|
switch self {
|
|
|
|
case .none:
|
|
|
|
return .ruf
|
|
|
|
case .ruf:
|
|
|
|
return .bettel
|
|
|
|
case .hochzeit:
|
|
|
|
return .bettel
|
|
|
|
case .bettel:
|
|
|
|
return .wenz
|
|
|
|
case .wenz, .geier:
|
|
|
|
return .solo
|
|
|
|
case .solo:
|
|
|
|
return nil
|
2021-12-06 18:28:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-09 11:11:17 +01:00
|
|
|
var allowsWedding: Bool {
|
|
|
|
switch self {
|
|
|
|
case .none, .ruf:
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-18 15:08:43 +01:00
|
|
|
func allows(game: GameType) -> Bool {
|
|
|
|
availableGames.contains(game)
|
|
|
|
}
|
|
|
|
|
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
|
2021-12-18 15:08:43 +01:00
|
|
|
case .hochzeit, .bettel:
|
2021-12-06 18:28:35 +01:00
|
|
|
return [.bettel, .wenz, .geier, .soloEichel, .soloBlatt, .soloHerz, .soloSchelln]
|
2021-12-18 15:08:43 +01:00
|
|
|
case .wenz, .geier:
|
2021-12-06 18:28:35 +01:00
|
|
|
return [.wenz, .geier, .soloEichel, .soloBlatt, .soloHerz, .soloSchelln]
|
|
|
|
case .solo:
|
|
|
|
return [.soloEichel, .soloBlatt, .soloHerz, .soloSchelln]
|
|
|
|
}
|
|
|
|
}
|
2021-12-18 15:08:43 +01:00
|
|
|
|
|
|
|
var availableClasses: [GameClass] {
|
|
|
|
switch self {
|
|
|
|
case .none, .ruf:
|
|
|
|
return [.ruf, .bettel, .wenz, .geier, .solo]
|
|
|
|
case .hochzeit, .bettel:
|
|
|
|
return [.bettel, .wenz, .geier, .solo]
|
|
|
|
case .wenz, .geier:
|
|
|
|
return [.wenz, .geier, .solo]
|
|
|
|
case .solo:
|
|
|
|
return [.solo]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var classesWhenOutbidding: [GameClass] {
|
|
|
|
increased()?.availableClasses ?? []
|
|
|
|
}
|
2021-12-06 18:28:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension GameType.GameClass: Comparable {
|
|
|
|
|
|
|
|
static func < (lhs: GameType.GameClass, rhs: GameType.GameClass) -> Bool {
|
|
|
|
lhs.rawValue < rhs.rawValue
|
|
|
|
}
|
|
|
|
}
|
2021-12-18 15:08:43 +01:00
|
|
|
|
|
|
|
extension GameType.GameClass: GameConvertible {
|
|
|
|
|
|
|
|
var id: GameId {
|
|
|
|
rawValue
|
|
|
|
}
|
|
|
|
}
|