Add final statistics when game ends

This commit is contained in:
Christoph Hagen
2021-12-21 09:53:42 +01:00
parent fa1be9485e
commit 941b25346d
5 changed files with 43 additions and 4 deletions

View File

@ -8,10 +8,13 @@ final class FinishedPlayer: Player {
let playedCard: Card
let selectedGame: Bool
init(player: PlayingPlayer) {
self.points = player.wonTricks.map { $0.points }.reduce(0, +)
self.leadsGame = player.leadsGame
self.playedCard = player.playedCard!
self.selectedGame = player.selectsGame
super.init(player: player)
}
@ -25,7 +28,6 @@ final class FinishedPlayer: Player {
override var info: PlayerInfo {
var result = super.info
result.points = points
result.playedCard = playedCard.id
return result
}

View File

@ -84,4 +84,10 @@ final class FinishedTable: AbstractTable<FinishedPlayer> {
let table = DealingTable(table: waiting)
return (.success, table)
}
override func tableInfo(forPlayerAt index: Int) -> TableInfo {
var info = super.tableInfo(forPlayerAt: index)
info.gameStats = GameStatistics(table: self, language: language)
return info
}
}