Esempio n. 1
0
        public ActionResult Index()
        {
            using (var worldSimulator = new WorldSimulatorService())
            {
                var tournaments = worldSimulator.GetTournamentsWithResultsForToday();

                if (tournaments.Any())
                {
                    var results = tournaments.Select(t =>
                        new TournamentResults
                        {
                            Tournament = t,
                            MatchResults = worldSimulator.GetTodayMatchResults(t.Id),
                            TeamStats = worldSimulator.GetLeagueStandings(t.Id)
                        });

                    var model = new TournamentResultsModel
                    {
                        CurrentDate = worldSimulator.GetCurrentDate(),
                        TournamentResults = results
                    };

                    return View(model);
                }
                else
                {
                    return View();
                }
            }
        }
        private void PlayTournament(WorldSimulatorService worldSimulator, DateTime date, Tournament tournament)
        {
            Console.Clear();
            Console.WriteLine("{0,-59} {1,59}", tournament.Name, date.ToLongDateString());
            Console.WriteLine();

            while (worldSimulator.PlayNextTodayFixture(tournament.Id))
            {
                var result = worldSimulator.GetLastMatchResult(tournament.Id);
                PrintMatchResult(result);
            }

            var standings = worldSimulator.GetLeagueStandings(tournament.Id);

            if (standings.Any())
            {
                Console.WriteLine();
                PrintStandings(standings);
            }
            else
            {
                standings = worldSimulator.GetCupGroupStageStandings(tournament.Id);

                if (standings.Any())
                {
                    Console.WriteLine();
                    PrintStandings(standings);
                }
            }

            if (date >= nextPauseDate)
            {
                Console.ReadLine();
            }

            Console.WriteLine("Top rated:");
            PrintPlayerStats(worldSimulator.GetTopPlayerStats(tournament.Id, 20));
            Console.WriteLine();

            Console.WriteLine("Top scorers:");
            PrintPlayerStats(worldSimulator.GetTopGoalScorers(tournament.Id, 10));
            Console.WriteLine();

            Console.WriteLine("Top assistants:");
            PrintPlayerStats(worldSimulator.GetTopAssistants(tournament.Id, 10));
            Console.WriteLine();

            Console.WriteLine();
        }