fix single group stage final ranking stuff

paca_championship
Raz 1 year ago
parent fe5ba820e4
commit 50a0f8a6ae
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 4
      PadelClub/Data/Tournament.swift
  3. 3
      PadelClub/Utils/PadelRule.swift
  4. 32
      PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift
  5. 6
      PadelClub/Views/Tournament/Screen/TableStructureView.swift

@ -3150,7 +3150,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2; CURRENT_PROJECT_VERSION = 5;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
@ -3195,7 +3195,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2; CURRENT_PROJECT_VERSION = 5;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6; DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -1778,6 +1778,10 @@ defer {
return Round(tournament: id, index: $0, matchFormat: roundSmartMatchFormat($0), loserBracketMode: loserBracketMode) return Round(tournament: id, index: $0, matchFormat: roundSmartMatchFormat($0), loserBracketMode: loserBracketMode)
} }
if rounds.isEmpty {
return
}
do { do {
try self.tournamentStore.rounds.addOrUpdate(contentOfs: rounds) try self.tournamentStore.rounds.addOrUpdate(contentOfs: rounds)
} catch { } catch {

@ -1592,7 +1592,8 @@ enum RoundRule {
} }
static func numberOfRounds(forTeams teams: Int) -> Int { static func numberOfRounds(forTeams teams: Int) -> Int {
Int(log2(Double(teamsInFirstRound(forTeams: teams)))) if teams == 0 { return 0 }
return Int(log2(Double(teamsInFirstRound(forTeams: teams))))
} }
static func matchIndex(fromRoundIndex roundIndex: Int) -> Int { static func matchIndex(fromRoundIndex roundIndex: Int) -> Int {

@ -66,24 +66,28 @@ struct GroupStageTeamView: View {
} }
} }
} }
}
Section {
if team.qualified == false { Section {
RowButtonView("Qualifier l'équipe", role: .destructive) { if team.qualified == false {
team.qualified = true RowButtonView("Qualifier l'équipe", role: .destructive) {
//team.bracketPosition = nil team.qualified = true
_save() //team.bracketPosition = nil
} _save()
} else { }
RowButtonView("Annuler la qualification", role: .destructive) { } else {
team.qualified = false RowButtonView("Annuler la qualification", role: .destructive) {
groupStage.tournamentObject()?.resetTeamScores(in: team.bracketPosition) team.qualified = false
team.bracketPosition = nil groupStage.tournamentObject()?.resetTeamScores(in: team.bracketPosition)
_save() team.bracketPosition = nil
} _save()
} }
} }
}
if groupStage.tournamentObject()?.hasEnded() == false {
if team.qualified == false { if team.qualified == false {
Section { Section {
RowButtonView("Retirer de la poule", role: .destructive) { RowButtonView("Retirer de la poule", role: .destructive) {

@ -106,7 +106,7 @@ struct TableStructureView: View {
if structurePreset != .doubleGroupStage { if structurePreset != .doubleGroupStage {
LabeledContent { LabeledContent {
StepperView(count: $qualifiedPerGroupStage, minimum: 1, maximum: (teamsPerGroupStage-1)) StepperView(count: $qualifiedPerGroupStage, minimum: 0, maximum: (teamsPerGroupStage-1))
} label: { } label: {
Text("Qualifié\(qualifiedPerGroupStage.pluralSuffix) par poule") Text("Qualifié\(qualifiedPerGroupStage.pluralSuffix) par poule")
} }
@ -445,8 +445,8 @@ struct TableStructureView: View {
teamsPerGroupStage = 2 teamsPerGroupStage = 2
} }
if qualifiedPerGroupStage < 1 { if qualifiedPerGroupStage < 0 {
qualifiedPerGroupStage = 1 qualifiedPerGroupStage = 0
} }
if groupStageAdditionalQualified < 0 { if groupStageAdditionalQualified < 0 {

Loading…
Cancel
Save