An amazing project that generates micro reports from tournament results
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

//
// TournamentStats.swift
// TournamentStats
//
// Created by Laurent Morvillier on 10/06/2019.
// Copyright © 2019 Stax River. All rights reserved.
//
import Foundation
struct TournamentStats : HTMLRepresentable {
var entries: Double
var buyin: Double
var prizepool: Double
var itmValue: Double
static func htmlHeaders() -> String {
return ""
}
func html() -> String {
let formatter = NumberFormatter()
var strings: [(String, String)] = []
strings.append(("Entries", formatter.string(from: NSNumber(value: self.entries))!))
strings.append(("Buy-in", Formatter.currency.string(from: NSNumber(value: self.buyin))!))
strings.append(("Prizepool", Formatter.currency.string(from: NSNumber(value: self.prizepool))!))
strings.append(("Earnings", Formatter.currency.string(from: NSNumber(value: self.itmValue))!))
var all = ""
strings.forEach { (tuple) in
let table = [tuple.0, tuple.1]
let joined = table.joined(separator: "</td><td>")
all.append("<tr><td>")
all.append(joined)
all.append("</td></tr>\n")
}
return all
}
}