2021-12-21 09:53:20 +01:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
struct EnglishGameSummarizer: GameSummarizer {
|
|
|
|
|
2021-12-21 14:24:53 +01:00
|
|
|
let table: FinishedTable
|
2021-12-21 09:53:20 +01:00
|
|
|
|
|
|
|
private var winText: String {
|
2021-12-21 14:24:53 +01:00
|
|
|
table.selectorDidWin ? "won" : "lost"
|
2021-12-21 09:53:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private var gameText: String {
|
2021-12-21 14:24:53 +01:00
|
|
|
switch table.game {
|
|
|
|
case .rufBlatt:
|
|
|
|
return "the call of Blatt"
|
|
|
|
case .rufEichel:
|
|
|
|
return "the call of Eichel"
|
|
|
|
case .rufSchelln:
|
|
|
|
return "the call of Schelln"
|
|
|
|
case .bettel:
|
|
|
|
return "the Bettel"
|
|
|
|
case .geier:
|
|
|
|
return "the Geier"
|
|
|
|
case .wenz:
|
|
|
|
return "the Wenz"
|
|
|
|
case .hochzeit:
|
|
|
|
return "the wedding"
|
|
|
|
case .soloBlatt:
|
|
|
|
return "the Solo Blatt"
|
|
|
|
case .soloEichel:
|
|
|
|
return "the Solo Eichel"
|
|
|
|
case .soloHerz:
|
|
|
|
return "the Solo Herz"
|
|
|
|
case .soloSchelln:
|
|
|
|
return "the Solo Schelln"
|
|
|
|
}
|
2021-12-21 09:53:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private var coPlayerNames: String {
|
2021-12-21 14:24:53 +01:00
|
|
|
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 " with \(coPlayers[0].name)"
|
2021-12-21 09:53:20 +01:00
|
|
|
case 2:
|
2021-12-21 14:24:53 +01:00
|
|
|
return " with \(coPlayers[0].name) and \(coPlayers[1].name)"
|
2021-12-21 09:53:20 +01:00
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private var costText: String {
|
2021-12-21 14:24:53 +01:00
|
|
|
let cost = table.cost
|
|
|
|
guard cost >= 100 else {
|
|
|
|
return "\(cost) cents"
|
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("Game \(table.game.basicCost)")
|
|
|
|
if !table.isBettel {
|
2021-12-22 14:54:31 +01:00
|
|
|
if table.isHochzeit {
|
|
|
|
components.append("wedding")
|
|
|
|
}
|
2021-12-21 14:24:53 +01:00
|
|
|
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 doubled")
|
|
|
|
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) the \(gameText)"
|
|
|
|
let cost = " The game costs \(costText) (\(costExplanation))."
|
|
|
|
guard table.game != .bettel else {
|
|
|
|
return start + cost
|
|
|
|
}
|
|
|
|
return start + "\(coPlayerNames) with \(table.selectorTeamPoints) points." + cost
|
2021-12-21 09:53:20 +01:00
|
|
|
}
|
|
|
|
}
|