Show proper game summary

This commit is contained in:
Christoph Hagen
2021-12-21 14:24:53 +01:00
parent b5cc395456
commit 7de2352c61
8 changed files with 192 additions and 78 deletions

View File

@@ -2,7 +2,7 @@ import Foundation
struct GameSummary: Codable, Equatable {
let leader: PlayerName
let selector: PlayerName
let coPlayers: [PlayerName]
@@ -10,24 +10,20 @@ struct GameSummary: Codable, Equatable {
let game: GameId
let leaderPoints: Int
let points: Int
let cost: Int
var text: String = ""
init(table: FinishedTable, language: SupportedLanguage) {
let leader = table.players.first { $0.selectedGame }!
self.coPlayers = table.players
.filter { $0 != leader && $0.leadsGame == leader.leadsGame }
.map { $0.name }
self.leader = leader.name
self.selector = table.gameSelector.name
self.coPlayers = table.coPlayers.map { $0.name }
self.game = table.game.id
self.leaderPoints = table.leadingPoints
self.didWin = table.winners.contains(player: leader.name)
self.cost = table.game.basicCost
// TODO: Calculate cost correctly
self.text = language.gameSummarizer.init(game: self).text
self.points = table.selectorTeamPoints
self.didWin = table.selectorDidWin
self.cost = table.cost
self.text = language.gameSummarizer.init(table: table).text
}
}