Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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 ("---------------------------");
        }
Exemple #3
0
 public static void DisplayHistory(Match match)
 {
     History.MatchHistory (match).ForEach (set => set.ForEach (game => game.ForEach (score => Console.WriteLine (score))));
 }
Exemple #4
0
 public static bool IsOver(Match match)
 {
     return Match.CurrentScore (match).HasMin (Settings.MinSets);
 }
Exemple #5
0
 public static Score CurrentScore(Match match)
 {
     return Score.SumOfWins (match.Sets.Where (s => s.IsOver ()).Select (s => s.CurrentScore ()).ToList ());
 }
Exemple #6
0
 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 ();
 }
Exemple #7
0
 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");
     }
 }
Exemple #8
0
 public void AddNewMatch()
 {
     CurrentMatch = new Match ();
     Matches.Add (CurrentMatch);
     Console.WriteLine ("New Match " + (Matches.Count - 1));
 }