@ -349,7 +349,9 @@ public enum FederalTournamentAge: Int, Hashable, Codable, CaseIterable, Identifi
return 4
} else {
switch level {
case . p25 , . p100 , . p250 :
case . p25 :
return 4
case . p100 , . p250 :
if category = = . women {
return 4
}
@ -710,7 +712,7 @@ public enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable
case 13. . . 16 :
return [ 175 , 150 , 138 , 113 , 100 , 88 , 75 , 63 , 53 , 45 , 38 , 25 , 13 , 8 , 3 ]
case 17. . . 20 :
return [ 188 , 163 , 150 , 138 , 123 , 113 , 100 , 88 , 75 , 63 , 58 , 50 , 45 , 38 , 30 , 25 , 13 , 8 , 3 ]
return [ 188 , 163 , 150 , 138 , 125 , 113 , 100 , 88 , 75 , 63 , 58 , 50 , 45 , 38 , 30 , 25 , 13 , 8 , 3 ]
case 21. . . 24 :
return [ 188 , 175 , 163 , 150 , 138 , 125 , 118 , 108 , 100 , 93 , 83 , 75 , 70 , 63 , 58 , 50 , 45 , 38 , 30 , 25 , 13 , 8 , 3 ]
case 25. . . 28 :
@ -1199,6 +1201,7 @@ public enum TeamPosition: Int, Identifiable, Hashable, Codable, CaseIterable {
public enum SetFormat : Int , Hashable , Codable {
case nine
case four
case three
case six
case superTieBreak
case megaTieBreak
@ -1225,6 +1228,10 @@ public enum SetFormat: Int, Hashable, Codable {
if teamOne = = 5 || teamTwo = = 5 {
return true
}
case . three :
if teamOne = = 4 || teamTwo = = 4 {
return true
}
case . six :
if teamOne = = 7 || teamTwo = = 7 {
return true
@ -1243,6 +1250,8 @@ public enum SetFormat: Int, Hashable, Codable {
return 8
case . four :
return 4
case . three :
return 3
case . six :
return 6
case . superTieBreak , . megaTieBreak :
@ -1260,6 +1269,10 @@ public enum SetFormat: Int, Hashable, Codable {
if teamOneScore = = 4 {
return [ ]
}
case . three :
if teamOneScore = = 3 {
return [ ]
}
case . six :
if teamOneScore = = 6 {
return [ ]
@ -1282,6 +1295,8 @@ public enum SetFormat: Int, Hashable, Codable {
return [ 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 ]
case . four :
return [ 5 , 4 , 3 , 2 , 1 , 0 ]
case . three :
return [ 4 , 3 , 2 , 1 , 0 ]
case . six :
return [ 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 ]
case . superTieBreak :
@ -1297,6 +1312,8 @@ public enum SetFormat: Int, Hashable, Codable {
return 9
case . four :
return 4
case . three :
return 4
case . six :
return 6
case . superTieBreak :
@ -1364,15 +1381,15 @@ public enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable {
return 2
case . nineGames , . nineGamesDecisivePoint :
return 3
case . superTie :
case . singleSetOfFourGames , . singleSetOfFourGamesDecisivePoint :
return 4
case . mega Tie:
case . super Tie:
return 5
case . twoSetsOfSuper Tie:
case . mega Tie:
return 6
case . singleSet , . singleSetDecisivePoint :
case . twoSetsOfSuperTie :
return 7
case . singleSetOfFourGames , . singleSetOfFourGames DecisivePoint :
case . singleSet , . singleSetDecisivePoint :
return 8
}
}
@ -1395,15 +1412,15 @@ public enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable {
return 3
case . nineGamesDecisivePoint :
return 3
case . superTie :
case . singleSetOfFourGames , . singleSetOfFourGamesDecisivePoint :
return 4
case . mega Tie:
case . super Tie:
return 5
case . twoSetsOfSuper Tie:
case . mega Tie:
return 6
case . singleSet , . singleSetDecisivePoint :
case . twoSetsOfSuperTie :
return 7
case . singleSetOfFourGames , . singleSetOfFourGames DecisivePoint :
case . singleSet , . singleSetDecisivePoint :
return 8
}
}
@ -1641,7 +1658,7 @@ public enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable {
case . megaTie :
return " supertie de 15 points "
case . singleSetOfFourGames , . singleSetOfFourGamesDecisivePoint :
return " 1 set de 4 jeux, tiebreak à 4/4 "
return " 1 set de 4 jeux, tiebreak à 3/3 "
}
}
@ -1670,8 +1687,10 @@ public enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable {
switch self {
case . twoSets , . twoSetsSuperTie , . twoSetsDecisivePoint , . twoSetsDecisivePointSuperTie , . singleSet , . singleSetDecisivePoint :
return . six
case . twoSetsOfFourGames , . twoSetsOfFourGamesDecisivePoint , . singleSetOfFourGames , . singleSetOfFourGamesDecisivePoint :
case . twoSetsOfFourGames , . twoSetsOfFourGamesDecisivePoint :
return . four
case . singleSetOfFourGames , . singleSetOfFourGamesDecisivePoint :
return . three
case . nineGames , . nineGamesDecisivePoint :
return . nine
case . superTie , . twoSetsOfSuperTie :
@ -1850,6 +1869,16 @@ public enum RoundRule {
}
}
public static func cumulatedNumberOfMatches ( forTeams teams : Int ) -> Int {
var i = teams / 2
var loserTeams = teams / 2
while loserTeams > 1 {
i += Self . cumulatedNumberOfMatches ( forTeams : loserTeams )
loserTeams = loserTeams / 2
}
return i
}
public static func teamsInFirstRound ( forTeams teams : Int ) -> Int {
Int ( pow ( 2.0 , ceil ( log2 ( Double ( teams ) ) ) ) )
}
@ -1880,12 +1909,16 @@ public enum RoundRule {
}
public static func numberOfMatches ( forRoundIndex roundIndex : Int ) -> Int {
Int ( pow ( 2.0 , Double ( roundIndex ) ) )
( 1 << roundIndex )
}
public static func baseIndex ( forRoundIndex roundIndex : Int ) -> Int {
numberOfMatches ( forRoundIndex : roundIndex ) - 1
}
static func matchIndexWithinRound ( fromMatchIndex matchIndex : Int ) -> Int {
let roundIndex = roundIndex ( fromMatchIndex : matchIndex )
let matchIndexWithinRound = matchIndex - ( Int ( pow ( 2.0 , Double ( roundIndex ) ) ) - 1 )
let matchIndexWithinRound = matchIndex - baseIndex ( forRoundIndex : roundIndex )
return matchIndexWithinRound
}
@ -1909,7 +1942,7 @@ public enum RoundRule {
}
return " Quart de finale "
default :
return " \( Int ( pow ( 2.0 , Double ( roundIndex ) ) ) ) ème "
return " \( ( 1 << roundIndex ) ) ème "
}
}
}