Esempio n. 1
0
        public void GameScore(Game game, TournamentCategory category)
        {
            Console.WriteLine("\nWrite scored points by team {0}:", game.HomeTeam.Name);
            int homePoints = StaticMethods.ReadNumber("");

            game.HomePoints = homePoints;

            Console.WriteLine("\nWrite scored points by team {0}:", game.AwayTeam.Name);
            int awayPoints = StaticMethods.ReadNumber("");

            game.AwayPoints = awayPoints;

            game.Winner = homePoints > awayPoints ? game.HomeTeam : game.AwayTeam;
            game.Winner.GamesWin++;
            game.HomeTeam.GamesPlayed++;
            game.AwayTeam.GamesPlayed++;
            game.HomeTeam.PointsScored += homePoints;
            game.AwayTeam.PointsScored += awayPoints;
            game.Played = true;

            game.HomeTeam.PlayerScore(homePoints, game.GetHomePlayersPoints());
            game.AwayTeam.PlayerScore(awayPoints, game.GetAwayPlayersPoints());

            if (category.System == TournamentSystem.FirstLossOut)
            {
                category.TeamAdvance(game.Winner);
            }
        }
Esempio n. 2
0
        public void AddResult()
        {
            TournamentCategory category = ReadCategory("\nWrite name of category where you want to add result of game:");

            bool   done = false;
            string gameName;

            while (!done)
            {
                Console.WriteLine("\n'0' - Cancel adding result");
                Console.WriteLine("'1' - Choose game by number of game");
                Console.WriteLine("'2' - Choose game by opponents");
                Console.WriteLine("'3' - Print schedule of games");
                gameName = Console.ReadLine();

                if (gameName.Length != 0)
                {
                    switch (gameName[0])
                    {
                    case '1': GameResultByNumber(category); break;

                    case '2': GameResultByOpponents(category); break;

                    case '3': category.PrintSchedule(); break;

                    case '0': done = true; break;

                    default: Console.WriteLine("Wrong input!"); break;
                    }
                }
            }
        }
Esempio n. 3
0
 public bool AddCategory(TournamentCategory category)
 {
     if (!HasCategory(category.CategoryName))
     {
         categories.Add(category);
         return(true);
     }
     return(false);
 }
Esempio n. 4
0
        public void PrintTable()
        {
            TournamentCategory category = ReadCategory("\nWrite name of category where you want to print table:");

            if (category.System == Enum.TournamentSystem.FirstLossOut)
            {
                Console.WriteLine("This category does not have table!");
                return;
            }
            category.PrintTable();
        }
Esempio n. 5
0
        public void DrawNextRound()
        {
            TournamentCategory category = ReadCategory("\nWrite name of category where you want to draw next round:");

            if (category.System == Enum.TournamentSystem.EveryoneWithEveryone)
            {
                Console.WriteLine("This category does not have rounds!");
                return;
            }
            category.SetNextRoundFirstLossOut();
        }
Esempio n. 6
0
        public async Task ExportSpider()
        {
            TournamentCategory category = ReadCategory("\nWrite name of category where you want to export spider:");

            if (category.System == Enum.TournamentSystem.EveryoneWithEveryone)
            {
                Console.WriteLine("This category does not have rounds!");
                return;
            }
            await category.ExportSpider();
        }
Esempio n. 7
0
        public void GameResultByNumber(TournamentCategory category)
        {
            Game game;

            while (true)
            {
                Console.WriteLine();
                int numberOfGame = StaticMethods.ReadNumber("Write number of game:");
                if (category.CanAddResult(numberOfGame))
                {
                    game = category.GetGame(numberOfGame);
                    break;
                }
            }
            if (game.Played)
            {
                Console.WriteLine("\nGame #{0} {1} vs. {2} is played", game.NumberOfMatch, game.HomeTeam.Name, game.AwayTeam.Name);
                return;
            }
            GameScore(game, category);
        }
Esempio n. 8
0
        public void GameResultByOpponents(TournamentCategory category)
        {
            Game game;

            while (true)
            {
                Console.WriteLine("\nWrite name of first team: ");
                string first = Console.ReadLine();
                Console.WriteLine("\nWrite name of second team: ");
                string second = Console.ReadLine();
                if (category.CanAddResult(first, second))
                {
                    game = category.GetGame(first, second);
                    break;
                }
            }
            if (game.Played)
            {
                Console.WriteLine("\nGame #{0} {1} vs. {2} is played", game.NumberOfMatch, game.HomeTeam.Name, game.AwayTeam.Name);
                return;
            }
            GameScore(game, category);
        }
Esempio n. 9
0
        public void PrintSchedule()
        {
            TournamentCategory category = ReadCategory("\nWrite name of category where you want to print Schedule:");

            category.PrintSchedule();
        }