Laurent 1 year ago
commit fc8c69d224
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 16
      PadelClub/Data/GroupStage.swift
  3. 13
      PadelClub/Data/Round.swift
  4. 6
      PadelClub/Views/GroupStage/GroupStageSettingsView.swift
  5. 38
      PadelClub/Views/GroupStage/GroupStageView.swift
  6. 6
      PadelClub/Views/Round/RoundSettingsView.swift

@ -1915,7 +1915,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 93;
CURRENT_PROJECT_VERSION = 94;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
@ -1962,7 +1962,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 93;
CURRENT_PROJECT_VERSION = 94;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -262,7 +262,7 @@ final class GroupStage: ModelObject, Storable {
}
private func _matchUp(for matchIndex: Int) -> [Int] {
Array((0..<size).combinations(ofCount: 2))[matchIndex]
Array((0..<size).combinations(ofCount: 2))[safe: matchIndex] ?? []
}
func localizedMatchUpLabel(for matchIndex: Int) -> String {
@ -278,9 +278,9 @@ final class GroupStage: ModelObject, Storable {
let _teams = _teams(for: matchIndex)
switch team {
case .one:
return _teams.first!
return _teams.first ?? nil
case .two:
return _teams.last!
return _teams.last ?? nil
}
}
@ -368,6 +368,16 @@ final class GroupStage: ModelObject, Storable {
}
}
func pasteData() -> String {
var data: [String] = []
data.append(self.groupStageTitle())
teams().forEach { team in
data.append(team.teamLabelRanked(displayRank: true, displayTeamName: true))
}
return data.joined(separator: "\n")
}
override func deleteDependencies() throws {
let matches = self._matches()
for match in matches {

@ -455,6 +455,19 @@ defer {
return nextRound()?.isRankDisabled() == false
}
func pasteData() -> String {
var data: [String] = []
data.append(self.roundTitle())
playedMatches().forEach { match in
data.append(match.matchTitle())
data.append(match.team(.one)?.teamLabelRanked(displayRank: true, displayTeamName: true) ?? "-----")
data.append(match.team(.two)?.teamLabelRanked(displayRank: true, displayTeamName: true) ?? "-----")
}
return data.joined(separator: "\n")
}
func seedInterval(initialMode: Bool = false) -> SeedInterval? {
#if DEBUG_TIME //DEBUGING TIME
let start = Date()

@ -74,6 +74,12 @@ struct GroupStageSettingsView: View {
}
}
Section {
ShareLink(item: tournament.groupStages().compactMap { $0.pasteData() }.joined(separator: "\n\n")) {
Text("Exportez l'état poules")
}
}
#if DEBUG
Section {
RowButtonView("delete all group stages") {

@ -370,27 +370,29 @@ struct GroupStageNameEditionView: View {
}
private func maximumSize() -> Int {
if groupStage.index == 0 {
return tournament.teamsPerGroupStage + 1
}
if let previousGroupStage = tournament.groupStages().first(where: { $0.index == groupStage.index - 1 }), previousGroupStage.size > groupStage.size {
return tournament.teamsPerGroupStage + 1
}
return tournament.teamsPerGroupStage
return 10
// if groupStage.index == 0 {
// return tournament.teamsPerGroupStage + 1
// }
//
// if let previousGroupStage = tournament.groupStages().first(where: { $0.index == groupStage.index - 1 }), previousGroupStage.size > groupStage.size {
// return tournament.teamsPerGroupStage + 1
// }
//
// return tournament.teamsPerGroupStage
}
private func minimumSize() -> Int {
if groupStage.index == tournament.groupStageCount - 1 {
return max(3, tournament.teamsPerGroupStage - 1)
}
if let nextGroupStage = tournament.groupStages().first(where: { $0.index == groupStage.index + 1 }), nextGroupStage.size < groupStage.size {
return max(3, tournament.teamsPerGroupStage - 1)
}
return tournament.teamsPerGroupStage
return 3
// if groupStage.index == tournament.groupStageCount - 1 {
// return max(3, tournament.teamsPerGroupStage - 1)
// }
//
// if let nextGroupStage = tournament.groupStages().first(where: { $0.index == groupStage.index + 1 }), nextGroupStage.size < groupStage.size {
// return max(3, tournament.teamsPerGroupStage - 1)
// }
//
// return tournament.teamsPerGroupStage
}
private func _save() {

@ -74,6 +74,12 @@ struct RoundSettingsView: View {
}
}
Section {
ShareLink(item: tournament.rounds().compactMap { $0.pasteData() }.joined(separator: "\n\n")) {
Text("Exportez l'état du tableau")
}
}
// Section {
// RowButtonView("Enabled", role: .destructive) {
// let allMatches = tournament._allMatchesIncludingDisabled()

Loading…
Cancel
Save