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(); } } }
public void Perform() { using (var worldSimulator = new WorldSimulatorService()) { nextPauseDate = worldSimulator.GetCurrentDate(); } while (true) { using (var worldSimulator = new WorldSimulatorService()) { DateTime date = worldSimulator.GetCurrentDate(); var tournaments = worldSimulator.GetTournamentsWithFixturesForToday().OrderBy(t => t.Level).ToArray(); foreach (var tournament in tournaments) { PlayTournament(worldSimulator, date, tournament); if (date >= nextPauseDate) { Console.Write("> "); string answer = Console.ReadLine(); int weeks = 0; if (int.TryParse(answer, out weeks)) { nextPauseDate = date.AddDays(7 * weeks); } else { nextPauseDate = date; } } } } using (var worldSimulator = new WorldSimulatorService()) { if (worldSimulator.IsSeasonEnd()) { worldSimulator.AdvanceSeason(); } else { worldSimulator.AdvanceDate(); } } } }
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(); }