@ -462,6 +462,15 @@ struct PlanningSettingsView: View {
} header : {
Text ( " Classement " )
}
Section {
Toggle ( isOn : $ matchScheduler . accountGroupStageBreakTime ) {
Text ( " Tenir compte des temps de pause réglementaires " )
}
} header : {
Text ( " Poule " )
}
Section {
Toggle ( isOn : $ matchScheduler . rotationDifferenceIsImportant ) {
@ -469,18 +478,27 @@ struct PlanningSettingsView: View {
}
LabeledContent {
StepperView ( count : $ matchScheduler . upperBracketRotationDifference , minimum : 0 , maximum : 2 )
StepperView ( count : $ matchScheduler . upperBracketRotationDifference , minimum : 0 )
} label : {
Text ( " Tableau " )
}
. disabled ( matchScheduler . rotationDifferenceIsImportant = = false )
LabeledContent {
StepperView ( count : $ matchScheduler . loserBracketRotationDifference , minimum : 0 , maximum : 2 )
StepperView ( count : $ matchScheduler . loserBracketRotationDifference , minimum : 0 )
} label : {
Text ( " Classement " )
}
. disabled ( matchScheduler . rotationDifferenceIsImportant = = false )
LabeledContent {
StepperView ( count : $ matchScheduler . groupStageRotationDifference , minimum : 0 )
} label : {
Text ( " Poule " )
}
. disabled ( matchScheduler . rotationDifferenceIsImportant = = false )
} footer : {
Text ( " Cette option ajoute du temps entre 2 rotations, permettant ainsi de mieux configurer plusieurs tournois se déroulant en même temps. " )
}
@ -517,83 +535,11 @@ struct PlanningSettingsView: View {
}
private func _groupMatchesByDay ( matches : [ Match ] ) -> [ Date : [ Match ] ] {
var matchesByDay = [ Date : [ Match ] ] ( )
let calendar = Calendar . current
for match in matches {
// E x t r a c t d a y / m o n t h / y e a r a n d c r e a t e a d a t e w i t h o n l y t h e s e c o m p o n e n t s
let components = calendar . dateComponents ( [ . year , . month , . day ] , from : match . computedStartDateForSorting )
let strippedDate = calendar . date ( from : components ) !
// G r o u p m a t c h e s b y t h e s t r i p p e d D a t e ( o n l y d a y / m o n t h / y e a r )
if matchesByDay [ strippedDate ] = = nil {
matchesByDay [ strippedDate ] = [ ]
}
let shouldIncludeMatch : Bool
switch match . matchType {
case . groupStage :
shouldIncludeMatch = ! matchesByDay [ strippedDate ] ! . filter { $0 . groupStage != nil } . compactMap { $0 . groupStage } . contains ( match . groupStage ! )
case . bracket :
shouldIncludeMatch = ! matchesByDay [ strippedDate ] ! . filter { $0 . round != nil } . compactMap { $0 . round } . contains ( match . round ! )
case . loserBracket :
shouldIncludeMatch = true
}
if shouldIncludeMatch {
matchesByDay [ strippedDate ] ! . append ( match )
}
}
return matchesByDay
tournament . groupMatchesByDay ( matches : matches )
}
private func _matchCountPerDay ( matchesByDay : [ Date : [ Match ] ] , tournament : Tournament ) -> [ Date : NSCountedSet ] {
let days = matchesByDay . keys
var matchCountPerDay = [ Date : NSCountedSet ] ( )
for day in days {
if let matches = matchesByDay [ day ] {
var groupStageCount = 0
let countedSet = NSCountedSet ( )
for match in matches {
switch match . matchType {
case . groupStage :
if let groupStage = match . groupStageObject {
if groupStageCount < groupStage . size - 1 {
groupStageCount = groupStage . size - 1
}
}
case . bracket :
countedSet . add ( match . matchFormat )
case . loserBracket :
break
}
}
if groupStageCount > 0 {
for _ in 0. . < groupStageCount {
countedSet . add ( tournament . groupStageMatchFormat )
}
}
if let loserRounds = matches . filter ( { $0 . round != nil } ) . filter ( { $0 . roundObject ? . parent = = nil } ) . sorted ( by : \ . computedStartDateForSorting ) . last ? . roundObject ? . loserRounds ( ) {
let ids = matches . map { $0 . id }
for loserRound in loserRounds {
if let first = loserRound . playedMatches ( ) . first {
if ids . contains ( first . id ) {
countedSet . add ( first . matchFormat )
}
}
}
}
matchCountPerDay [ day ] = countedSet
}
}
return matchCountPerDay
tournament . matchCountPerDay ( matchesByDay : matchesByDay )
}
private func _formatPerDayView ( matchCountPerDay : [ Date : NSCountedSet ] ) -> some View {