|
|
|
|
@ -379,7 +379,7 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
resetBracketPosition() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func pasteData(_ exportFormat: ExportFormat = .rawText, _ index: Int = 0) -> String { |
|
|
|
|
func pasteData(_ exportFormat: ExportFormat = .rawText, _ index: Int = 0, allPlayers: [(String, String)] = []) -> String { |
|
|
|
|
switch exportFormat { |
|
|
|
|
case .rawText: |
|
|
|
|
return [playersPasteData(exportFormat), formattedInscriptionDate(exportFormat), name].compactMap({ $0 }).joined(separator: exportFormat.newLineSeparator()) |
|
|
|
|
@ -388,8 +388,8 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
case .championship: |
|
|
|
|
var baseValue: [String] = [ |
|
|
|
|
formattedInscriptionDate(exportFormat) ?? "", |
|
|
|
|
alertCountFormatted(teamIndex: index), |
|
|
|
|
alertDescription(teamIndex: index), |
|
|
|
|
alertCountFormatted(teamIndex: index, allPlayers: allPlayers), |
|
|
|
|
alertDescription(teamIndex: index, allPlayers: allPlayers), |
|
|
|
|
teamWeightFormatted(), |
|
|
|
|
jokerWeightFormatted(), |
|
|
|
|
playerCountFormatted(), |
|
|
|
|
@ -435,13 +435,13 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
players().filter({ $0.isUnranked() && $0.source == nil }).count.formatted() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func alertDescription(teamIndex: Int) -> String { |
|
|
|
|
let multiLineString = championshipAlerts(teamIndex: teamIndex, tournament: tournamentObject()!).compactMap({ $0.errorDescription }).joined(separator: "\n") |
|
|
|
|
func alertDescription(teamIndex: Int, allPlayers: [(String, String)]) -> String { |
|
|
|
|
let multiLineString = championshipAlerts(teamIndex: teamIndex, tournament: tournamentObject()!, allPlayers: allPlayers).compactMap({ $0.errorDescription }).joined(separator: "\n") |
|
|
|
|
let escapedString = "\"\(multiLineString.replacingOccurrences(of: "\"", with: "\"\""))\"" |
|
|
|
|
return escapedString |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func championshipAlerts(teamIndex: Int, tournament: Tournament) -> [ChampionshipAlert] { |
|
|
|
|
func championshipAlerts(teamIndex: Int, tournament: Tournament, allPlayers: [(String, String)]) -> [ChampionshipAlert] { |
|
|
|
|
var alerts = [ChampionshipAlert]() |
|
|
|
|
if clubCode?.isValidCodeClub(62) == false { |
|
|
|
|
alerts.append(.clubCodeInvalid(self)) |
|
|
|
|
@ -449,18 +449,18 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
|
|
|
|
|
let players = players() |
|
|
|
|
|
|
|
|
|
// if teamIndex <= 16, players.filter({ $0.isNveq }).count > 2 { |
|
|
|
|
// alerts.append(.tooManyNVEQ(self)) |
|
|
|
|
// |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// if teamIndex <= 16, players.count > 8 { |
|
|
|
|
// alerts.append(.tooManyPlayers(self)) |
|
|
|
|
// |
|
|
|
|
// } |
|
|
|
|
if teamIndex <= 16, players.filter({ $0.isNveq }).count > 2 { |
|
|
|
|
alerts.append(.tooManyNVEQ(self)) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if teamIndex <= 16, players.count > 8 { |
|
|
|
|
alerts.append(.tooManyPlayers(self)) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
players.forEach { pr in |
|
|
|
|
alerts.append(contentsOf: pr.championshipAlerts(tournament: tournament)) |
|
|
|
|
alerts.append(contentsOf: pr.championshipAlerts(tournament: tournament, allPlayers: allPlayers)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return alerts |
|
|
|
|
@ -474,8 +474,8 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func alertCountFormatted(teamIndex: Int) -> String { |
|
|
|
|
let championshipAlertsCount = championshipAlerts(teamIndex: teamIndex, tournament: tournamentObject()!).count |
|
|
|
|
func alertCountFormatted(teamIndex: Int, allPlayers: [(String, String)]) -> String { |
|
|
|
|
let championshipAlertsCount = championshipAlerts(teamIndex: teamIndex, tournament: tournamentObject()!, allPlayers: allPlayers).count |
|
|
|
|
return championshipAlertsCount.formatted() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|