remove the need to have a target team count

online_reg
Raz 11 months ago
parent dc3d193b55
commit 494f083a34
  1. 14
      PadelClub/Data/Tournament.swift
  2. 9
      PadelClub/Utils/PadelRule.swift
  3. 9
      PadelClub/Views/Tournament/Screen/RegistrationSetupView.swift
  4. 3
      PadelClub/Views/Tournament/Screen/TableStructureView.swift

@ -63,7 +63,6 @@ final class Tournament : ModelObject, Storable {
var enableOnlineRegistration: Bool = false
var registrationDateLimit: Date? = nil
var openingRegistrationDate: Date? = nil
var targetTeamCount: Int? = nil
var waitingListLimit: Int? = nil
var accountIsRequired: Bool = true
var licenseIsRequired: Bool = true
@ -124,7 +123,6 @@ final class Tournament : ModelObject, Storable {
case _enableOnlineRegistration = "enableOnlineRegistration"
case _registrationDateLimit = "registrationDateLimit"
case _openingRegistrationDate = "openingRegistrationDate"
case _targetTeamCount = "targetTeamCount"
case _waitingListLimit = "waitingListLimit"
case _accountIsRequired = "accountIsRequired"
case _licenseIsRequired = "licenseIsRequired"
@ -134,7 +132,7 @@ final class Tournament : ModelObject, Storable {
}
internal init(event: String? = nil, name: String? = nil, startDate: Date = Date(), endDate: Date? = nil, creationDate: Date = Date(), isPrivate: Bool = false, groupStageFormat: MatchFormat? = nil, roundFormat: MatchFormat? = nil, loserRoundFormat: MatchFormat? = nil, groupStageSortMode: GroupStageOrderingMode, groupStageCount: Int = 4, rankSourceDate: Date? = nil, dayDuration: Int = 1, teamCount: Int = 24, teamSorting: TeamSortingType? = nil, federalCategory: TournamentCategory, federalLevelCategory: TournamentLevel, federalAgeCategory: FederalTournamentAge, closedRegistrationDate: Date? = nil, groupStageAdditionalQualified: Int = 0, courtCount: Int = 2, prioritizeClubMembers: Bool = false, qualifiedPerGroupStage: Int = 1, teamsPerGroupStage: Int = 4, entryFee: Double? = nil, additionalEstimationDuration: Int = 0, isDeleted: Bool = false, publishTeams: Bool = false, publishSummons: Bool = false, publishGroupStages: Bool = false, publishBrackets: Bool = false, shouldVerifyBracket: Bool = false, shouldVerifyGroupStage: Bool = false, hideTeamsWeight: Bool = false, publishTournament: Bool = false, hidePointsEarned: Bool = false, publishRankings: Bool = false, loserBracketMode: LoserBracketMode = .automatic, initialSeedRound: Int = 0, initialSeedCount: Int = 0, enableOnlineRegistration: Bool = false, registrationDateLimit: Date? = nil, openingRegistrationDate: Date? = nil, targetTeamCount: Int? = nil, waitingListLimit: Int? = nil, accountIsRequired: Bool = true, licenseIsRequired: Bool = true, minimumPlayerPerTeam: Int = 2, maximumPlayerPerTeam: Int = 2, information: String? = nil) {
internal init(event: String? = nil, name: String? = nil, startDate: Date = Date(), endDate: Date? = nil, creationDate: Date = Date(), isPrivate: Bool = false, groupStageFormat: MatchFormat? = nil, roundFormat: MatchFormat? = nil, loserRoundFormat: MatchFormat? = nil, groupStageSortMode: GroupStageOrderingMode, groupStageCount: Int = 4, rankSourceDate: Date? = nil, dayDuration: Int = 1, teamCount: Int = 24, teamSorting: TeamSortingType? = nil, federalCategory: TournamentCategory, federalLevelCategory: TournamentLevel, federalAgeCategory: FederalTournamentAge, closedRegistrationDate: Date? = nil, groupStageAdditionalQualified: Int = 0, courtCount: Int = 2, prioritizeClubMembers: Bool = false, qualifiedPerGroupStage: Int = 1, teamsPerGroupStage: Int = 4, entryFee: Double? = nil, additionalEstimationDuration: Int = 0, isDeleted: Bool = false, publishTeams: Bool = false, publishSummons: Bool = false, publishGroupStages: Bool = false, publishBrackets: Bool = false, shouldVerifyBracket: Bool = false, shouldVerifyGroupStage: Bool = false, hideTeamsWeight: Bool = false, publishTournament: Bool = false, hidePointsEarned: Bool = false, publishRankings: Bool = false, loserBracketMode: LoserBracketMode = .automatic, initialSeedRound: Int = 0, initialSeedCount: Int = 0, enableOnlineRegistration: Bool = false, registrationDateLimit: Date? = nil, openingRegistrationDate: Date? = nil, waitingListLimit: Int? = nil, accountIsRequired: Bool = true, licenseIsRequired: Bool = true, minimumPlayerPerTeam: Int = 2, maximumPlayerPerTeam: Int = 2, information: String? = nil) {
self.event = event
self.name = name
self.startDate = startDate
@ -191,7 +189,6 @@ final class Tournament : ModelObject, Storable {
self.enableOnlineRegistration = enableOnlineRegistration
self.registrationDateLimit = registrationDateLimit
self.openingRegistrationDate = openingRegistrationDate
self.targetTeamCount = targetTeamCount
self.waitingListLimit = waitingListLimit
self.accountIsRequired = accountIsRequired
@ -249,7 +246,6 @@ final class Tournament : ModelObject, Storable {
enableOnlineRegistration = try container.decodeIfPresent(Bool.self, forKey: ._enableOnlineRegistration) ?? false
registrationDateLimit = try container.decodeIfPresent(Date.self, forKey: ._registrationDateLimit)
openingRegistrationDate = try container.decodeIfPresent(Date.self, forKey: ._openingRegistrationDate)
targetTeamCount = try container.decodeIfPresent(Int.self, forKey: ._targetTeamCount)
waitingListLimit = try container.decodeIfPresent(Int.self, forKey: ._waitingListLimit)
accountIsRequired = try container.decodeIfPresent(Bool.self, forKey: ._accountIsRequired) ?? true
licenseIsRequired = try container.decodeIfPresent(Bool.self, forKey: ._licenseIsRequired) ?? true
@ -348,7 +344,6 @@ final class Tournament : ModelObject, Storable {
try container.encode(enableOnlineRegistration, forKey: ._enableOnlineRegistration)
try container.encode(registrationDateLimit, forKey: ._registrationDateLimit)
try container.encode(openingRegistrationDate, forKey: ._openingRegistrationDate)
try container.encode(targetTeamCount, forKey: ._targetTeamCount)
try container.encode(waitingListLimit, forKey: ._waitingListLimit)
try container.encode(accountIsRequired, forKey: ._accountIsRequired)
@ -2490,20 +2485,17 @@ defer {
}
}
if let targetTeamCount = targetTeamCount {
// Get all team registrations excluding walk_outs
let currentTeamCount = unsortedTeamsWithoutWO().count
if currentTeamCount >= targetTeamCount {
if currentTeamCount >= teamCount {
if let waitingListLimit = waitingListLimit {
let waitingListCount = currentTeamCount - targetTeamCount
let waitingListCount = currentTeamCount - teamCount
if waitingListCount >= waitingListLimit {
return .waitingListFull
}
}
return .waitingListPossible
}
}
return .open
}

@ -369,6 +369,15 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
var id: Int { self.rawValue }
func wildcardArePossible() -> Bool {
switch self {
case .p500, .p1000, .p1500, .p2000:
return true
default:
return false
}
}
func minimumPlayerRank(category: TournamentCategory, ageCategory: FederalTournamentAge) -> Int {
switch self {
case .p25:

@ -52,13 +52,8 @@ struct RegistrationSetupView: View {
}
// Target Team Count
if let targetTeamCount = tournament.targetTeamCount {
_targetTeamCount = .init(wrappedValue: targetTeamCount)
_targetTeamCountEnabled = .init(wrappedValue: true)
} else {
_targetTeamCount = .init(wrappedValue: tournament.teamCount) // Default value
_targetTeamCountEnabled = .init(wrappedValue: false)
}
// Waiting List Limit
if let waitingListLimit = tournament.waitingListLimit {
@ -289,9 +284,9 @@ struct RegistrationSetupView: View {
}
if targetTeamCountEnabled == false {
tournament.targetTeamCount = nil
tournament.teamCount = 24
} else {
tournament.targetTeamCount = targetTeamCount
tournament.teamCount = targetTeamCount
}
if waitingListLimitEnabled == false {

@ -77,6 +77,7 @@ struct TableStructureView: View {
teamsPerGroupStage = structurePreset.teamsPerGroupStage()
qualifiedPerGroupStage = structurePreset.qualifiedPerGroupStage()
groupStageAdditionalQualified = 0
buildWildcards = tournament.level.wildcardArePossible()
}
}
@ -223,7 +224,7 @@ struct TableStructureView: View {
}
}
if structurePreset.hasWildcards() {
if structurePreset.hasWildcards() && tournament.level.wildcardArePossible() {
Section {
Toggle("Avec wildcards", isOn: $buildWildcards)
} footer: {

Loading…
Cancel
Save