import Foundation struct GameStatistics: Codable, Equatable { let leader: PlayerName let coPlayers: [PlayerName] let didWin: Bool let game: GameId let leaderPoints: 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.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 } }