// // TournamentWinner.swift // TournamentStats // // Created by Laurent Morvillier on 04/06/2019. // Copyright © 2019 Stax River. All rights reserved. // import Foundation struct TournamentWinner : HTMLRepresentable { var tournament: Tournament var result: Result var showPlayer: Bool = true func columnDescriptors() -> [ColumnDescriptor] { if showPlayer { return [ ColumnDescriptor(header: "Buy-in", number: true, widthWeight: 0.5), ColumnDescriptor(header: "Event", number: false, widthWeight: 3.0), ColumnDescriptor(header: "Player", number: false, widthWeight: 1.0), ColumnDescriptor(header: "Prize", number: true, widthWeight: 1.0)] } else { return [ ColumnDescriptor(header: "Buy-in", number: true, widthWeight: 0.5), ColumnDescriptor(header: "Event", number: false, widthWeight: 3.0), ColumnDescriptor(header: "Prizepool", number: true, widthWeight: 1.0), ColumnDescriptor(header: "Entries", number: true, widthWeight: 1.0), ] } } func cellValues() -> [String] { if showPlayer { return [ tournament.buyin.currencyFormatted, tournament.name, result.player?.formattedName ?? "", result.earnings.currencyFormatted ] } else { return [ tournament.buyin.currencyFormatted, tournament.name, tournament.prizepool.currencyFormatted, tournament.entries.formatted() ] } } func htmlHeaders() -> String { var header = "" header.append("Buy-in") header.append("Event") if showPlayer { header.append("Player") header.append("Prize") } else { header.append("Prizepool") header.append("Entries") } return "\(header)" } // func html() -> String { // var strings: [String] = [] // strings.append("\(tournament.number)") // strings.append(tournament.buyin.currencyFormatted) // strings.append(tournament.name) // strings.append(result.player?.formattedName ?? "") // strings.append(result.earnings.currencyFormatted) // let all = strings.joined(separator: "") // return "\(all)" // } }