public static void Display(Match match) { Set set = match.CurrentSet (); Game game = set.CurrentGame (); if (!game.IsOver ()) { UI.Scoreboard (game); } else if (!set.IsOver ()) { UI.Scoreboard (set); } else { UI.Scoreboard (match); } }
public static void Scoreboard(Match m) { List<Score> scores = m.Sets.Select (s => s.CurrentScore ()).ToList (); var range = Enumerable.Range (1, scores.Count); List<int> p1 = scores.Select (score => score.a).ToList (); List<int> p2 = scores.Select (score => score.b).ToList (); if (Match.IsOver (m)) { Console.WriteLine (WinString (Match.CurrentScore (m))); } Console.WriteLine (range.Aggregate ("Set |", FormatAgg)); Console.WriteLine ("---------------------------"); Console.WriteLine (p1.Aggregate ("Player A |", FormatAgg)); Console.WriteLine ("---------------------------"); Console.WriteLine (p2.Aggregate ("Player B |", FormatAgg)); Console.WriteLine ("---------------------------"); }
public static void DisplayHistory(Match match) { History.MatchHistory (match).ForEach (set => set.ForEach (game => game.ForEach (score => Console.WriteLine (score)))); }
public static bool IsOver(Match match) { return Match.CurrentScore (match).HasMin (Settings.MinSets); }
public static Score CurrentScore(Match match) { return Score.SumOfWins (match.Sets.Where (s => s.IsOver ()).Select (s => s.CurrentScore ()).ToList ()); }
public static List<List<List<string>>> MatchHistory(Match match) { List<int> range = Enumerable.Range (1, match.Sets.Count).ToList (); return range.Zip (match.Sets, (count, set) => SetHistory (count, set)).ToList (); }
public void SwitchToMatch(int num) { if (num < Matches.Count) { Console.WriteLine ("Switching to " + num); CurrentMatch = Matches.ElementAt (num); UI.Scoreboard (this.CurrentMatch); } else { Console.WriteLine ("No such game"); } }
public void AddNewMatch() { CurrentMatch = new Match (); Matches.Add (CurrentMatch); Console.WriteLine ("New Match " + (Matches.Count - 1)); }