multistore
Raz 1 year ago
parent c9c2b72b0f
commit 0b2542bc29
  1. 8
      PadelClub/Data/Tournament.swift
  2. 4
      PadelClub/Utils/FileImportManager.swift
  3. 88
      PadelClub/Utils/PadelRule.swift
  4. 4
      PadelClub/Views/GroupStage/GroupStageView.swift
  5. 8
      PadelClub/Views/Team/Components/TeamHeaderView.swift
  6. 5
      PadelClub/Views/Team/Components/TeamWeightView.swift
  7. 2
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift
  8. 12
      PadelClub/Views/Tournament/Screen/TournamentRankView.swift
  9. 8
      PadelClub/Views/Tournament/Shared/TournamentCellView.swift

@ -848,6 +848,8 @@ class Tournament : ModelObject, Storable {
func unrankValue(for malePlayer: Bool) -> Int? {
switch tournamentCategory {
case .unlisted:
return nil
case .men:
return maleUnrankedValue
case .women:
@ -1171,7 +1173,11 @@ class Tournament : ModelObject, Storable {
}
func tournamentTitle(_ displayStyle: DisplayStyle = .wide) -> String {
[tournamentLevel.localizedLabel(.wide) + " " + tournamentCategory.localizedLabel(.wide), displayStyle == .wide ? name : nil].compactMap({ $0 }).joined(separator: " - ")
[tournamentLevel.localizedLabel(displayStyle) + " " + tournamentCategory.localizedLabel(displayStyle), displayStyle == .wide ? name : nil].compactMap({ $0 }).joined(separator: " - ")
}
func hideWeight() -> Bool {
tournamentLevel.hideWeight()
}
func subtitle(_ displayStyle: DisplayStyle = .wide) -> String {

@ -253,6 +253,7 @@ class FileImportManager {
var sexPlayerOne : Int {
switch tournamentCategory {
case .unlisted: return 1
case .men: return 1
case .women: return 0
case .mix: return 0
@ -261,6 +262,7 @@ class FileImportManager {
var sexPlayerTwo : Int {
switch tournamentCategory {
case .unlisted: return 1
case .men: return 1
case .women: return 0
case .mix: return 1
@ -299,6 +301,7 @@ class FileImportManager {
var sexPlayerOne : Int {
switch tournamentCategory {
case .unlisted: return 1
case .men: return 1
case .women: return 0
case .mix: return 1
@ -307,6 +310,7 @@ class FileImportManager {
var sexPlayerTwo : Int {
switch tournamentCategory {
case .unlisted: return 1
case .men: return 1
case .women: return 0
case .mix: return 0

@ -156,6 +156,7 @@ enum TournamentDifficulty {
}
enum FederalTournamentAge: Int, Hashable, Codable, CaseIterable, Identifiable {
case unlisted = 0
case a11_12 = 120
case a13_14 = 140
case a15_16 = 160
@ -187,6 +188,8 @@ enum FederalTournamentAge: Int, Hashable, Codable, CaseIterable, Identifiable {
var order: Int {
switch self {
case .unlisted:
return 7
case .a11_12:
return 6
case .a13_14:
@ -206,6 +209,8 @@ enum FederalTournamentAge: Int, Hashable, Codable, CaseIterable, Identifiable {
func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String {
switch self {
case .unlisted:
return displayStyle == .wide ? "Aucune" : ""
case .a11_12:
return "11/12 ans"
case .a13_14:
@ -236,6 +241,7 @@ enum FederalTournamentAge: Int, Hashable, Codable, CaseIterable, Identifiable {
}
enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
case unlisted = 0
case p25 = 25
case p100 = 100
case p250 = 250
@ -249,6 +255,15 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
self.init(rawValue: value)
}
func hideWeight() -> Bool {
switch self {
case .unlisted:
return true
default:
return false
}
}
static func mostRecent(inTournaments tournaments: [Tournament]) -> Self {
return tournaments.first?.tournamentLevel ?? .p100
}
@ -265,15 +280,6 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
var id: Int { self.rawValue }
func maximumDuration() -> Double {
switch self {
case .p25:
return 0.5
default:
return 3
}
}
func minimumPlayerRank(category: TournamentCategory, ageCategory: FederalTournamentAge) -> Int {
switch self {
case .p25:
@ -376,6 +382,8 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
var order: Int {
switch self {
case .unlisted:
return 7
case .p25:
return 6
case .p100:
@ -394,6 +402,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
}
func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String {
if self == .unlisted { return displayStyle == .wide ? "Animation" : "" }
return String(describing: self).capitalized
}
@ -407,6 +416,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
}
func points(for rank: Int, count: Int) -> Int {
if self == .unlisted { return 0 }
let points = points(for: count)
if rank >= points.count {
return points.last!
@ -423,6 +433,8 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
func points(for count: Int) -> [Int] {
switch self {
case .unlisted:
return []
case .p25:
switch count {
case 9...12:
@ -559,7 +571,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
//
func minimumFormatFinalTableAndQualifier(roundIndex: Int) -> MatchFormat? {
switch self {
case .p25:
case .p25, .unlisted:
return nil
case .p100:
return .nineGamesDecisivePoint
@ -588,7 +600,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
func minimumFormatLoserBracket(roundIndex: Int) -> MatchFormat? {
switch self {
case .p25:
case .p25, .unlisted:
return nil
case .p100, .p250, .p500:
return .nineGamesDecisivePoint
@ -632,6 +644,7 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable {
case men
case women
case mix
case unlisted
init?(rawValue: Int?) {
guard let value = rawValue else { return nil }
@ -640,6 +653,8 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable {
func mandatoryPlayerType() -> [Int] {
switch self {
case .unlisted:
return []
case .mix:
return [0, 1]
case .women:
@ -694,43 +709,25 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable {
}
}
var next: TournamentCategory {
switch self {
case .men:
return .women
case .women:
return .mix
case .mix:
return .men
}
}
var id: Int { self.rawValue }
var sexValue: Int {
switch self {
case .men:
return 1
case .women:
return 0
case .mix:
return -1
}
}
var order: Int {
switch self {
case .men:
case .unlisted:
return 0
case .women:
case .men:
return 1
case .mix:
case .women:
return 2
case .mix:
return 3
}
}
var buildLabel: String {
switch self {
case .unlisted:
return "-"
case .men:
return "H"
case .women:
@ -742,6 +739,8 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable {
var requestLabel: String {
switch self {
case .unlisted:
return "-"
case .men:
return "DM"
case .women:
@ -753,6 +752,8 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable {
var importingRawValue: String {
switch self {
case .unlisted:
return "-"
case .men:
return "messieurs"
case .women:
@ -764,6 +765,8 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable {
func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String {
switch self {
case .unlisted:
return displayStyle == .wide ? "Aucune" : ""
case .men:
return displayStyle == .wide ? "Hommes" : "H"
case .women:
@ -773,20 +776,9 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable {
}
}
var rankingDataSourceMale: Bool {
switch self {
case .men:
return true
case .women:
return false
case .mix:
return false
}
}
var playerFilterOption: PlayerFilterOption {
switch self {
case .men:
case .men, .unlisted:
return .all
case .women:
return .female

@ -118,7 +118,9 @@ struct GroupStageView: View {
VStack(alignment: .leading, spacing: 4.0) {
HStack(spacing: 6.0) {
Text("#\(groupStagePosition + 1)")
Text("Poids \(team.weight)")
if groupStage.tournamentObject()?.hideWeight() == false {
Text("Poids \(team.weight)")
}
Spacer()
if team.qualified {
Text("qualifié")

@ -22,9 +22,11 @@ struct TeamHeaderView: View {
}
if team.unsortedPlayers().isEmpty == false {
VStack(alignment: .leading, spacing: 0) {
Text("Poids").font(.caption)
Text(team.weight.formatted())
if tournament?.hideWeight() == false {
VStack(alignment: .leading, spacing: 0) {
Text("Poids").font(.caption)
Text(team.weight.formatted())
}
}
if let name = team.name {
VStack(alignment: .leading, spacing: 0) {

@ -8,6 +8,7 @@
import SwiftUI
struct TeamWeightView: View {
@Environment(Tournament.self) var tournament: Tournament
var team: TeamRegistration
var teamPosition: TeamPosition? = nil
var teamIndex: Int?
@ -20,7 +21,7 @@ struct TeamWeightView: View {
var body: some View {
VStack(alignment: .trailing, spacing: 0) {
if teamPosition == .one || teamPosition == nil {
if (teamPosition == .one || teamPosition == nil) && tournament.hideWeight() == false {
Text(team.weight.formatted())
.monospacedDigit()
.font(.caption)
@ -29,7 +30,7 @@ struct TeamWeightView: View {
Text("#" + (teamIndex + 1).formatted(.number.precision(.integerLength(2...3))))
.monospacedDigit()
}
if teamPosition == .two {
if teamPosition == .two && tournament.hideWeight() == false {
Text(team.weight.formatted())
.monospacedDigit()
.font(.caption)

@ -631,7 +631,7 @@ struct InscriptionManagerView: View {
private func _addPlayerSex() -> Int {
switch tournament.tournamentCategory {
case .men:
case .men, .unlisted:
return 1
case .women:
return 0

@ -119,11 +119,13 @@ struct TournamentRankView: View {
}
}
Spacer()
VStack(alignment: .trailing) {
HStack(alignment: .lastTextBaseline, spacing: 0.0) {
Text(tournament.tournamentLevel.points(for: key - 1, count: tournament.teamCount).formatted(.number.sign(strategy: .always())))
Text("pts").font(.caption)
if tournament.hideWeight() == false {
Spacer()
VStack(alignment: .trailing) {
HStack(alignment: .lastTextBaseline, spacing: 0.0) {
Text(tournament.tournamentLevel.points(for: key - 1, count: tournament.teamCount).formatted(.number.sign(strategy: .always())))
Text("pts").font(.caption)
}
}
}
}

@ -79,8 +79,8 @@ struct TournamentCellView: View {
.fontWeight(.semibold)
if displayStyle == .wide {
VStack(alignment: .leading, spacing: 0) {
Text(build.category.localizedLabel())
Text(build.age.localizedLabel())
Text(build.category.localizedLabel(.short))
Text(build.age.localizedLabel(.short))
}
.font(.caption)
}
@ -117,8 +117,8 @@ struct TournamentCellView: View {
}
Text(tournament.subtitleLabel()).lineLimit(1)
} else {
Text(build.category.localizedLabel())
Text(build.age.localizedLabel())
Text(build.category.localizedLabel(.short))
Text(build.age.localizedLabel(.short))
}
}
}

Loading…
Cancel
Save