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.
pa-tournament-stats/TournamentStats/report/structures/TournamentRepresentable.swift

57 lines
1.9 KiB

//
// TournamentEntries.swift
// TournamentStats
//
// Created by Laurent Morvillier on 05/06/2019.
// Copyright © 2019 Stax River. All rights reserved.
//
import Foundation
struct TournamentRepresentable : HTMLRepresentable {
var tournament: Tournament
func columnDescriptors() -> [ColumnDescriptor] {
return [ColumnDescriptor(header: "#", number: true, widthWeight: 0.3),
ColumnDescriptor(header: "Buy-in", number: true, widthWeight: 0.5),
ColumnDescriptor(header: "Event", number: false, widthWeight: 2.6),
ColumnDescriptor(header: "Prizepool", number: true, widthWeight: 1.0),
ColumnDescriptor(header: "Entries", number: true, widthWeight: 0.6)]
}
func cellValues() -> [String] {
return [
"\(tournament.number)",
tournament.buyin.currencyFormatted,
tournament.name,
tournament.prizepool.currencyFormatted,
"\(tournament.entries)"
]
}
func htmlHeaders() -> String {
var strings: [String] = []
// strings.append("Date")
strings.append("#")
strings.append("Buy-in")
strings.append("Event")
strings.append("Prizepool")
strings.append("Entries")
let all = strings.joined(separator: "</td><td>")
return "<tr class=\"table-header\"><td width=\"50\">\(all)</td></tr>"
}
// func html() -> String {
// var strings: [String] = []
//// strings.append(tournament.date.year)
// strings.append("\(tournament.number)")
// strings.append(tournament.buyin.currencyFormatted)
// strings.append(tournament.name)
// strings.append(tournament.prizepool.currencyFormatted)
// strings.append("\(tournament.entries)")
// let all = strings.joined(separator: "</td><td>")
// return "<tr><td>\(all)</td></tr>"
// }
}