Laurent 1 year ago
commit 1fb67af4ae
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 2
      PadelClub/Data/Round.swift
  3. 4
      PadelClub/Data/Tournament.swift
  4. 7
      PadelClub/Views/Cashier/Event/TournamentConfiguratorView.swift
  5. 16
      PadelClub/Views/Components/FortuneWheelView.swift
  6. 8
      PadelClub/Views/Planning/PlanningSettingsView.swift
  7. 14
      PadelClub/Views/Round/LoserRoundView.swift
  8. 2
      PadelClub/Views/Round/LoserRoundsView.swift
  9. 9
      PadelClub/Views/Round/RoundSettingsView.swift
  10. 85
      PadelClub/Views/Round/RoundView.swift

@ -1906,7 +1906,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 89;
CURRENT_PROJECT_VERSION = 90;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
@ -1950,7 +1950,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 89;
CURRENT_PROJECT_VERSION = 90;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -480,7 +480,7 @@ defer {
if (previousRound.enabledMatches().isEmpty == false || initialMode) {
return previousRound.seedInterval(initialMode: initialMode)?.chunks()?.first
} else {
return previousRound.previousRound()?.seedInterval(initialMode: initialMode)
return previousRound.seedInterval(initialMode: initialMode)
}
} else if let parentRound {
if parentRound.parent == nil {

@ -1827,8 +1827,8 @@ defer {
func setupFederalSettings() {
teamSorting = tournamentLevel.defaultTeamSortingType
groupStageMatchFormat = groupStageSmartMatchFormat()
loserBracketMatchFormat = loserBracketSmartMatchFormat(1)
matchFormat = roundSmartMatchFormat(1)
loserBracketMatchFormat = loserBracketSmartMatchFormat(5)
matchFormat = roundSmartMatchFormat(5)
}
func roundSmartMatchFormat(_ roundIndex: Int) -> MatchFormat {

@ -29,6 +29,13 @@ struct TournamentConfigurationView: View {
if tournament.federalLevelCategory == .unlisted {
tournament.federalCategory = .unlisted
tournament.federalAgeCategory = .unlisted
} else {
if tournament.federalCategory == .unlisted {
tournament.federalCategory = .men
}
if tournament.federalAgeCategory == .unlisted {
tournament.federalAgeCategory = .senior
}
}
}
Picker(selection: $tournament.federalCategory, label: Text("Catégorie")) {

@ -62,7 +62,7 @@ struct SpinDrawView: View {
let drawees: [any SpinDrawable]
@State var segments: [any SpinDrawable]
var autoMode: Bool = false
let completion: ([DrawResult]) -> Void // Completion closure
let completion: ([DrawResult]) async -> Void // Completion closure
@State private var drawCount: Int = 0
@State private var draws: [DrawResult] = [DrawResult]()
@ -82,7 +82,7 @@ struct SpinDrawView: View {
_validationLabelView(drawee: drawCount, result: segments[draws.last!.drawIndex])
if autoMode == false || drawCount == drawees.count {
RowButtonView("Valider le tirage") {
completion(draws)
await completion(draws)
dismiss()
}
}
@ -173,10 +173,16 @@ struct SpinDrawView: View {
ToolbarItem(placement: .topBarTrailing) {
Button {
validating = true
completion(draws)
dismiss()
Task {
await completion(draws)
dismiss()
}
} label: {
Text("Tout valider")
if validating {
ProgressView()
} else {
Text("Tout valider")
}
}
}

@ -220,8 +220,12 @@ struct PlanningSettingsView: View {
} label: {
Text("Poules en parallèle")
let value = tournament.getGroupStageChunkValue()
if parallelType == false, value > 1 {
Text("\(value.formatted()) poules commenceront en parallèle")
if parallelType == false {
if value > 1 {
Text("\(value.formatted()) poules commenceront en parallèle")
} else {
Text("une poule sera jouer à la fois")
}
}
}
.onChange(of: parallelType) {

@ -65,6 +65,20 @@ struct LoserRoundView: View {
Spacer()
Text(seedIntervalPointRange)
.font(.caption)
} else {
if let previousRound = loserRound.previousRound() {
if let seedInterval = previousRound.seedInterval() {
Text(seedInterval.localizedLabel())
} else {
Text("no previous round")
}
} else if let parentRound = loserRound.parentRound {
if let seedInterval = parentRound.seedInterval() {
Text(seedInterval.localizedLabel())
} else {
Text("no parent round")
}
}
}
}
}

@ -15,13 +15,11 @@ class UpperRound: Identifiable, Selectable {
}()
let title: String
let playedMatches: [Match]
let correspondingLoserRoundTitle: String
init(round: Round) {
self.round = round
self.title = round.roundTitle(.short)
self.playedMatches = round.playedMatches()
self.correspondingLoserRoundTitle = round.correspondingLoserRoundTitle()
}
func loserMatches() -> [Match] {

@ -99,14 +99,15 @@ struct RoundSettingsView: View {
let nextRound = round.nextRound()
var currentIndex = 0
let matches = (0..<matchCount).map { index in //0 is final match
let match = Match(round: round.id, index: index + matchStartIndex, matchFormat: round.matchFormat)
if let nextRound, let followingMatch = self.tournament.tournamentStore.matches.first(where: { $0.round == nextRound.id && $0.index == (index - 1) / 2 }) {
let computedIndex = index + matchStartIndex
let match = Match(round: round.id, index: computedIndex, matchFormat: round.matchFormat)
if let nextRound, let followingMatch = self.tournament.tournamentStore.matches.first(where: { $0.round == nextRound.id && $0.index == (computedIndex - 1) / 2 }) {
if followingMatch.disabled {
match.disabled = true
} else if index%2 == 1 && followingMatch.team(.one) != nil {
} else if computedIndex%2 == 1 && followingMatch.team(.one) != nil {
//index du match courant impair = position haut du prochain match
match.disabled = true
} else if index%2 == 0 && followingMatch.team(.two) != nil {
} else if computedIndex%2 == 0 && followingMatch.team(.two) != nil {
//index du match courant pair = position basse du prochain match
match.disabled = true
} else {

@ -87,11 +87,12 @@ struct RoundView: View {
.tipStyle(tint: .master, asSection: true)
if upperRound.loserRounds.isEmpty == false {
let correspondingLoserRoundTitle = upperRound.round.correspondingLoserRoundTitle()
Section {
NavigationLink {
LoserRoundsView(upperBracketRound: upperRound)
.environment(tournament)
.navigationTitle(upperRound.correspondingLoserRoundTitle)
.navigationTitle(correspondingLoserRoundTitle)
} label: {
LabeledContent {
let status = upperRound.status()
@ -101,7 +102,7 @@ struct RoundView: View {
Text("\(status.0) terminé\(status.0.pluralSuffix) sur \(status.1)")
}
} label: {
Text(upperRound.correspondingLoserRoundTitle)
Text(correspondingLoserRoundTitle)
}
}
}
@ -129,12 +130,14 @@ struct RoundView: View {
if availableSeeds.isEmpty == false, let availableSeedGroup {
Section {
RowButtonView("Placer \(availableSeedGroup.localizedLabel())" + ((availableSeedGroup.isFixed() == false) ? " au hasard" : "")) {
tournament.setSeeds(inRoundIndex: upperRound.round.index, inSeedGroup: availableSeedGroup)
_save()
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty {
self.isEditingTournamentSeed.wrappedValue = false
Task {
tournament.setSeeds(inRoundIndex: upperRound.round.index, inSeedGroup: availableSeedGroup)
_save()
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty {
self.isEditingTournamentSeed.wrappedValue = false
}
_prepareRound()
}
_prepareRound()
}
} footer: {
if availableSeedGroup.isFixed() == false {
@ -160,14 +163,16 @@ struct RoundView: View {
ForEach(availableQualifiedTeams) { team in
NavigationLink {
SpinDrawView(drawees: [team], segments: spaceLeft) { results in
results.forEach { drawResult in
team.setSeedPosition(inSpot: spaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: true)
Task {
results.forEach { drawResult in
team.setSeedPosition(inSpot: spaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: true)
}
_save()
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty {
self.isEditingTournamentSeed.wrappedValue = false
}
_prepareRound()
}
_save()
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty {
self.isEditingTournamentSeed.wrappedValue = false
}
_prepareRound()
}
} label: {
TeamRowView(team: team, displayCallDate: false)
@ -189,14 +194,16 @@ struct RoundView: View {
ForEach(availableSeeds) { team in
NavigationLink {
SpinDrawView(drawees: [team], segments: seedSpaceLeft) { results in
results.forEach { drawResult in
team.setSeedPosition(inSpot: seedSpaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: false)
}
_save()
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty {
self.isEditingTournamentSeed.wrappedValue = false
Task {
results.forEach { drawResult in
team.setSeedPosition(inSpot: seedSpaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: false)
}
_save()
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty {
self.isEditingTournamentSeed.wrappedValue = false
}
_prepareRound()
}
_prepareRound()
}
} label: {
TeamRowView(team: team, displayCallDate: false)
@ -214,14 +221,16 @@ struct RoundView: View {
ForEach(availableSeeds) { team in
NavigationLink {
SpinDrawView(drawees: [team], segments: spaceLeft) { results in
results.forEach { drawResult in
team.setSeedPosition(inSpot: spaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: true)
Task {
results.forEach { drawResult in
team.setSeedPosition(inSpot: spaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: true)
}
_save()
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty {
self.isEditingTournamentSeed.wrappedValue = false
}
_prepareRound()
}
_save()
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty {
self.isEditingTournamentSeed.wrappedValue = false
}
_prepareRound()
}
} label: {
TeamRowView(team: team, displayCallDate: false)
@ -286,15 +295,17 @@ struct RoundView: View {
let availableSeedSpot = opposingSeeding ? spaceLeft : seedSpaceLeft
NavigationStack {
SpinDrawView(drawees: seeds, segments: availableSeedSpot, autoMode: true) { draws in
draws.forEach { drawResult in
seeds[drawResult.drawee].setSeedPosition(inSpot: availableSeedSpot[drawResult.drawIndex], slot: nil, opposingSeeding: opposingSeeding)
}
_save()
_prepareRound()
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty {
self.isEditingTournamentSeed.wrappedValue = false
Task {
draws.forEach { drawResult in
seeds[drawResult.drawee].setSeedPosition(inSpot: availableSeedSpot[drawResult.drawIndex], slot: nil, opposingSeeding: opposingSeeding)
}
_save()
_prepareRound()
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty {
self.isEditingTournamentSeed.wrappedValue = false
}
}
}
}

Loading…
Cancel
Save