@ -36,11 +36,11 @@ class Round: ModelObject, Storable {
}
}
func _matches ( ) -> [ Match ] {
func _matches ( ) -> [ Match ] {
return Store . main . filter { $0 . round = = self . id }
return Data Store. shared . matches . filter { $0 . round = = self . id }
}
}
func getDisabledMatches ( ) -> [ Match ] {
func getDisabledMatches ( ) -> [ Match ] {
return Store . main . filter { $0 . round = = self . id && $0 . disabled = = true }
return Data Store. shared . matches . filter { $0 . round = = self . id && $0 . disabled = = true }
}
}
// MARK: -
// MARK: -
@ -60,7 +60,11 @@ class Round: ModelObject, Storable {
}
}
func hasEnded ( ) -> Bool {
func hasEnded ( ) -> Bool {
if parent = = nil {
return playedMatches ( ) . anySatisfy ( { $0 . hasEnded ( ) = = false } ) = = false
return playedMatches ( ) . anySatisfy ( { $0 . hasEnded ( ) = = false } ) = = false
} else {
return enabledMatches ( ) . anySatisfy ( { $0 . hasEnded ( ) = = false } ) = = false
}
}
}
func upperMatches ( ofMatch match : Match ) -> [ Match ] {
func upperMatches ( ofMatch match : Match ) -> [ Match ] {
@ -74,8 +78,8 @@ class Round: ModelObject, Storable {
func previousMatches ( ofMatch match : Match ) -> [ Match ] {
func previousMatches ( ofMatch match : Match ) -> [ Match ] {
guard let previousRound = previousRound ( ) else { return [ ] }
guard let previousRound = previousRound ( ) else { return [ ] }
return Store . main . filter {
return Data Store. shared . matches . filter {
( $0 . index = = match . topPreviousRoundMatchIndex ( ) || $0 . index = = match . bottomPreviousRoundMatchIndex ( ) ) && $0 . round = = previousRound . id
$0 . round = = previousRound . id && ( $0 . index = = match . topPreviousRoundMatchIndex ( ) || $0 . index = = match . bottomPreviousRoundMatchIndex ( ) )
}
}
}
}
@ -92,26 +96,21 @@ class Round: ModelObject, Storable {
}
}
}
}
func team ( _ team : TeamPosition , inMatch match : Match ) -> TeamRegistration ? {
func team ( _ team : TeamPosition , inMatch match : Match , previousRound : Round ? ) -> TeamRegistration ? {
switch team {
return roundProjectedTeam ( team , inMatch : match , previousRound : previousRound )
case . one :
return roundProjectedTeam ( . one , inMatch : match )
case . two :
return roundProjectedTeam ( . two , inMatch : match )
}
}
}
func seed ( _ team : TeamPosition , inMatchIndex matchIndex : Int ) -> TeamRegistration ? {
func seed ( _ team : TeamPosition , inMatchIndex matchIndex : Int ) -> TeamRegistration ? {
return Store . main . filter ( isIncluded : {
return DataStore . shared . teamRegistrations . first ( where : {
$0 . tournament = = tournament
$0 . tournament = = tournament
&& $0 . bracketPosition != nil
&& $0 . bracketPosition != nil
&& ( $0 . bracketPosition ! / 2 ) = = matchIndex
&& ( $0 . bracketPosition ! / 2 ) = = matchIndex
&& ( $0 . bracketPosition ! % 2 ) = = team . rawValue
&& ( $0 . bracketPosition ! % 2 ) = = team . rawValue
} ) . first
} )
}
}
func seeds ( inMatchIndex matchIndex : Int ) -> [ TeamRegistration ] {
func seeds ( inMatchIndex matchIndex : Int ) -> [ TeamRegistration ] {
return Store . main . filter ( isIncluded : {
return Data Store. shared . teamRegistrations . filter ( {
$0 . tournament = = tournament
$0 . tournament = = tournament
&& $0 . bracketPosition != nil
&& $0 . bracketPosition != nil
&& ( $0 . bracketPosition ! / 2 ) = = matchIndex
&& ( $0 . bracketPosition ! / 2 ) = = matchIndex
@ -121,7 +120,7 @@ class Round: ModelObject, Storable {
func seeds ( ) -> [ TeamRegistration ] {
func seeds ( ) -> [ TeamRegistration ] {
let initialMatchIndex = RoundRule . matchIndex ( fromRoundIndex : index )
let initialMatchIndex = RoundRule . matchIndex ( fromRoundIndex : index )
let numberOfMatches = RoundRule . numberOfMatches ( forRoundIndex : index )
let numberOfMatches = RoundRule . numberOfMatches ( forRoundIndex : index )
return Store . main . filter ( isIncluded : {
return Data Store. shared . teamRegistrations . filter ( {
$0 . tournament = = tournament
$0 . tournament = = tournament
&& $0 . bracketPosition != nil
&& $0 . bracketPosition != nil
&& ( $0 . bracketPosition ! / 2 ) >= initialMatchIndex
&& ( $0 . bracketPosition ! / 2 ) >= initialMatchIndex
@ -137,7 +136,14 @@ class Round: ModelObject, Storable {
return playedMatches ( ) . flatMap ( { $0 . teams ( ) } )
return playedMatches ( ) . flatMap ( { $0 . teams ( ) } )
}
}
func roundProjectedTeam ( _ team : TeamPosition , inMatch match : Match ) -> TeamRegistration ? {
func roundProjectedTeam ( _ team : TeamPosition , inMatch match : Match , previousRound : Round ? ) -> TeamRegistration ? {
#if DEBUG_TIME // D E B U G I N G T I M E
let start = Date ( )
defer {
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
print ( " func roundProjectedTeam " , team . rawValue , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
#endif
if isLoserBracket ( ) = = false , let seed = seed ( team , inMatchIndex : match . index ) {
if isLoserBracket ( ) = = false , let seed = seed ( team , inMatchIndex : match . index ) {
return seed
return seed
}
}
@ -146,76 +152,115 @@ class Round: ModelObject, Storable {
case . one :
case . one :
if let luckyLoser = match . teamScores . first ( where : { $0 . luckyLoser = = match . index * 2 } ) {
if let luckyLoser = match . teamScores . first ( where : { $0 . luckyLoser = = match . index * 2 } ) {
return luckyLoser . team
return luckyLoser . team
} else if let parent = upperBracketTopMatch ( ofMatchIndex : match . index ) ? . losingTeamId {
} else if let previousMatch = topPreviousRoundMatch ( ofMatch : match , previousRound : previousRound ) {
return Store . main . findById ( parent )
} else if let previousMatch = topPreviousRoundMatch ( ofMatch : match ) {
if let teamId = previousMatch . winningTeamId {
if let teamId = previousMatch . winningTeamId {
return Store . main . findById ( teamId )
return Store . main . findById ( teamId )
} else if previousMatch . disabled {
} else if previousMatch . disabled {
return previousMatch . teams ( ) . first
return previousMatch . teams ( ) . first
}
}
} else if let parent = upperBracketTopMatch ( ofMatchIndex : match . index , previousRound : previousRound ) ? . losingTeamId {
return Store . main . findById ( parent )
}
}
case . two :
case . two :
if let luckyLoser = match . teamScores . first ( where : { $0 . luckyLoser = = match . index * 2 + 1 } ) {
if let luckyLoser = match . teamScores . first ( where : { $0 . luckyLoser = = match . index * 2 + 1 } ) {
return luckyLoser . team
return luckyLoser . team
} else if let parent = upperBracketBottomMatch ( ofMatchIndex : match . index ) ? . losingTeamId {
} else if let previousMatch = bottomPreviousRoundMatch ( ofMatch : match , previousRound : previousRound ) {
return Store . main . findById ( parent )
} else if let previousMatch = bottomPreviousRoundMatch ( ofMatch : match ) {
if let teamId = previousMatch . winningTeamId {
if let teamId = previousMatch . winningTeamId {
return Store . main . findById ( teamId )
return Store . main . findById ( teamId )
} else if previousMatch . disabled {
} else if previousMatch . disabled {
return previousMatch . teams ( ) . first
return previousMatch . teams ( ) . first
}
}
} else if let parent = upperBracketBottomMatch ( ofMatchIndex : match . index , previousRound : previousRound ) ? . losingTeamId {
return Store . main . findById ( parent )
}
}
}
}
return nil
return nil
}
}
func upperBracketTopMatch ( ofMatchIndex matchIndex : Int ) -> Match ? {
func upperBracketTopMatch ( ofMatchIndex matchIndex : Int , previousRound : Round ? ) -> Match ? {
#if DEBUG_TIME // D E B U G I N G T I M E
let start = Date ( )
defer {
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
print ( " func upperBracketTopMatch " , matchIndex , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
#endif
let indexInRound = RoundRule . matchIndexWithinRound ( fromMatchIndex : matchIndex )
let indexInRound = RoundRule . matchIndexWithinRound ( fromMatchIndex : matchIndex )
if isLoserBracket ( ) , previousRound ( ) = = nil , let parentRound = parentRound , let upperBracketTopMatch = parentRound . getMatch ( atMatchIndexInRound : indexInRound * 2 ) {
if isLoserBracket ( ) , previousRound = = nil , let parentRound = parentRound , let upperBracketTopMatch = parentRound . getMatch ( atMatchIndexInRound : indexInRound * 2 ) {
return upperBracketTopMatch
return upperBracketTopMatch
}
}
return nil
return nil
}
}
func upperBracketBottomMatch ( ofMatchIndex matchIndex : Int ) -> Match ? {
func upperBracketBottomMatch ( ofMatchIndex matchIndex : Int , previousRound : Round ? ) -> Match ? {
#if DEBUG_TIME // D E B U G I N G T I M E
let start = Date ( )
defer {
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
print ( " func upperBracketBottomMatch " , matchIndex , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
#endif
let indexInRound = RoundRule . matchIndexWithinRound ( fromMatchIndex : matchIndex )
let indexInRound = RoundRule . matchIndexWithinRound ( fromMatchIndex : matchIndex )
if isLoserBracket ( ) , previousRound ( ) = = nil , let parentRound = parentRound , let upperBracketBottomMatch = parentRound . getMatch ( atMatchIndexInRound : indexInRound * 2 + 1 ) {
if isLoserBracket ( ) , previousRound = = nil , let parentRound = parentRound , let upperBracketBottomMatch = parentRound . getMatch ( atMatchIndexInRound : indexInRound * 2 + 1 ) {
return upperBracketBottomMatch
return upperBracketBottomMatch
}
}
return nil
return nil
}
}
func topPreviousRoundMatch ( ofMatch match : Match ) -> Match ? {
func topPreviousRoundMatch ( ofMatch match : Match , previousRound : Round ? ) -> Match ? {
guard let previousRound = previousRound ( ) else { return nil }
#if DEBUG_TIME // D E B U G I N G T I M E
let matches : [ Match ] = Store . main . filter {
let start = Date ( )
$0 . index = = match . topPreviousRoundMatchIndex ( ) && $0 . round = = previousRound . id
defer {
}
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
return matches . sorted ( by : \ . index ) . first
print ( " func topPreviousRoundMatch " , match . id , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
}
#endif
func bottomPreviousRoundMatch ( ofMatch match : Match ) -> Match ? {
guard let previousRound else { return nil }
guard let previousRound = previousRound ( ) else { return nil }
let topPreviousRoundMatchIndex = match . topPreviousRoundMatchIndex ( )
let matches : [ Match ] = Store . main . filter {
return DataStore . shared . matches . first ( where : {
$0 . index = = match . bottomPreviousRoundMatchIndex ( ) && $0 . round = = previousRound . id
$0 . round = = previousRound . id && $0 . index = = topPreviousRoundMatchIndex
} )
}
}
return matches . sorted ( by : \ . index ) . first
func bottomPreviousRoundMatch ( ofMatch match : Match , previousRound : Round ? ) -> Match ? {
#if DEBUG_TIME // D E B U G I N G T I M E
let start = Date ( )
defer {
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
print ( " func bottomPreviousRoundMatch " , match . id , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
#endif
guard let previousRound else { return nil }
let bottomPreviousRoundMatchIndex = match . bottomPreviousRoundMatchIndex ( )
return DataStore . shared . matches . first ( where : {
$0 . round = = previousRound . id && $0 . index = = bottomPreviousRoundMatchIndex
} )
}
}
func getMatch ( atMatchIndexInRound matchIndexInRound : Int ) -> Match ? {
func getMatch ( atMatchIndexInRound matchIndexInRound : Int ) -> Match ? {
Store . main . filter ( isIncluded : {
Data Store. shared . matches . first ( where : {
let index = RoundRule . matchIndexWithinRound ( fromMatchIndex : $0 . index )
let index = RoundRule . matchIndexWithinRound ( fromMatchIndex : $0 . index )
return $0 . round = = id && index = = matchIndexInRound
return $0 . round = = id && index = = matchIndexInRound
} ) . first
} )
}
}
func enabledMatches ( ) -> [ Match ] {
func enabledMatches ( ) -> [ Match ] {
return Store . main . filter { $0 . round = = self . id && $0 . disabled = = false }
return Data Store. shared . matches . filter { $0 . round = = self . id && $0 . disabled = = false }
}
}
func displayableMatches ( ) -> [ Match ] {
func displayableMatches ( ) -> [ Match ] {
#if DEBUG_TIME // D E B U G I N G T I M E
let start = Date ( )
defer {
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
print ( " func displayableMatches of round: " , id , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
#endif
if index = = 0 && isUpperBracket ( ) {
if index = = 0 && isUpperBracket ( ) {
var matches : [ Match ? ] = [ playedMatches ( ) . first ]
var matches : [ Match ? ] = [ playedMatches ( ) . first ]
matches . append ( loserRounds ( ) . first ? . playedMatches ( ) . first )
matches . append ( loserRounds ( ) . first ? . playedMatches ( ) . first )
@ -234,17 +279,28 @@ class Round: ModelObject, Storable {
}
}
func previousRound ( ) -> Round ? {
func previousRound ( ) -> Round ? {
return Store . main . filter ( isIncluded : { $0 . tournament = = tournament && $0 . parent = = parent && $0 . index = = index + 1 } ) . first
#if DEBUG_TIME // D E B U G I N G T I M E
let start = Date ( )
defer {
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
print ( " func previousRound of: " , id , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
#endif
return DataStore . shared . rounds . first ( where : { $0 . tournament = = tournament && $0 . parent = = parent && $0 . index = = index + 1 } )
}
}
func nextRound ( ) -> Round ? {
func nextRound ( ) -> Round ? {
return Store . main . filter ( isIncluded : { $0 . tournament = = tournament && $0 . parent = = parent && $0 . index = = index - 1 } ) . first
return Data Store. shared . rounds . first ( where : { $0 . tournament = = tournament && $0 . parent = = parent && $0 . index = = index - 1 } )
}
}
func loserRounds ( forRoundIndex roundIndex : Int ) -> [ Round ] {
func loserRounds ( forRoundIndex roundIndex : Int ) -> [ Round ] {
return loserRoundsAndChildren ( ) . filter ( { $0 . index = = roundIndex } ) . sorted ( by : \ . theoryCumulativeMatchCount )
return loserRoundsAndChildren ( ) . filter ( { $0 . index = = roundIndex } ) . sorted ( by : \ . theoryCumulativeMatchCount )
}
}
func loserRounds ( forRoundIndex roundIndex : Int , loserRoundsAndChildren : [ Round ] ) -> [ Round ] {
return loserRoundsAndChildren . filter ( { $0 . index = = roundIndex } ) . sorted ( by : \ . theoryCumulativeMatchCount )
}
func isDisabled ( ) -> Bool {
func isDisabled ( ) -> Bool {
return _matches ( ) . allSatisfy ( { $0 . disabled } )
return _matches ( ) . allSatisfy ( { $0 . disabled } )
}
}
@ -351,8 +407,15 @@ class Round: ModelObject, Storable {
func correspondingLoserRoundTitle ( _ displayStyle : DisplayStyle = . wide ) -> String {
func correspondingLoserRoundTitle ( _ displayStyle : DisplayStyle = . wide ) -> String {
#if DEBUG_TIME // D E B U G I N G T I M E
let start = Date ( )
defer {
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
print ( " func correspondingLoserRoundTitle() " , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
#endif
let initialMatchIndexFromRoundIndex = RoundRule . matchIndex ( fromRoundIndex : index )
let initialMatchIndexFromRoundIndex = RoundRule . matchIndex ( fromRoundIndex : index )
let seedsAfterThisRound : [ TeamRegistration ] = Store . main . filter ( isIncluded : {
let seedsAfterThisRound : [ TeamRegistration ] = Data Store. shared . teamRegistrations . filter ( {
$0 . tournament = = tournament
$0 . tournament = = tournament
&& $0 . bracketPosition != nil
&& $0 . bracketPosition != nil
&& ( $0 . bracketPosition ! / 2 ) < initialMatchIndexFromRoundIndex
&& ( $0 . bracketPosition ! / 2 ) < initialMatchIndexFromRoundIndex
@ -366,23 +429,38 @@ class Round: ModelObject, Storable {
return nextRound ( ) ? . isRankDisabled ( ) = = false
return nextRound ( ) ? . isRankDisabled ( ) = = false
}
}
func seedInterval ( ) -> SeedInterval ? {
func seedInterval ( expanded : Bool = false ) -> SeedInterval ? {
#if DEBUG_TIME // D E B U G I N G T I M E
let start = Date ( )
defer {
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
print ( " func seedInterval(expanded: Bool = false) " , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
#endif
if parent = = nil {
if parent = = nil {
let numberOfMatches = RoundRule . numberOfMatches ( forRoundIndex : index + 1 )
if index = = 0 { return SeedInterval ( first : 1 , last : 2 ) }
let initialMatchIndexFromRoundIndex = RoundRule . matchIndex ( fromRoundIndex : index )
let initialMatchIndexFromRoundIndex = RoundRule . matchIndex ( fromRoundIndex : index )
let seedsAfterThisRound : [ TeamRegistration ] = Store . main . filter ( isIncluded : {
let seedsAfterThisRound : [ TeamRegistration ] = Data Store. shared . teamRegistrations . filter ( {
$0 . tournament = = tournament
$0 . tournament = = tournament
&& $0 . bracketPosition != nil
&& $0 . bracketPosition != nil
&& ( $0 . bracketPosition ! / 2 ) < initialMatchIndexFromRoundIndex
&& ( $0 . bracketPosition ! / 2 ) < initialMatchIndexFromRoundIndex
} )
} )
let playedMatches = playedMatches ( )
let playedMatches = playedMatches ( )
let reduce = numberOfMatches / 2 - ( playedMatches . count + seedsAfterThisRound . count )
let seedInterval = SeedInterval ( first : playedMatches . count + seedsAfterThisRound . count + 1 , last : playedMatches . count * 2 + seedsAfterThisRound . count )
return SeedInterval ( first : 1 , last : numberOfMatches , reduce : reduce )
return seedInterval
}
}
if let previousRound = previousRound ( ) {
if let previousRound = previousRound ( ) {
if previousRound . enabledMatches ( ) . isEmpty = = false && expanded = = false {
return previousRound . seedInterval ( ) ? . chunks ( ) ? . first
return previousRound . seedInterval ( ) ? . chunks ( ) ? . first
} else {
return previousRound . previousRound ( ) ? . seedInterval ( )
}
} else if let parentRound {
} else if let parentRound {
if parentRound . parent = = nil && expanded = = false {
return parentRound . seedInterval ( )
}
return parentRound . seedInterval ( ) ? . chunks ( ) ? . last
return parentRound . seedInterval ( ) ? . chunks ( ) ? . last
}
}
@ -396,20 +474,6 @@ class Round: ModelObject, Storable {
return RoundRule . roundName ( fromRoundIndex : index , displayStyle : displayStyle )
return RoundRule . roundName ( fromRoundIndex : index , displayStyle : displayStyle )
}
}
func roundTitleAndPointsRange ( _ displayStyle : DisplayStyle = . wide , expanded : Bool = false , inTournament : Tournament ) -> ( String ? , String ? ) {
let seedInterval = seedInterval ( ) ? . withLast ( enabledMatches ( ) . count * 2 - 1 )
var roundTitle : String ? = nil
if parent != nil {
roundTitle = seedInterval ? . localizedLabel ( displayStyle ) ? ? " Round pas trouvé "
} else {
roundTitle = RoundRule . roundName ( fromRoundIndex : index , displayStyle : displayStyle )
}
let tournamentTeamCount = inTournament . teamCount
let pointsEarned : String ? = seedInterval ? . pointsRange ( tournamentLevel : inTournament . tournamentLevel , teamsCount : tournamentTeamCount )
return ( roundTitle , pointsEarned )
}
func updateTournamentState ( ) {
func updateTournamentState ( ) {
if let tournamentObject = tournamentObject ( ) , index = = 0 , isUpperBracket ( ) , hasEnded ( ) {
if let tournamentObject = tournamentObject ( ) , index = = 0 , isUpperBracket ( ) , hasEnded ( ) {
tournamentObject . endDate = Date ( )
tournamentObject . endDate = Date ( )
@ -433,7 +497,15 @@ class Round: ModelObject, Storable {
}
}
func loserRounds ( ) -> [ Round ] {
func loserRounds ( ) -> [ Round ] {
return Store . main . filter ( isIncluded : { $0 . parent = = id } ) . sorted ( by : \ . index ) . reversed ( )
#if DEBUG_TIME // D E B U G I N G T I M E
let start = Date ( )
defer {
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
print ( " func loserRounds: " , id , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
#endif
return DataStore . shared . rounds . filter ( { $0 . parent = = id } ) . sorted ( by : \ . index ) . reversed ( )
}
}
func loserRoundsAndChildren ( ) -> [ Round ] {
func loserRoundsAndChildren ( ) -> [ Round ] {
@ -574,7 +646,7 @@ extension Round: Selectable, Equatable {
}
}
func selectionLabel ( ) -> String {
func selectionLabel ( index : Int ) -> String {
if let parentRound {
if let parentRound {
return " Tour # \( parentRound . loserRounds ( ) . count - index ) "
return " Tour # \( parentRound . loserRounds ( ) . count - index ) "
} else {
} else {
@ -583,6 +655,15 @@ extension Round: Selectable, Equatable {
}
}
func badgeValue ( ) -> Int ? {
func badgeValue ( ) -> Int ? {
#if DEBUG_TIME // D E B U G I N G T I M E
let start = Date ( )
defer {
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
print ( " func badgeValue round of: " , id , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
#endif
if let parentRound {
if let parentRound {
return parentRound . loserRounds ( forRoundIndex : index ) . flatMap { $0 . playedMatches ( ) } . filter ( { $0 . isRunning ( ) } ) . count
return parentRound . loserRounds ( forRoundIndex : index ) . flatMap { $0 . playedMatches ( ) } . filter ( { $0 . isRunning ( ) } ) . count
} else {
} else {
@ -595,6 +676,13 @@ extension Round: Selectable, Equatable {
}
}
func badgeImage ( ) -> Badge ? {
func badgeImage ( ) -> Badge ? {
hasEnded ( ) ? . checkmark : nil
#if DEBUG_TIME // D E B U G I N G T I M E
let start = Date ( )
defer {
let duration = Duration . milliseconds ( Date ( ) . timeIntervalSince ( start ) * 1_000 )
print ( " func badgeImage of round: " , id , duration . formatted ( . units ( allowed : [ . seconds , . milliseconds ] ) ) )
}
#endif
return hasEnded ( ) ? . checkmark : nil
}
}
}
}