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_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 = 93; CURRENT_PROJECT_VERSION = 94;
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\"";
@ -1962,7 +1962,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 = 93; CURRENT_PROJECT_VERSION = 94;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6; DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -262,7 +262,7 @@ final class GroupStage: ModelObject, Storable {
} }
private func _matchUp(for matchIndex: Int) -> [Int] { 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 { func localizedMatchUpLabel(for matchIndex: Int) -> String {
@ -278,9 +278,9 @@ final class GroupStage: ModelObject, Storable {
let _teams = _teams(for: matchIndex) let _teams = _teams(for: matchIndex)
switch team { switch team {
case .one: case .one:
return _teams.first! return _teams.first ?? nil
case .two: case .two:
return _teams.last! return _teams.last ?? nil
} }
} }
@ -367,6 +367,16 @@ final class GroupStage: ModelObject, Storable {
Logger.error(error) Logger.error(error)
} }
} }
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 { override func deleteDependencies() throws {
let matches = self._matches() let matches = self._matches()

@ -455,6 +455,19 @@ defer {
return nextRound()?.isRankDisabled() == false 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? { func seedInterval(initialMode: Bool = false) -> SeedInterval? {
#if DEBUG_TIME //DEBUGING TIME #if DEBUG_TIME //DEBUGING TIME
let start = Date() 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 #if DEBUG
Section { Section {
RowButtonView("delete all group stages") { RowButtonView("delete all group stages") {

@ -370,27 +370,29 @@ struct GroupStageNameEditionView: View {
} }
private func maximumSize() -> Int { private func maximumSize() -> Int {
if groupStage.index == 0 { return 10
return tournament.teamsPerGroupStage + 1 // 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 // if let previousGroupStage = tournament.groupStages().first(where: { $0.index == groupStage.index - 1 }), previousGroupStage.size > groupStage.size {
} // return tournament.teamsPerGroupStage + 1
// }
return tournament.teamsPerGroupStage //
// return tournament.teamsPerGroupStage
} }
private func minimumSize() -> Int { private func minimumSize() -> Int {
if groupStage.index == tournament.groupStageCount - 1 { return 3
return max(3, tournament.teamsPerGroupStage - 1) // 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) // 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 tournament.teamsPerGroupStage
} }
private func _save() { 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 { // Section {
// RowButtonView("Enabled", role: .destructive) { // RowButtonView("Enabled", role: .destructive) {
// let allMatches = tournament._allMatchesIncludingDisabled() // let allMatches = tournament._allMatchesIncludingDisabled()

Loading…
Cancel
Save