multistore
Razmig Sarkissian 1 year ago
parent 5d6148e5f6
commit af11629e03
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 20
      PadelClub/Data/Tournament.swift

@ -1859,7 +1859,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 41; CURRENT_PROJECT_VERSION = 42;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6; DEVELOPMENT_TEAM = BQ3Y44M3Q6;
@ -1897,7 +1897,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 41; CURRENT_PROJECT_VERSION = 42;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6; DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -531,9 +531,18 @@ class Tournament : ModelObject, Storable {
selectedSortedTeams().filter({ $0.groupStagePosition != nil }) selectedSortedTeams().filter({ $0.groupStagePosition != nil })
} }
func groupStageSpots() -> Int {
let _groupStagesCount = groupStages().count
if groupStageCount != _groupStagesCount {
return groupStageCount * teamsPerGroupStage
} else {
return groupStages().map { $0.size }.reduce(0,+)
}
}
func seeds() -> [TeamRegistration] { func seeds() -> [TeamRegistration] {
let selectedSortedTeams = selectedSortedTeams() let selectedSortedTeams = selectedSortedTeams()
let seeds = max(selectedSortedTeams.count - groupStageCount * teamsPerGroupStage, 0) let seeds = max(selectedSortedTeams.count - groupStageSpots() , 0)
return Array(selectedSortedTeams.prefix(seeds)) return Array(selectedSortedTeams.prefix(seeds))
} }
@ -761,8 +770,9 @@ class Tournament : ModelObject, Storable {
let wcBracket = _teams.filter { $0.wildCardBracket }.sorted(using: _currentSelectionSorting, order: .ascending) let wcBracket = _teams.filter { $0.wildCardBracket }.sorted(using: _currentSelectionSorting, order: .ascending)
var bracketSeeds = min(teamCount, _completeTeams.count) - groupStageCount * teamsPerGroupStage - wcBracket.count let groupStageSpots = groupStageSpots()
var groupStageTeamCount = groupStageCount * teamsPerGroupStage - wcGroupStage.count var bracketSeeds = min(teamCount, _completeTeams.count) - groupStageSpots - wcBracket.count
var groupStageTeamCount = groupStageSpots - wcGroupStage.count
if groupStageTeamCount < 0 { groupStageTeamCount = 0 } if groupStageTeamCount < 0 { groupStageTeamCount = 0 }
if bracketSeeds < 0 { bracketSeeds = 0 } if bracketSeeds < 0 { bracketSeeds = 0 }
@ -792,7 +802,7 @@ class Tournament : ModelObject, Storable {
} }
func groupStageCut() -> Int { func groupStageCut() -> Int {
groupStageCount * teamsPerGroupStage groupStageSpots()
} }
func cutLabel(index: Int) -> String { func cutLabel(index: Int) -> String {
@ -1299,7 +1309,7 @@ class Tournament : ModelObject, Storable {
func groupStageStatus() async -> String { func groupStageStatus() async -> String {
let groupStageTeamsCount = groupStageTeams().count let groupStageTeamsCount = groupStageTeams().count
if groupStageTeamsCount == 0 || groupStageTeamsCount != teamsPerGroupStage * groupStageCount { if groupStageTeamsCount == 0 || groupStageTeamsCount != groupStageSpots() {
return "à faire" return "à faire"
} }
let runningGroupStages = groupStages().filter({ $0.isRunning() }) let runningGroupStages = groupStages().filter({ $0.isRunning() })

Loading…
Cancel
Save