2021-12-21 09:53:20 +01:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
struct GermanGameSummarizer: GameSummarizer {
|
|
|
|
|
2021-12-21 14:24:53 +01:00
|
|
|
let table: FinishedTable
|
2021-12-21 09:53:20 +01:00
|
|
|
|
2021-12-21 14:24:53 +01:00
|
|
|
private var winText: String {
|
|
|
|
table.selectorDidWin ? "gewinnt" : "verliert"
|
2021-12-21 09:53:20 +01:00
|
|
|
}
|
|
|
|
|
2021-12-21 14:24:53 +01:00
|
|
|
private var gameText: String {
|
|
|
|
switch table.game {
|
2021-12-21 09:53:20 +01:00
|
|
|
case .rufBlatt:
|
|
|
|
return "den Ruf Blatt"
|
|
|
|
case .rufEichel:
|
|
|
|
return "den Ruf Eichel"
|
|
|
|
case .rufSchelln:
|
|
|
|
return "den Ruf Schelln"
|
|
|
|
case .bettel:
|
|
|
|
return "den Bettel"
|
|
|
|
case .geier:
|
|
|
|
return "den Geier"
|
|
|
|
case .wenz:
|
|
|
|
return "den Wenz"
|
|
|
|
case .hochzeit:
|
|
|
|
return "die Hochzeit"
|
|
|
|
case .soloBlatt:
|
|
|
|
return "das Solo Blatt"
|
|
|
|
case .soloEichel:
|
|
|
|
return "das Solo Eichel"
|
|
|
|
case .soloHerz:
|
|
|
|
return "das Solo Herz"
|
|
|
|
case .soloSchelln:
|
|
|
|
return "das Solo Schelln"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 14:24:53 +01:00
|
|
|
private var coPlayerNames: String {
|
|
|
|
let coPlayers = table.coPlayers
|
|
|
|
switch coPlayers.count {
|
2021-12-21 09:53:20 +01:00
|
|
|
case 0:
|
|
|
|
return ""
|
|
|
|
case 1:
|
2021-12-21 14:24:53 +01:00
|
|
|
return " mit \(coPlayers[0].name)"
|
2021-12-21 09:53:20 +01:00
|
|
|
case 2:
|
2021-12-21 14:24:53 +01:00
|
|
|
return " mit \(coPlayers[0].name) und \(coPlayers[1].name)"
|
2021-12-21 09:53:20 +01:00
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 14:24:53 +01:00
|
|
|
private var costText: String {
|
|
|
|
let cost = table.cost
|
|
|
|
guard cost >= 100 else {
|
|
|
|
return "\(cost) Cent"
|
2021-12-21 09:53:20 +01:00
|
|
|
}
|
2021-12-21 14:24:53 +01:00
|
|
|
return String(format: "%d.%02d €", cost / 100, cost % 100)
|
|
|
|
}
|
|
|
|
|
|
|
|
private var costExplanation: String {
|
|
|
|
var components = [String]()
|
|
|
|
components.append("Grundspiel \(table.game.basicCost)")
|
|
|
|
if !table.isBettel {
|
|
|
|
if table.isSchwarz {
|
|
|
|
components.append("Schwarz")
|
|
|
|
} else if table.isSchneider {
|
|
|
|
components.append("Schneider")
|
|
|
|
}
|
|
|
|
if table.leadingTrumps > 0 {
|
|
|
|
components.append("\(table.leadingTrumps) Laufende")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
components.append("\(table.totalNumberOfDoubles)x gedoppelt")
|
|
|
|
return components.joined(separator: ", ")
|
2021-12-21 09:53:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var text: String {
|
2021-12-21 14:24:53 +01:00
|
|
|
let start = "\(table.gameSelector.name) \(winText) \(gameText)"
|
|
|
|
let cost = " Das Spiel kostet \(costText) (\(costExplanation))."
|
|
|
|
guard table.game != .bettel else {
|
|
|
|
return start + cost
|
|
|
|
}
|
|
|
|
return start + "\(coPlayerNames) mit \(table.selectorTeamPoints) Punkten." + cost
|
2021-12-21 09:53:20 +01:00
|
|
|
}
|
|
|
|
}
|