fix preset management when no group stage

paca_championship
Raz 1 year ago
parent 412df66c1e
commit 176df45214
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 12
      PadelClub/Utils/PadelRule.swift
  3. 8
      PadelClub/Views/Tournament/Screen/TableStructureView.swift

@ -3134,7 +3134,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
@ -3179,7 +3179,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -1884,9 +1884,21 @@ enum PadelTournamentStructurePreset: Int, Identifiable, CaseIterable {
1
}
}
func hasWildcards() -> Bool {
wildcardBrackets() > 0 || wildcardQualifiers() > 0
}
func isFederalPreset() -> Bool {
switch self {
case .manual:
return false
case .doubleGroupStage:
return false
case .federalStructure_8, .federalStructure_12, .federalStructure_16, .federalStructure_20, .federalStructure_24, .federalStructure_32, .federalStructure_48, .federalStructure_64:
return true
}
}
}
enum TournamentDeadlineType: String, CaseIterable {

@ -193,7 +193,7 @@ struct TableStructureView: View {
} label: {
Text("Nombre de têtes de série")
if tsPure > 0 && (tsPure > teamCount / 2 || tsPure < teamCount / 8 || tsPure < qualifiedFromGroupStage + groupStageAdditionalQualified) {
if groupStageCount > 0 && tsPure > 0 && (tsPure > teamCount / 2 || tsPure < teamCount / 8 || tsPure < qualifiedFromGroupStage + groupStageAdditionalQualified) {
Text("Attention !").foregroundStyle(.red)
}
}
@ -212,7 +212,7 @@ struct TableStructureView: View {
}
}
} footer: {
if tsPure > 0 && structurePreset != .doubleGroupStage {
if tsPure > 0 && structurePreset != .doubleGroupStage, groupStageCount > 0 {
if tsPure > teamCount / 2 {
Text("Le nombre de têtes de série ne devrait pas être supérieur à la moitié de l'effectif.").foregroundStyle(.red)
} else if tsPure < teamCount / 8 {
@ -288,6 +288,10 @@ struct TableStructureView: View {
} else {
updatedElements.remove(.groupStageCount)
}
if structurePreset.isFederalPreset(), groupStageCount == 0 {
teamCount = structurePreset.tableDimension()
}
}
.onChange(of: teamsPerGroupStage) {
if teamsPerGroupStage != tournament.teamsPerGroupStage {

Loading…
Cancel
Save