|
|
|
|
@ -94,18 +94,13 @@ class GroupStage: ModelObject, Storable { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func scoreLabel(forGroupStagePosition groupStagePosition: Int) -> String? { |
|
|
|
|
func scoreLabel(forGroupStagePosition groupStagePosition: Int) -> (wins: String, losses: String, setsDifference: String?, gamesDifference: String?)? { |
|
|
|
|
if let scoreData = _score(forGroupStagePosition: groupStagePosition) { |
|
|
|
|
let hideGameDifference = matchFormat.setsToWin == 1 |
|
|
|
|
let hideSetDifference = matchFormat.setsToWin == 1 |
|
|
|
|
let setDifference = scoreData.setDifference.formatted(.number.sign(strategy: .always(includingZero: false))) |
|
|
|
|
let gameDifference = scoreData.gameDifference.formatted(.number.sign(strategy: .always(includingZero: false))) |
|
|
|
|
var differenceAsString = "\n" + gameDifference + " jeux" |
|
|
|
|
if hideGameDifference == false { |
|
|
|
|
differenceAsString = "\n" + setDifference + " sets" + differenceAsString |
|
|
|
|
} else { |
|
|
|
|
differenceAsString = setDifference |
|
|
|
|
} |
|
|
|
|
return "\(scoreData.wins)/\(scoreData.loses) " + differenceAsString |
|
|
|
|
return (wins: scoreData.wins.formatted(), losses: scoreData.loses.formatted(), setsDifference: hideSetDifference ? nil : setDifference, gamesDifference: gameDifference) |
|
|
|
|
// return "\(scoreData.wins)/\(scoreData.loses) " + differenceAsString |
|
|
|
|
} else { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
@ -114,6 +109,7 @@ class GroupStage: ModelObject, Storable { |
|
|
|
|
fileprivate func _score(forGroupStagePosition groupStagePosition: Int) -> TeamGroupStageScore? { |
|
|
|
|
guard let team = teamAt(groupStagePosition: groupStagePosition) else { return nil } |
|
|
|
|
let matches = matches(forGroupStagePosition: groupStagePosition).filter({ $0.hasEnded() }) |
|
|
|
|
if matches.isEmpty { return nil } |
|
|
|
|
let wins = matches.filter { $0.winningTeamId == team.id }.count |
|
|
|
|
let loses = matches.filter { $0.losingTeamId == team.id }.count |
|
|
|
|
let differences = matches.compactMap { $0.scoreDifference(groupStagePosition) } |
|
|
|
|
|