From 23eded127bf9d906984518532d0b29faeff6fce4 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 1 Dec 2021 15:00:18 +0100 Subject: [PATCH] Update for 2021 infography --- TournamentStats.xcodeproj/project.pbxproj | 8 +- TournamentStats/AppDelegate.swift | 26 +- TournamentStats/UI/Fonts.swift | 57 ++- TournamentStats/UI/components/BarChart.swift | 44 +++ .../UI/components/DataSourceWrapper.swift | 2 +- TournamentStats/UI/components/Label.swift | 2 +- TournamentStats/UI/components/PieChart.swift | 4 +- TournamentStats/UI/components/TableView.swift | 6 +- .../UI/components/TitleLabel.swift | 15 +- .../UI/reports/InfographyView.swift | 56 +-- TournamentStats/UI/reports/InfographyView.xib | 324 ++++++++++-------- TournamentStats/realm/Model.swift | 5 +- TournamentStats/report/Queries.swift | 17 +- TournamentStats/report/ReportGenerator.swift | 8 +- .../report/structures/CountryCounter.swift | 6 + .../report/structures/CumulatedResults.swift | 9 +- .../report/structures/FestivalStats.swift | 4 +- .../structures/PlayerNotableFinishes.swift | 19 +- .../report/structures/TournamentCounter.swift | 5 + .../report/structures/TournamentStats.swift | 6 +- TournamentStats/scrapper/Downloader.swift | 189 +++++----- .../utils/ColumnRepresentable.swift | 60 +++- TournamentStats/utils/Game.swift | 8 + 23 files changed, 528 insertions(+), 352 deletions(-) create mode 100644 TournamentStats/UI/components/BarChart.swift diff --git a/TournamentStats.xcodeproj/project.pbxproj b/TournamentStats.xcodeproj/project.pbxproj index 712b3f8..fc1a2a6 100644 --- a/TournamentStats.xcodeproj/project.pbxproj +++ b/TournamentStats.xcodeproj/project.pbxproj @@ -144,6 +144,7 @@ 4DF78DD122F9AADF00C02F73 /* TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF78DD022F9AADF00C02F73 /* TableView.swift */; }; 4DF78DD422F9C85C00C02F73 /* UIColor+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF78DD322F9C85C00C02F73 /* UIColor+Extensions.swift */; }; 4DF78DD622F9CE7E00C02F73 /* TitleLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF78DD522F9CE7E00C02F73 /* TitleLabel.swift */; }; + C4408391275760E800A68675 /* BarChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4408390275760E800A68675 /* BarChart.swift */; }; FFE9052C22BB7313006FEFA4 /* event34 in Resources */ = {isa = PBXBuildFile; fileRef = FFE9052922BB7312006FEFA4 /* event34 */; }; FFE9052D22BB7313006FEFA4 /* event41 in Resources */ = {isa = PBXBuildFile; fileRef = FFE9052A22BB7312006FEFA4 /* event41 */; }; FFE9052E22BB7313006FEFA4 /* event40 in Resources */ = {isa = PBXBuildFile; fileRef = FFE9052B22BB7313006FEFA4 /* event40 */; }; @@ -298,6 +299,7 @@ 4DF78DD022F9AADF00C02F73 /* TableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableView.swift; sourceTree = ""; }; 4DF78DD322F9C85C00C02F73 /* UIColor+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extensions.swift"; sourceTree = ""; }; 4DF78DD522F9CE7E00C02F73 /* TitleLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleLabel.swift; sourceTree = ""; }; + C4408390275760E800A68675 /* BarChart.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarChart.swift; sourceTree = ""; }; FFE9052922BB7312006FEFA4 /* event34 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = event34; sourceTree = ""; }; FFE9052A22BB7312006FEFA4 /* event41 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = event41; sourceTree = ""; }; FFE9052B22BB7313006FEFA4 /* event40 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = event40; sourceTree = ""; }; @@ -574,11 +576,12 @@ 4DF78DCF22F9AA9300C02F73 /* components */ = { isa = PBXGroup; children = ( + C4408390275760E800A68675 /* BarChart.swift */, + 4D39B6F222F8549100625E31 /* DataSourceWrapper.swift */, + 4DB113DA230559F600D0C671 /* Label.swift */, 4DF78DCD22F9AA3F00C02F73 /* PieChart.swift */, 4DF78DD022F9AADF00C02F73 /* TableView.swift */, - 4D39B6F222F8549100625E31 /* DataSourceWrapper.swift */, 4DF78DD522F9CE7E00C02F73 /* TitleLabel.swift */, - 4DB113DA230559F600D0C671 /* Label.swift */, ); path = components; sourceTree = ""; @@ -810,6 +813,7 @@ 4DD9C5BD2316D092003501A4 /* PlayerNotableFinishes.swift in Sources */, 4DDEF11422AE4FB900F4D7C1 /* TournamentStats.swift in Sources */, 4DF760A722A3FD12004B0EF1 /* Model.swift in Sources */, + C4408391275760E800A68675 /* BarChart.swift in Sources */, 4D39B6FC22F8686300625E31 /* CumulatedWins.swift in Sources */, 4DF7614F22A6CF93004B0EF1 /* PlayerResult.swift in Sources */, 4D39B6F722F8573900625E31 /* StackTableCell.swift in Sources */, diff --git a/TournamentStats/AppDelegate.swift b/TournamentStats/AppDelegate.swift index c582aea..48b5586 100644 --- a/TournamentStats/AppDelegate.swift +++ b/TournamentStats/AppDelegate.swift @@ -17,13 +17,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { -// for fontFamilyName in UIFont.familyNames { -// print("family: \(fontFamilyName)\n") -// -// for fontName in UIFont.fontNames(forFamilyName: fontFamilyName) { -// print("font: \(fontName)") -// } -// } + for fontFamilyName in UIFont.familyNames { + print("family: \(fontFamilyName)\n") + + for fontName in UIFont.fontNames(forFamilyName: fontFamilyName) { + print("font: \(fontName)") + } + } // UI stuff let splitViewController = window!.rootViewController as! UISplitViewController @@ -39,16 +39,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele // launchReports() - let realm = try! Realm() - try! realm.write { - realm.deleteAll() - } +// let realm = try! Realm() +// try! realm.write { +// realm.deleteAll() +// } - Downloader.downloadWSOPResults() +// Downloader.downloadWSOPResults() let generator = ReportGenerator() generator.generate() + InfographyView.generate(generator) + let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] print("documents = \(documentsPath)") diff --git a/TournamentStats/UI/Fonts.swift b/TournamentStats/UI/Fonts.swift index 9cd9ea3..1604a35 100644 --- a/TournamentStats/UI/Fonts.swift +++ b/TournamentStats/UI/Fonts.swift @@ -11,22 +11,55 @@ import UIKit class Fonts { - fileprivate enum FontName : String { - case regular = "Menlo-Regular" - case bold = "Menlo-Bold" + fileprivate enum FontName { + case graph + case regular + case bold + + var name: String { + switch self { + case .graph: + return "Menlo-Bold" + case .regular: + return "HelveticaNeue" + case .bold: + return "HelveticaNeue-Bold" + } + } } - static let monospaced: UIFont = UIFont(name: FontName.regular.rawValue, size: 18.0)! - static let bigNumbers: UIFont = UIFont(name: FontName.regular.rawValue, size: 48.0)! + static let color: UIColor = UIColor.white + static let titleColor: UIColor = UIColor.white //UIColor(r: 31, g: 222, b: 255, a: 1.0) + static let graphTextColor: UIColor = UIColor(white: 0.8, alpha: 1.0) + + static var monospaced: UIFont { return Fonts.monospaced(size: 18) } + static var bigNumbers: UIFont { return Fonts.monospaced(size: 48) } + static let graph: UIFont = UIFont(name: FontName.graph.name, size: 18.0)! + + static let small: UIFont = UIFont(name: FontName.regular.name, size: 16.0)! + static let regular: UIFont = UIFont(name: FontName.regular.name, size: 18.0)! + static let bold: UIFont = UIFont(name: FontName.bold.name, size: 18.0)! - static let regular: UIFont = UIFont(name: FontName.regular.rawValue, size: 18.0)! - static let bold: UIFont = UIFont(name: FontName.bold.rawValue, size: 18.0)! + static let mainTitle: UIFont = UIFont(name: FontName.bold.name, size: 72.0)! + static let title: UIFont = UIFont(name: FontName.bold.name, size: 36.0)! + static let subTitle: UIFont = UIFont(name: FontName.regular.name, size: 28.0)! + static let cellTitle: UIFont = UIFont(name: FontName.regular.name, size: 20.0)! - static let mainTitle: UIFont = UIFont(name: FontName.regular.rawValue, size: 72.0)! - static let subTitle: UIFont = UIFont(name: FontName.regular.rawValue, size: 28.0)! - static let cellTitle: UIFont = UIFont(name: FontName.regular.rawValue, size: 20.0)! + static let chartEntries: UIFont = UIFont(name: FontName.bold.name, size: 28.0)! + static let chartLegend: UIFont = UIFont(name: FontName.regular.name, size: 18.0)! - static let pieChartEntries: UIFont = UIFont(name: FontName.bold.rawValue, size: 28.0)! - static let chartLegend: UIFont = UIFont(name: FontName.regular.rawValue, size: 18.0)! // + fileprivate static func monospaced(size: CGFloat = 18.0, weight: UIFont.Weight = .regular) -> UIFont { + let features = [ + [ + UIFontDescriptor.FeatureKey.featureIdentifier: kNumberSpacingType, + UIFontDescriptor.FeatureKey.typeIdentifier: kMonospacedNumbersSelector + ] + ] + + let fontDescriptor = UIFont.systemFont(ofSize: size, weight: weight).fontDescriptor.addingAttributes( + [UIFontDescriptor.AttributeName.featureSettings: features] + ) + return UIFont(descriptor: fontDescriptor, size: size) + } } diff --git a/TournamentStats/UI/components/BarChart.swift b/TournamentStats/UI/components/BarChart.swift new file mode 100644 index 0000000..b423e49 --- /dev/null +++ b/TournamentStats/UI/components/BarChart.swift @@ -0,0 +1,44 @@ +// +// BarChart.swift +// TournamentStats +// +// Created by Laurent Morvillier on 01/12/2021. +// Copyright © 2021 Stax River. All rights reserved. +// + +import Foundation +import UIKit +import Charts + +class BarChart : BarChartView { + + override init(frame: CGRect) { + super.init(frame: frame) + + self.leftAxis.labelTextColor = Fonts.graphTextColor + self.leftAxis.labelFont = Fonts.graph + self.leftAxis.drawGridLinesEnabled = false + self.leftAxis.drawZeroLineEnabled = true + self.leftAxis.axisMinimum = 0.0 + + self.xAxis.drawGridLinesEnabled = false + self.xAxis.drawAxisLineEnabled = false + self.xAxis.granularity = 1 + self.xAxis.labelTextColor = Fonts.graphTextColor + self.xAxis.labelFont = Fonts.graph + self.xAxis.labelPosition = .bottom + + self.rightAxis.enabled = false + + self.legend.enabled = false + } + + func setXAxisLabels(_ labels: [String]) { + self.xAxis.valueFormatter = IndexAxisValueFormatter(values: labels) + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} diff --git a/TournamentStats/UI/components/DataSourceWrapper.swift b/TournamentStats/UI/components/DataSourceWrapper.swift index cc6bae4..b54c2a0 100644 --- a/TournamentStats/UI/components/DataSourceWrapper.swift +++ b/TournamentStats/UI/components/DataSourceWrapper.swift @@ -77,7 +77,7 @@ class DataSourceWrapper : NSObject, UITableViewDataSour labelContainer.widthAnchor.constraint(equalTo: cell.contentView.widthAnchor, multiplier: multiplier).isActive = true let label: UILabel = UILabel(frame: CGRect.zero) - label.textColor = UIColor.white + label.textColor = Fonts.color label.backgroundColor = UIColor.clear label.text = value label.font = font diff --git a/TournamentStats/UI/components/Label.swift b/TournamentStats/UI/components/Label.swift index 97dd43f..96a75af 100644 --- a/TournamentStats/UI/components/Label.swift +++ b/TournamentStats/UI/components/Label.swift @@ -17,7 +17,7 @@ class Label: UILabel { } fileprivate func _initialize() { - self.textColor = UIColor.white + self.textColor = Fonts.color self.font = Fonts.subTitle } diff --git a/TournamentStats/UI/components/PieChart.swift b/TournamentStats/UI/components/PieChart.swift index 3936903..8487b40 100644 --- a/TournamentStats/UI/components/PieChart.swift +++ b/TournamentStats/UI/components/PieChart.swift @@ -15,8 +15,6 @@ class PieChart : PieChartView { override init(frame: CGRect) { super.init(frame: frame) -// self.backgroundColor = UIColor.gray - self.holeColor = UIColor.clear self.usePercentValuesEnabled = true self.minOffset = 16.0 @@ -24,7 +22,7 @@ class PieChart : PieChartView { self.drawEntryLabelsEnabled = false self.transparentCircleRadiusPercent = 0 - self.legend.textColor = UIColor.white + self.legend.textColor = Fonts.graphTextColor self.legend.font = Fonts.chartLegend self.legend.orientation = .vertical self.legend.form = .circle diff --git a/TournamentStats/UI/components/TableView.swift b/TournamentStats/UI/components/TableView.swift index 3d32d22..e1b1fa1 100644 --- a/TournamentStats/UI/components/TableView.swift +++ b/TournamentStats/UI/components/TableView.swift @@ -25,7 +25,7 @@ class TableView : UITableView { private func label(height: CGFloat, text: String) -> UILabel { let label = UILabel(frame: CGRect(x: 0, y: 0, width: self.frame.width, height: height)) label.text = text - label.textColor = UIColor.white + label.textColor = Fonts.color label.backgroundColor = UIColor.clear label.textAlignment = .center label.font = Fonts.regular @@ -35,7 +35,8 @@ class TableView : UITableView { func setHeader(header: String) { let label = self.label(height: 60.0, text: header) label.textAlignment = .left - label.font = Fonts.subTitle + label.font = Fonts.title + label.textColor = Fonts.titleColor self.tableHeaderView = label } @@ -58,6 +59,7 @@ class TableView : UITableView { self.register(UINib(nibName: "StackTableCell", bundle: Bundle.main), forCellReuseIdentifier: "Cell") self.backgroundColor = UIColor.clear + self.separatorColor = UIColor.lightGray } diff --git a/TournamentStats/UI/components/TitleLabel.swift b/TournamentStats/UI/components/TitleLabel.swift index 873750c..2be5a2b 100644 --- a/TournamentStats/UI/components/TitleLabel.swift +++ b/TournamentStats/UI/components/TitleLabel.swift @@ -13,14 +13,19 @@ class TitleLabel : UILabel { init(frame: CGRect, text: String) { super.init(frame: frame) - self.textColor = UIColor.white - self.text = text - self.textAlignment = .center - self.font = UIFont.boldSystemFont(ofSize: 16.0) + self._configure() } required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") + super.init(coder: aDecoder) + self._configure() + } + + fileprivate func _configure() { + self.textColor = Fonts.titleColor + self.text = text + self.textAlignment = .left + self.font = Fonts.title } } diff --git a/TournamentStats/UI/reports/InfographyView.swift b/TournamentStats/UI/reports/InfographyView.swift index df0bbc6..03de646 100644 --- a/TournamentStats/UI/reports/InfographyView.swift +++ b/TournamentStats/UI/reports/InfographyView.swift @@ -100,8 +100,7 @@ class InfographyView: UIView { } fileprivate func _createBackground() { - let startColor = UIColor(red: 23/255, green: 72/255, blue: 61/255, alpha: 1) - self.backgroundColor = startColor + self.backgroundColor = UIColor(r: 8, g: 54, b: 63, a: 1) } fileprivate func _fillView() { @@ -110,8 +109,8 @@ class InfographyView: UIView { return } - self.infographyTitle.text = "2019 World Series of Poker" - self.infographyTitle.textColor = UIColor.white + self.infographyTitle.text = "2021 World Series of Poker" + self.infographyTitle.textColor = Fonts.color self.infographyTitle.font = Fonts.mainTitle self.collectionView.register(UINib(nibName: "StatCollectionViewCell", bundle: Bundle.main), forCellWithReuseIdentifier: "Stat") @@ -134,22 +133,24 @@ class InfographyView: UIView { self.tableView12.setData(data: generator.mostCashes, maxRows: 5) self.tableView12.setHeader(header: "Most cashes") - self.tableView13.setData(data: generator.averageCash, maxRows: 5) - self.tableView13.setHeader(header: "Best average cash (8+)") + self.tableView13.setData(data: generator.averageCash.results, maxRows: 5) + self.tableView13.setHeader(header: "Best average cash (\(generator.averageCash.minimumCashes)+)") ///// self.label21.text = "Buy-in distribution" self.label22.text = "First prizes distribution" - let pieChartFrame = CGRect(x: 0, y: 0, width: 650, height: 500) - let buyinDistribPie = PieChart(frame: pieChartFrame) - buyinDistribPie.data = generator.tournamentBuyinDistribution.pieChartData - self.container21.addSubview(buyinDistribPie) + let barChartFrame = CGRect(x: 0, y: 0, width: 650, height: 500) + let buyinDistribBarChart = BarChart(frame: barChartFrame) + buyinDistribBarChart.data = generator.tournamentBuyinDistribution.barChartData + buyinDistribBarChart.setXAxisLabels(generator.tournamentBuyinDistribution.labels) + self.container21.addSubview(buyinDistribBarChart) - let firstPrizeDistributionPie = PieChart(frame: pieChartFrame) - firstPrizeDistributionPie.data = generator.firstPrizeDistribution.pieChartData - self.container22.addSubview(firstPrizeDistributionPie) + let firstPrizeDistributionBarChart = BarChart(frame: barChartFrame) + firstPrizeDistributionBarChart.data = generator.firstPrizeDistribution.barChartData + firstPrizeDistributionBarChart.setXAxisLabels(generator.firstPrizeDistribution.labels) + self.container22.addSubview(firstPrizeDistributionBarChart) ///// @@ -163,26 +164,29 @@ class InfographyView: UIView { self.label41.text = "USA vs. World bracelets" self.label42.text = "Games distribution" - let USABraceletsDistribPie = PieChart(frame: pieChartFrame) - USABraceletsDistribPie.data = generator.USAvsWorldWins.pieChartData - self.container41.addSubview(USABraceletsDistribPie) - self.container41.addMaxConstraints(view: USABraceletsDistribPie) - - let holdemDistributionPie = PieChart(frame: pieChartFrame) - holdemDistributionPie.data = generator.gamesDistribution.pieChartData - self.container42.addSubview(holdemDistributionPie) - self.container42.addMaxConstraints(view: holdemDistributionPie) + let USABraceletsDistribBarChart = BarChart(frame: barChartFrame) + USABraceletsDistribBarChart.data = generator.USAvsWorldWins.barChartData + USABraceletsDistribBarChart.setXAxisLabels(generator.USAvsWorldWins.labels) + self.container41.addSubview(USABraceletsDistribBarChart) + self.container41.addMaxConstraints(view: USABraceletsDistribBarChart) + + let holdemDistributionBarChart = BarChart(frame: barChartFrame) + holdemDistributionBarChart.data = generator.gamesDistribution.barChartData + holdemDistributionBarChart.setXAxisLabels(generator.gamesDistribution.labels) + self.container42.addSubview(holdemDistributionBarChart) + self.container42.addMaxConstraints(view: holdemDistributionBarChart) self.label51.text = "Average event" - let ds = generator.averageEvent.first + let ds: TournamentStats? = generator.averageEvent.first self.collectionView51.register(UINib(nibName: "StatCollectionViewCell", bundle: Bundle.main), forCellWithReuseIdentifier: "Stat") self.collectionView51.dataSource = ds self.collectionView51.delegate = ds self.labelTableSize.text = "No-Limit Hold'em table sizes" - let tableSizeDistributionPie = PieChart(frame: pieChartFrame) - tableSizeDistributionPie.data = generator.tableSizeDistribution.pieChartData - self.containerTableSize.addSubview(tableSizeDistributionPie) + let tableSizeDistributionBarChart = BarChart(frame: barChartFrame) + tableSizeDistributionBarChart.data = generator.tableSizeDistribution.barChartData + tableSizeDistributionBarChart.setXAxisLabels(generator.tableSizeDistribution.labels) + self.containerTableSize.addSubview(tableSizeDistributionBarChart) } } diff --git a/TournamentStats/UI/reports/InfographyView.xib b/TournamentStats/UI/reports/InfographyView.xib index b196de6..4173669 100644 --- a/TournamentStats/UI/reports/InfographyView.xib +++ b/TournamentStats/UI/reports/InfographyView.xib @@ -1,23 +1,22 @@ - - - - + + - + + - + - + + - - + @@ -51,11 +50,11 @@ - - + + - + @@ -64,47 +63,47 @@ - + + - + - - + - - - + + + - - + + - + - + + - + - - + - + - + @@ -112,63 +111,71 @@ - + + - + - - - - - - - - - - - - - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - + + - + - - + - + @@ -176,19 +183,19 @@ - + + - + - - + - + @@ -196,86 +203,102 @@ - + + - + - - - + + - - + + + + + + + + + + + + + + + + + + + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -284,15 +307,16 @@ + @@ -303,7 +327,6 @@ - @@ -313,12 +336,9 @@ - - - @@ -338,4 +358,12 @@ + + + + + + + + diff --git a/TournamentStats/realm/Model.swift b/TournamentStats/realm/Model.swift index cfe10f3..e8b57e7 100644 --- a/TournamentStats/realm/Model.swift +++ b/TournamentStats/realm/Model.swift @@ -22,7 +22,7 @@ class Tournament : Object, Named { @objc dynamic var date: Date = Date() @objc dynamic var number: Int = 0 @objc dynamic var buyin: Int = 0 - @objc dynamic var tableSize: Int = 0 + @objc dynamic var tableSize: Int = 9 @objc dynamic var name: String = "" let results = List() @@ -39,7 +39,8 @@ class Tournament : Object, Named { } var formatted: String { - return "\(self.buyin.currencyFormatted) \(self.name) (#\(self.number))" + return "\(self.buyin.currencyFormatted) \(self.name)" +// return "\(self.buyin.currencyFormatted) \(self.name) (#\(self.number))" } } diff --git a/TournamentStats/report/Queries.swift b/TournamentStats/report/Queries.swift index 8428034..1c08ef2 100644 --- a/TournamentStats/report/Queries.swift +++ b/TournamentStats/report/Queries.swift @@ -39,7 +39,7 @@ class Queries { }) } - static func averageCash(realm: Realm, minCount: Int) -> [CumulatedResults] { + static func averageCash(realm: Realm, minCount: Int) -> BestAverageCash { let players = realm.objects(Player.self).filter(NSPredicate(format: "results.@count >= %i", minCount)) var crArray: [CumulatedResults] = [] @@ -48,9 +48,10 @@ class Queries { crArray.append(CumulatedResults(player: player, options: [.average])) } - return crArray.sorted(by: { (cr1, cr2) -> Bool in + let results = crArray.sorted(by: { (cr1, cr2) -> Bool in return cr1.total > cr2.total }) + return BestAverageCash(minimumCashes: minCount, results: results) } static func mostCashes(realm: Realm, notable: Bool = false) -> [CumulatedResults] { @@ -211,10 +212,10 @@ class Queries { let tournaments: Results = realm.objects(Tournament.self) - let verylow = DistributionCounter(name: "<$1,000") - let low = DistributionCounter(name: "$1,000 - $1,999") - let medium = DistributionCounter(name: "$2,000 - $5,000") - let high = DistributionCounter(name: ">$5,000") + let verylow = DistributionCounter(name: "<$1K") + let low = DistributionCounter(name: "$1K - $2K") + let medium = DistributionCounter(name: "$2K - $5K") + let high = DistributionCounter(name: ">$5K") let counters: [DistributionCounter] = [verylow, low, medium, high] tournaments.forEach { tournament in @@ -280,8 +281,8 @@ class Queries { let tournaments: Results = realm.objects(Tournament.self) - let noLimitHoldem = DistributionCounter(name: Game.holdem.rawValue) - let potLimitOmaha = DistributionCounter(name: Game.omaha.rawValue) + let noLimitHoldem = DistributionCounter(name: Game.holdem.label) + let potLimitOmaha = DistributionCounter(name: Game.omaha.label) let not = DistributionCounter(name: "Others") let games: [DistributionCounter] = [noLimitHoldem, potLimitOmaha, not] diff --git a/TournamentStats/report/ReportGenerator.swift b/TournamentStats/report/ReportGenerator.swift index e24baf1..d32413d 100644 --- a/TournamentStats/report/ReportGenerator.swift +++ b/TournamentStats/report/ReportGenerator.swift @@ -65,7 +65,7 @@ class ReportGenerator { var cashesByCountry: [CountryCounter] = [] var averageEvent: [TournamentStats] = [] var notablesMostCashes: [CumulatedResults] = [] - var averageCash: [CumulatedResults] = [] + var averageCash: BestAverageCash = BestAverageCash(minimumCashes: 0) var tournamentBuyinDistribution: [DistributionCounter] = [] var tournamentPrizepoolDistribution: [DistributionCounter] = [] var firstPrizeDistribution: [DistributionCounter] = [] @@ -88,11 +88,11 @@ class ReportGenerator { self.tourniesByEntries = Queries.sortedEvents(realm: realm, fieldName: "entries", ascending: false) self.tourniesByPrizepool = Queries.sortedEvents(realm: realm, fieldName: "prizepool", ascending: false) self.winsByCountry = Queries.winsByCountry(realm: realm) - self.USAvsWorldWins = CountryCounter.aggregate(table: self.winsByCountry, param: "United States") + self.USAvsWorldWins = CountryCounter.aggregate(table: self.winsByCountry, param: "US") self.cashesByCountry = Queries.cashesByCountry(realm: realm) self.averageEvent = Queries.averageEvent(realm: realm) self.notablesMostCashes = Queries.mostCashes(realm: realm, notable: true) - self.averageCash = Queries.averageCash(realm: realm, minCount: 4) + self.averageCash = Queries.averageCash(realm: realm, minCount: 8) self.tournamentBuyinDistribution = Queries.tournamentBuyinDistribution(realm: realm) self.tournamentPrizepoolDistribution = Queries.tournamentPrizepoolDistribution(realm: realm) self.firstPrizeDistribution = Queries.firstPrizeDistribution(realm: realm) @@ -135,7 +135,7 @@ class ReportGenerator { self.cashesByCountry.writeHTML(fileName: "reports/countryCashes.html") self.averageEvent.writeHTML(fileName: "reports/averageEvent.html") self.notablesMostCashes.writeHTML(fileName: "reports/notablesMostCashes.html", limit: nil) - self.averageCash.writeHTML(fileName: "reports/bestAverageCashes.html", limit: 5) + self.averageCash.results.writeHTML(fileName: "reports/bestAverageCashes.html", limit: 5) self.tournamentBuyinDistribution.writeHTML(fileName: "reports/buyinDistribution.html") self.tournamentPrizepoolDistribution.writeHTML(fileName: "reports/prizepoolDistribution.html") self.firstPrizeDistribution.writeHTML(fileName: "reports/firstPrizeDistribution.html") diff --git a/TournamentStats/report/structures/CountryCounter.swift b/TournamentStats/report/structures/CountryCounter.swift index d38e579..54a6492 100644 --- a/TournamentStats/report/structures/CountryCounter.swift +++ b/TournamentStats/report/structures/CountryCounter.swift @@ -60,4 +60,10 @@ final class CountryCounter : HTMLRepresentable, Aggregeable { return PieChartDataEntry(value: Double(self.counter), label: self.country) } + func barChartDataEntry(index: Double) -> BarChartDataEntry { + return BarChartDataEntry(x: index, y: Double(self.counter), data: self.country) + } + + var name: String { return self.country } + } diff --git a/TournamentStats/report/structures/CumulatedResults.swift b/TournamentStats/report/structures/CumulatedResults.swift index f00cb67..675f070 100644 --- a/TournamentStats/report/structures/CumulatedResults.swift +++ b/TournamentStats/report/structures/CumulatedResults.swift @@ -8,6 +8,13 @@ import Foundation +struct BestAverageCash { + + var minimumCashes: Int + var results: [CumulatedResults] = [] + +} + class CumulatedResults : HTMLRepresentable, ColumnRepresentable { enum Options { @@ -50,7 +57,7 @@ class CumulatedResults : HTMLRepresentable, ColumnRepresentable { } private func add(result: Result) { - if result.tournaments.first?.number == 73 && result.rank < 10 { + if result.tournaments.first?.number == 67 && result.rank < 10 { self.mainEventFinalist = true } diff --git a/TournamentStats/report/structures/FestivalStats.swift b/TournamentStats/report/structures/FestivalStats.swift index df79b01..9ec445f 100644 --- a/TournamentStats/report/structures/FestivalStats.swift +++ b/TournamentStats/report/structures/FestivalStats.swift @@ -47,8 +47,8 @@ class FestivalStats : NSObject, UICollectionViewDataSource, UICollectionViewDele cell.nameLabel.text = name.uppercased() cell.valueLabel.text = value - cell.nameLabel.textColor = UIColor.white - cell.valueLabel.textColor = UIColor.white + cell.nameLabel.textColor = Fonts.color + cell.valueLabel.textColor = Fonts.color cell.nameLabel.font = Fonts.regular cell.valueLabel.font = Fonts.bigNumbers diff --git a/TournamentStats/report/structures/PlayerNotableFinishes.swift b/TournamentStats/report/structures/PlayerNotableFinishes.swift index c7bd3e6..85cb3e9 100644 --- a/TournamentStats/report/structures/PlayerNotableFinishes.swift +++ b/TournamentStats/report/structures/PlayerNotableFinishes.swift @@ -52,9 +52,9 @@ class PlayerNotableFinishesDataSource : NSObject, UITableViewDataSource, UITable let sortedWins = win.wins.sorted(by: { $0.tournaments.first!.number < $1.tournaments.first!.number }) for result in sortedWins { if let tournamentName = result.tournaments.first?.formatted { - self.winsDisplay.append((" " + tournamentName, Fonts.regular)) + self.winsDisplay.append((" " + tournamentName, Fonts.small)) } else { - self.winsDisplay.append(("no tournament!!!", Fonts.regular)) + self.winsDisplay.append(("no tournament!!!", Fonts.small)) } } } @@ -72,7 +72,7 @@ class PlayerNotableFinishesDataSource : NSObject, UITableViewDataSource, UITable let sortedRunnerUps = runnerup.runnerUps.sorted(by: { $0.tournaments.first!.number < $1.tournaments.first!.number }) for result in sortedRunnerUps { if let tournamentName = result.tournaments.first?.formatted { - self.runnerUpsDisplay.append((" " + tournamentName, Fonts.regular)) + self.runnerUpsDisplay.append((" " + tournamentName, Fonts.regular)) } else { self.runnerUpsDisplay.append(("no tournament!!!", Fonts.regular)) } @@ -100,10 +100,10 @@ class PlayerNotableFinishesDataSource : NSObject, UITableViewDataSource, UITable return cumulatedResults } - // MARK - Table + // MARK: - Table func numberOfSections(in tableView: UITableView) -> Int { - return 2 + return 1 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { @@ -121,7 +121,7 @@ class PlayerNotableFinishesDataSource : NSObject, UITableViewDataSource, UITable let cell = UITableViewCell() cell.backgroundColor = UIColor.clear - cell.textLabel?.textColor = UIColor.white + cell.textLabel?.textColor = Fonts.color let font: UIFont let text: String @@ -155,12 +155,11 @@ class PlayerNotableFinishesDataSource : NSObject, UITableViewDataSource, UITable default: text = "Most final tables" } - return self.headerLabel(text: text) } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - return 36.0 + return 32.0 } func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { @@ -173,8 +172,8 @@ class PlayerNotableFinishesDataSource : NSObject, UITableViewDataSource, UITable func headerLabel(text: String) -> UILabel { let label = UILabel(frame: CGRect(x: 0, y: 0, width: 500.0, height: 60.0)) - label.textColor = UIColor.white - label.font = Fonts.subTitle + label.textColor = Fonts.titleColor + label.font = Fonts.title label.text = text return label } diff --git a/TournamentStats/report/structures/TournamentCounter.swift b/TournamentStats/report/structures/TournamentCounter.swift index 1a8bbd3..f213a73 100644 --- a/TournamentStats/report/structures/TournamentCounter.swift +++ b/TournamentStats/report/structures/TournamentCounter.swift @@ -42,6 +42,11 @@ class DistributionCounter : HTMLRepresentable { var pieChartDataEntry: PieChartDataEntry { return PieChartDataEntry(value: Double(self.counter), label: name) } + + func barChartDataEntry(index: Double) -> BarChartDataEntry { + return BarChartDataEntry(x: index, y: Double(self.counter), data: self.name) + } + // func htmlHeaders() -> String { // var strings: [String] = [] diff --git a/TournamentStats/report/structures/TournamentStats.swift b/TournamentStats/report/structures/TournamentStats.swift index 00b6acb..84bb037 100644 --- a/TournamentStats/report/structures/TournamentStats.swift +++ b/TournamentStats/report/structures/TournamentStats.swift @@ -153,8 +153,8 @@ class TournamentStats : NSObject, HTMLRepresentable, UITableViewDelegate, UITabl cell.nameLabel.text = name.uppercased() cell.valueLabel.text = value - cell.nameLabel.textColor = UIColor.white - cell.valueLabel.textColor = UIColor.white + cell.nameLabel.textColor = Fonts.color + cell.valueLabel.textColor = Fonts.color cell.nameLabel.font = Fonts.regular cell.valueLabel.font = Fonts.bigNumbers @@ -163,7 +163,7 @@ class TournamentStats : NSObject, HTMLRepresentable, UITableViewDelegate, UITabl } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - return CGSize(width: 650.0, height: 90.0) + return CGSize(width: collectionView.frame.width, height: 90.0) } } diff --git a/TournamentStats/scrapper/Downloader.swift b/TournamentStats/scrapper/Downloader.swift index 63edfd3..816af7f 100644 --- a/TournamentStats/scrapper/Downloader.swift +++ b/TournamentStats/scrapper/Downloader.swift @@ -19,99 +19,105 @@ class Downloader { static func downloadWSOPResults() { let infos: [TS] = [ -// TS(id: "19728", date: "02/10/2021"), -// TS(id: "19729", date: "03/10/2021"), -// TS(id: "19730", date: "02/10/2021"), -// TS(id: "19732", date: "04/10/2021"), -// TS(id: "19733", date: "05/10/2021"), -// TS(id: "19731", date: "06/10/2021"), -// TS(id: "19734", date: "06/10/2021"), -// TS(id: "19926", date: "06/10/2021"), -// TS(id: "19927", date: "06/10/2021"), -// TS(id: "19737", date: "06/10/2021"), -// TS(id: "19735", date: "07/10/2021"), -// TS(id: "19736", date: "08/10/2021"), -// TS(id: "19738", date: "08/10/2021"), -// TS(id: "19739", date: "08/10/2021"), -// TS(id: "19740", date: "09/10/2021"), -// TS(id: "19741", date: "09/10/2021"), -// TS(id: "19928", date: "10/10/2021"), -// TS(id: "19742", date: "11/10/2021"), -// TS(id: "19743", date: "11/10/2021"), -// TS(id: "19745", date: "12/10/2021"), -// TS(id: "19747", date: "12/10/2021"), -// TS(id: "19748", date: "12/10/2021"), -// TS(id: "19749", date: "13/10/2021"), -// TS(id: "19744", date: "14/10/2021"), -// TS(id: "19751", date: "14/10/2021"), -// TS(id: "19752", date: "14/10/2021"), -// TS(id: "19750", date: "15/10/2021"), -// TS(id: "19754", date: "15/10/2021"), -// TS(id: "19753", date: "16/10/2021"), -// TS(id: "19755", date: "16/10/2021"), -// TS(id: "19756", date: "17/10/2021"), -// TS(id: "19757", date: "17/10/2021"), -// TS(id: "19759", date: "17/10/2021"), -// TS(id: "19929", date: "17/10/2021"), -// TS(id: "19761", date: "19/10/2021"), -// TS(id: "19762", date: "19/10/2021"), -// TS(id: "19758", date: "20/10/2021"), -// TS(id: "19763", date: "20/10/2021"), -// TS(id: "19764", date: "20/10/2021"), -// TS(id: "19765", date: "21/10/2021"), -// TS(id: "19766", date: "21/10/2021"), -// TS(id: "19767", date: "22/10/2021"), -// TS(id: "19768", date: "23/10/2021"), -// TS(id: "19769", date: "24/10/2021"), -// TS(id: "19770", date: "24/10/2021"), -// TS(id: "19771", date: "24/10/2021"), -// TS(id: "19930", date: "24/10/2021"), -// TS(id: "19832", date: "25/10/2021"), -// TS(id: "19774", date: "26/10/2021"), -// TS(id: "19772", date: "27/10/2021"), -// TS(id: "19773", date: "27/10/2021"), -// TS(id: "19775", date: "27/10/2021"), -// TS(id: "19776", date: "28/10/2021"), -// TS(id: "19778", date: "28/10/2021"), -// TS(id: "19779", date: "28/10/2021"), -// TS(id: "19780", date: "28/10/2021"), -// TS(id: "19782", date: "31/10/2021"), -// TS(id: "19784", date: "31/10/2021"), -// TS(id: "19931", date: "31/10/2021"), -// TS(id: "19781", date: "01/11/2021"), -// TS(id: "19786", date: "01/11/2021"), -// TS(id: "19785", date: "02/11/2021"), -// TS(id: "19788", date: "02/11/2021"), -// TS(id: "19789", date: "03/11/2021"), -// TS(id: "19790", date: "03/11/2021"), -// TS(id: "19792", date: "04/11/2021"), -// TS(id: "19793", date: "04/11/2021"), -// TS(id: "19795", date: "04/11/2021"), -// TS(id: "19794", date: "05/11/2021"), -// TS(id: "19791", date: "06/11/2021"), -// TS(id: "19796", date: "06/11/2021"), -// TS(id: "19797", date: "06/11/2021"), -// TS(id: "19805", date: "13/11/2021"), -// TS(id: "19802", date: "14/11/2021"), -// TS(id: "19807", date: "14/11/2021"), -// TS(id: "19809", date: "15/11/2021"), -// TS(id: "19933", date: "16/11/2021"), -// TS(id: "19934", date: "16/11/2021"), -// TS(id: "19808", date: "17/11/2021"), -// TS(id: "19813", date: "17/11/2021"), -// TS(id: "19815", date: "17/11/2021"), -// TS(id: "19798", date: "18/11/2021"), -// TS(id: "19814", date: "18/11/2021"), -// TS(id: "19816", date: "18/11/2021"), -// TS(id: "19817", date: "20/11/2021"), -// TS(id: "19818", date: "20/11/2021"), -// TS(id: "19819", date: "20/11/2021"), -// TS(id: "19820", date: "20/11/2021"), + TS(id: "19728", date: "02/10/2021"), + TS(id: "19729", date: "03/10/2021"), + TS(id: "19730", date: "02/10/2021"), + TS(id: "19732", date: "04/10/2021"), + TS(id: "19733", date: "05/10/2021"), + TS(id: "19731", date: "06/10/2021"), + TS(id: "19734", date: "06/10/2021"), + TS(id: "19926", date: "06/10/2021"), + TS(id: "19927", date: "06/10/2021"), + TS(id: "19737", date: "06/10/2021"), + TS(id: "19735", date: "07/10/2021"), + TS(id: "19736", date: "08/10/2021"), + TS(id: "19738", date: "08/10/2021"), + TS(id: "19739", date: "08/10/2021"), + TS(id: "19740", date: "09/10/2021"), + TS(id: "19741", date: "09/10/2021"), + TS(id: "19928", date: "10/10/2021"), + TS(id: "19742", date: "11/10/2021"), + TS(id: "19743", date: "11/10/2021"), + TS(id: "19745", date: "12/10/2021"), + TS(id: "19747", date: "12/10/2021"), + TS(id: "19748", date: "12/10/2021"), + TS(id: "19749", date: "13/10/2021"), + TS(id: "19744", date: "14/10/2021"), + TS(id: "19751", date: "14/10/2021"), + TS(id: "19752", date: "14/10/2021"), + TS(id: "19750", date: "15/10/2021"), + TS(id: "19754", date: "15/10/2021"), + TS(id: "19753", date: "16/10/2021"), + TS(id: "19755", date: "16/10/2021"), + TS(id: "19756", date: "17/10/2021"), + TS(id: "19757", date: "17/10/2021"), + TS(id: "19759", date: "17/10/2021"), + TS(id: "19929", date: "17/10/2021"), + TS(id: "19761", date: "19/10/2021"), + TS(id: "19762", date: "19/10/2021"), + TS(id: "19758", date: "20/10/2021"), + TS(id: "19763", date: "20/10/2021"), + TS(id: "19764", date: "20/10/2021"), + TS(id: "19765", date: "21/10/2021"), + TS(id: "19766", date: "21/10/2021"), + TS(id: "19767", date: "22/10/2021"), + TS(id: "19768", date: "23/10/2021"), + TS(id: "19769", date: "24/10/2021"), + TS(id: "19770", date: "24/10/2021"), + TS(id: "19771", date: "24/10/2021"), + TS(id: "19930", date: "24/10/2021"), + TS(id: "19832", date: "25/10/2021"), + TS(id: "19774", date: "26/10/2021"), + TS(id: "19772", date: "27/10/2021"), + TS(id: "19773", date: "27/10/2021"), + TS(id: "19775", date: "27/10/2021"), + TS(id: "19776", date: "28/10/2021"), + TS(id: "19778", date: "28/10/2021"), + TS(id: "19779", date: "28/10/2021"), + TS(id: "19780", date: "28/10/2021"), + TS(id: "19782", date: "31/10/2021"), + TS(id: "19784", date: "31/10/2021"), + TS(id: "19931", date: "31/10/2021"), + TS(id: "19781", date: "01/11/2021"), + TS(id: "19786", date: "01/11/2021"), + TS(id: "19785", date: "02/11/2021"), + TS(id: "19788", date: "02/11/2021"), + TS(id: "19789", date: "03/11/2021"), + TS(id: "19790", date: "03/11/2021"), + TS(id: "19792", date: "04/11/2021"), + TS(id: "19793", date: "04/11/2021"), + TS(id: "19795", date: "04/11/2021"), + TS(id: "19794", date: "05/11/2021"), + TS(id: "19791", date: "06/11/2021"), + TS(id: "19796", date: "06/11/2021"), + TS(id: "19797", date: "06/11/2021"), + TS(id: "19805", date: "13/11/2021"), + TS(id: "19802", date: "14/11/2021"), + TS(id: "19807", date: "14/11/2021"), + TS(id: "19809", date: "15/11/2021"), + TS(id: "19811", date: "15/11/2021"), + TS(id: "19933", date: "16/11/2021"), + TS(id: "19934", date: "16/11/2021"), + TS(id: "19808", date: "17/11/2021"), + TS(id: "19813", date: "17/11/2021"), + TS(id: "19815", date: "17/11/2021"), + TS(id: "19798", date: "18/11/2021"), + TS(id: "19814", date: "18/11/2021"), + TS(id: "19816", date: "18/11/2021"), + TS(id: "19817", date: "20/11/2021"), + TS(id: "19818", date: "20/11/2021"), + TS(id: "19819", date: "20/11/2021"), + TS(id: "19820", date: "20/11/2021"), TS(id: "19821", date: "21/11/2021"), TS(id: "19822", date: "21/11/2021"), TS(id: "19823", date: "21/11/2021"), TS(id: "19827", date: "21/11/2021"), - + TS(id: "19828", date: "22/11/2021"), + TS(id: "19829", date: "22/11/2021"), + TS(id: "19936", date: "22/11/2021"), + TS(id: "19935", date: "22/11/2021"), + TS(id: "19830", date: "22/11/2021"), + ] for info in infos { @@ -178,7 +184,8 @@ class Downloader { if let strNumber = name.slice(from: "Event #", to: ":"), let number = nf.number(from: strNumber) { tour.number = number.intValue } - + print("#\(tour.number) \(name)") + if name.contains("6-Handed") { tour.tableSize = 6 } else if name.contains("8-Handed") { @@ -223,7 +230,7 @@ class Downloader { let cells = strresult.components(separatedBy: " [ColumnDescriptor] func cellValues() -> [String] - var chartDataEntry: ChartDataEntry { get } + func barChartDataEntry(index: Double) -> BarChartDataEntry var pieChartDataEntry: PieChartDataEntry { get } + var name: String { get } } extension ColumnRepresentable { - var chartDataEntry: ChartDataEntry { - return ChartDataEntry(x: 0, y: 0) + + func barChartDataEntry(index: Double) -> BarChartDataEntry { + return BarChartDataEntry(x: 0, y: 0) } + var pieChartDataEntry: PieChartDataEntry { return PieChartDataEntry(value: 0.0) } + + var name: String { return "none" } +} + +class IntFormatter : ValueFormatter { + + var numberFormatter: NumberFormatter = NumberFormatter() + + init() { + self.numberFormatter.maximumFractionDigits = 0 + } + + func stringForValue(_ value: Double, entry: ChartDataEntry, dataSetIndex: Int, viewPortHandler: ViewPortHandler?) -> String { + return self.numberFormatter.string(from: NSNumber(value: value)) ?? "" + } + } class PercentageFormatter : ValueFormatter { @@ -77,32 +96,35 @@ extension Array where Element : ColumnRepresentable { dataEntries.append(representable.pieChartDataEntry) } let dataSet = PieChartDataSet(entries: dataEntries, label: "") - dataSet.entryLabelFont = Fonts.pieChartEntries - dataSet.valueFont = Fonts.pieChartEntries + dataSet.entryLabelFont = Fonts.chartEntries + dataSet.valueFont = Fonts.chartEntries dataSet.colors = [UIColor.paGreen, UIColor.paColor2, UIColor.paColor3, UIColor.paBlue] dataSet.valueFormatter = PercentageFormatter() return PieChartData(dataSet: dataSet) } - var chartData: ChartData { - var dataEntries: [ChartDataEntry] = [] - self.forEach { representable in - dataEntries.append(representable.chartDataEntry) + var barChartData: BarChartData { + var dataEntries: [BarChartDataEntry] = [] + + for (index, representable) in self.enumerated() { + dataEntries.append(representable.barChartDataEntry(index: Double(index))) } - let dataSet = ChartDataSet(entries: dataEntries) - return ChartData(dataSet: dataSet) + + let dataSet = BarChartDataSet(entries: dataEntries, label: "") + dataSet.valueColors = [UIColor.white] + dataSet.valueFont = Fonts.chartEntries + dataSet.colors = [UIColor.paGreen, UIColor.paColor2, UIColor.paColor3, UIColor.paBlue] + dataSet.valueFormatter = IntFormatter() + + return BarChartData(dataSet: dataSet) + } + + var labels: [String] { + return self.map { $0.name } } } -//extension Array where Element : Aggregeable { -// -// func aggregate(param: String) -> [Element] { -// return [] -// } -// -//} - protocol Aggregeable { static func aggregate(table: [Self], param: String) -> [Self] } diff --git a/TournamentStats/utils/Game.swift b/TournamentStats/utils/Game.swift index a11c2e5..8731041 100644 --- a/TournamentStats/utils/Game.swift +++ b/TournamentStats/utils/Game.swift @@ -11,4 +11,12 @@ import Foundation enum Game : String { case holdem = "No-Limit Hold'em" case omaha = "Pot-Limit Omaha" + + var label: String { + switch self { + case .holdem: return "NL Hold'em" + case .omaha: return "PL Omaha" + } + } + }