public void ShouldReturnNullGameById()
        {
            // Arrange
            var db = GetDatebase();

            var league = new League {
                Id = 1, Country = "Uk", Name = "Premier league", Year = "2018", Stage = ""
            };
            var team = new Team {
                Id = 2, Name = "Man Utd", UniqueName = "Manchester United"
            };

            var firstGame = new FootballGame {
                Id = 1, MatchDate = DateTime.UtcNow, League = league, HomeTeam = team, AwayTeam = team
            };

            db.AddRange(firstGame);
            db.SaveChanges();

            var gameService = new GameService(db);
            // Act
            var result = gameService.ById(4);

            // Assert
            result
            .Should()
            .BeNull();
        }
Exemple #2
0
        private static FootballGame SetWinningAndLossingTeams(FootballGame thisGame)
        {
            var awayScore = thisGame.awayTeamScore;
            var homeScore = thisGame.homeTeamScore;

            if (awayScore != null && homeScore != null)
            {
                if (awayScore > homeScore)//away team wins
                {
                    thisGame.winningTeamId = thisGame.awayTeam.teamId;
                    thisGame.lossingTeamId = thisGame.homeTeam.teamId;
                }
                else if (homeScore > awayScore)//home team wins
                {
                    thisGame.winningTeamId = thisGame.homeTeam.teamId;
                    thisGame.lossingTeamId = thisGame.awayTeam.teamId;
                }

                if (awayScore == homeScore)
                {
                    thisGame.winningTeamId = -1; //tie
                    thisGame.lossingTeamId = -1;
                }
            }
            return(thisGame);
        }
        public void Setup()
        {
            string refreshToken = ConfigurationManager.AppSettings["Deersport.RefreshToken"];
            SportDeerEventCollector collector = new SportDeerEventCollector(refreshToken);
            Service service = new Service(collector, new TweetinviConnector(), new FootballGameRepository(), new TweetRepository());

            _footballGame = service.Create(new GameId("Marseille", "Lyon", "Ligue 1"));
            _footballGame.GetGoals().ForEach(Console.WriteLine);
        }
        private static FootballGameEntity ConvertToEntity(FootballGame game)
        {
            var gameEntity = new FootballGameEntity
            {
                AwayTeam = game.AwayTeam,
                HomeTeam = game.HomeTeam,
                League   = game.League
            };

            return(gameEntity);
        }
Exemple #5
0
        internal static void SubmitGameScores(FootballPoolViewModel thisVW)
        {
            ApplicationDbContext _db = new ApplicationDbContext();

            foreach (var game in thisVW.footballGames)
            {
                FootballGame thisGame = _db.FootballGame.Where(g => g.gameId == game.gameId).FirstOrDefault();
                thisGame.awayTeamScore = game.awayTeamScore;
                thisGame.homeTeamScore = game.homeTeamScore;
                //determine winning column
                thisGame = SetWinningAndLossingTeams(thisGame);
                _db.Entry(thisGame).State = System.Data.Entity.EntityState.Modified;
                _db.SaveChanges();
            }
        }
Exemple #6
0
        public void PersistGame()
        {
            var    gameId       = new GameId("Lyon", "Toulouse", "Ligue 1");
            var    footballGame = new FootballGameWithEvent(gameId);
            string refreshToken = ConfigurationManager.AppSettings["Deersport.RefreshToken"];

            var service = new Service(new SportDeerEventCollector(refreshToken), new TweetinviConnector(), new FootballGameRepository(), new TweetRepository());
            var sut     = new FootballGameRepository();

            service.Create(new GameId("Lyon", "Toulouse", "Ligue 1"));

            sut.Save(footballGame);

            FootballGame game = sut.Find(new GameId("Lyon", "Toulouse", "Ligue 1"));
        }
Exemple #7
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FootballGame = await _context.FootballGames.FirstOrDefaultAsync(m => m.Id == id);

            if (FootballGame == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemple #8
0
        public void GetScoreInProgressRequestedTeamLosingTest()
        {
            Dictionary <String, String> input = new Dictionary <string, string>
            {
                { "Command", "Football" },
                { "Team", "TestTeam" },
                { "Parameter", "Score" },
            };

            // Setup teams.
            FootballTeam requestedTeam  = new FootballTeam("Test", "Team", "TestTeam");
            FootballTeam oppositionTeam = new FootballTeam("Test 2", "Teams 2", "TestTeam2");

            // Setup game.
            FootballGame game = new FootballGame();

            game.State         = GameState.Started;
            game.HomeTeamScore = new FootballTeamScore()
            {
                Score = 7,
                Team  = requestedTeam
            };
            game.AwayTeamScore = new FootballTeamScore()
            {
                Score = 14,
                Team  = oppositionTeam,
            };
            game.StartingTime = new DateTime(2014, 11, 30, 13, 0, 0);

            // Setup mock.
            Mock <IFootballSensor> sensor = new Mock <IFootballSensor>(MockBehavior.Strict);

            sensor.Setup(s => s.IsValid).Returns(true);
            sensor.Setup(s => s.Teams).Returns(new List <FootballTeam>
            {
                requestedTeam,
                oppositionTeam,
            });
            sensor.Setup(s => s.LoadLatestScoreForTeam("TestTeam")).Returns(game);
            AddComponentToConfigurationManager(sensor.Object);

            // Run test
            String response = RunSingleConversation <FootballConversation>(input);

            Assert.IsTrue(response.StartsWith("The Team are losing to the Teams 2 by a score of 14 to 7. "), response);
            sensor.Verify(s => s.Teams, Times.Exactly(2));
            sensor.Verify(s => s.LoadLatestScoreForTeam("TestTeam"), Times.Exactly(1));
        }
Exemple #9
0
        public void GetScoreInProgressStartOfQuarterTest()
        {
            Dictionary <String, String> input = new Dictionary <string, string>
            {
                { "Command", "Football" },
                { "Team", "TestTeam" },
                { "Parameter", "Score" },
            };

            // Setup teams.
            FootballTeam requestedTeam  = new FootballTeam("Test", "Team", "TestTeam");
            FootballTeam oppositionTeam = new FootballTeam("Test 2", "Teams 2", "TestTeam2");

            // Setup game.
            FootballGame game = new FootballGame();

            game.State         = GameState.Started;
            game.HomeTeamScore = new FootballTeamScore()
            {
                Score = 14,
                Team  = requestedTeam
            };
            game.AwayTeamScore = new FootballTeamScore()
            {
                Score = 14,
                Team  = oppositionTeam,
            };
            game.StartingTime = new DateTime(2014, 11, 30, 13, 0, 0);
            game.Quarter      = 2;
            game.TimeLeft     = new TimeSpan(0, 15, 0);

            // Setup mock.
            Mock <IFootballSensor> sensor = new Mock <IFootballSensor>(MockBehavior.Strict);

            sensor.Setup(s => s.IsValid).Returns(true);
            sensor.Setup(s => s.Teams).Returns(new List <FootballTeam>
            {
                requestedTeam,
                oppositionTeam,
            });
            sensor.Setup(s => s.LoadLatestScoreForTeam("TestTeam")).Returns(game);
            AddComponentToConfigurationManager(sensor.Object);

            // Run test
            Assert.IsTrue(RunSingleConversation <FootballConversation>(input).EndsWith("at the beginning of the second quarter."));
            sensor.Verify(s => s.Teams, Times.Exactly(2));
            sensor.Verify(s => s.LoadLatestScoreForTeam("TestTeam"), Times.Exactly(1));
        }
Exemple #10
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FootballGame = await _context.FootballGames.FindAsync(id);

            if (FootballGame != null)
            {
                _context.FootballGames.Remove(FootballGame);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemple #11
0
        public List <Tweet> CollectTweets(FootballGame game, string hashtag)
        {
            TimeSpan oneHour = TimeSpan.FromHours(1);

            var tweets = game.BuildQueriesGame(hashtag)
                         .Select(SearchTweet)
                         .SelectMany(x => x)
                         .Distinct()
                         .ToList();

            return(tweets
                   .Select(CreateTweet)
                   .Where(x =>
                          x.Date > game.MatchStart.Subtract(oneHour) &&
                          x.Date < game.MatchStop.Add(oneHour))
                   .ToList());
        }
Exemple #12
0
        public void GetScoreHasntStartedRequestedTeamHomeTest()
        {
            Dictionary <String, String> input = new Dictionary <string, string>
            {
                { "Command", "Football" },
                { "Team", "TestTeam" },
                { "Parameter", "Score" },
            };

            // Setup teams.
            FootballTeam requestedTeam  = new FootballTeam("Test", "Team", "TestTeam");
            FootballTeam oppositionTeam = new FootballTeam("Test 2", "Teams 2", "TestTeam2");

            // Setup game.
            FootballGame game = new FootballGame();

            game.State         = GameState.GameHasntStarted;
            game.HomeTeamScore = new FootballTeamScore()
            {
                Score = 0,
                Team  = requestedTeam
            };
            game.AwayTeamScore = new FootballTeamScore()
            {
                Score = 0,
                Team  = oppositionTeam,
            };
            game.StartingTime = new DateTime(2014, 11, 30, 13, 0, 0);

            // Setup mock.
            Mock <IFootballSensor> sensor = new Mock <IFootballSensor>(MockBehavior.Strict);

            sensor.Setup(s => s.IsValid).Returns(true);
            sensor.Setup(s => s.Teams).Returns(new List <FootballTeam>
            {
                requestedTeam,
                oppositionTeam,
            });
            sensor.Setup(s => s.LoadLatestScoreForTeam("TestTeam")).Returns(game);
            AddComponentToConfigurationManager(sensor.Object);

            // Run test
            Assert.AreEqual("The Team will be playing the Teams 2 at 1:00 PM on Sunday.", RunSingleConversation <FootballConversation>(input));
            sensor.Verify(s => s.Teams, Times.Exactly(2));
            sensor.Verify(s => s.LoadLatestScoreForTeam("TestTeam"), Times.Exactly(1));
        }
        public void ShouldReturnNextGamesAndOrder()
        {
            // Arrange
            var db = GetDatebase();

            var league = new League {
                Id = 1, Country = "Uk", Name = "Premier league", Year = "2018", Stage = ""
            };
            var team = new Team {
                Id = 1, Name = "Man Utd", UniqueName = "Manchester United"
            };

            var firstGame = new FootballGame {
                Id = 1, MatchDate = DateTime.UtcNow, League = league, HomeTeam = team, AwayTeam = team
            };
            var secondGame = new FootballGame {
                Id = 2, MatchDate = DateTime.UtcNow, League = league, HomeTeam = team, AwayTeam = team, FullTimeResult = new GameResult {
                    Id = 2, Result = ResultEnum.H, HomeTeamGoals = 3, AwayTeamGoals = 1
                }
            };
            var thirdGame = new FootballGame {
                Id = 3, MatchDate = DateTime.UtcNow.AddDays(1), League = league, HomeTeam = team, AwayTeam = team
            };
            var fourthGame = new FootballGame {
                Id = 4, MatchDate = DateTime.UtcNow.AddDays(1), League = league, HomeTeam = team, AwayTeam = team, FullTimeResult = new GameResult {
                    Id = 1, Result = ResultEnum.H, HomeTeamGoals = 3, AwayTeamGoals = 1
                }
            };

            db.AddRange(firstGame, secondGame, thirdGame, fourthGame);
            db.SaveChanges();

            var gameService = new GameService(db);
            // Act
            var result = gameService.Next();

            // Assert
            result
            .Should()
            .Match(r =>
                   r.ElementAt(0).Id == 3 &&
                   r.ElementAt(1).Id == 1)
            .And
            .HaveCount(2);
        }
        public void Save(FootballGame game)
        {
            UnitOfWork(c =>
            {
                if (Find(game.GameId) != FootballGame.Null)
                {
                    throw new ApplicationException("a game with this data already exist");
                }

                var gameEntity = ConvertToEntity(game);
                gameEntity     = c.FootballGames.Add(gameEntity);

                c.SaveChanges();

                var events = game.Events
                             .Select(@event => ConvertToEventData(gameEntity, @event))
                             .ToList();

                c.EventDatas.AddRange(events);
            });
        }
 public IndexModel(TeamOrganiser.Data.ApplicationDbContext context, UserManager <IdentityUser> userManager)
 {
     _context     = context;
     _userManager = userManager;
     FootballGame = new FootballGame();
 }
Exemple #16
0
        public IEnumerable <FootballGame> LoadAllScores()
        {
            String jsonResults = GetJsonScores();

            while (jsonResults.Contains(",,"))
            {
                jsonResults = jsonResults.Replace(",,", ",\"\",");
            }
            var movieJson = DynamicJson.Parse(jsonResults);

            foreach (var game in movieJson.ss)
            {
                FootballTeamScore awayTeam = new FootballTeamScore()
                {
                    Team = Teams.Single(t => t.Key.Equals(game[4])),
                };
                awayTeam.Score = String.IsNullOrEmpty(game[5]) ? 0 : Int32.Parse(game[5]);
                FootballTeamScore homeTeam = new FootballTeamScore()
                {
                    Team = Teams.Single(t => t.Key.Equals(game[6])),
                };
                homeTeam.Score = String.IsNullOrEmpty(game[7]) ? 0 : Int32.Parse(game[7]);
                FootballGame parsedGame = new FootballGame()
                {
                    State         = GameState.GameHasntStarted,
                    HomeTeamScore = awayTeam,
                    AwayTeamScore = homeTeam,
                };

                DateTime  day = DateTime.Now;
                DayOfWeek desiredDayOfWeek = GetDayOfWeek(game[0]);
                switch (game[2] as String)
                {
                case "Pregame":
                    parsedGame.State = GameState.GameHasntStarted;
                    while (day.DayOfWeek != desiredDayOfWeek)
                    {
                        day = day.AddDays(1);
                    }
                    parsedGame.StartingTime = GetStartingTime(game[1], day);
                    break;

                case "Final":
                    parsedGame.State = GameState.Completed;
                    while (day.DayOfWeek != desiredDayOfWeek)
                    {
                        day = day.AddDays(-1);
                    }
                    parsedGame.StartingTime = GetStartingTime(game[1], day);
                    break;

                case "1":
                case "2":
                case "3":
                case "4":
                    parsedGame.State        = GameState.Started;
                    parsedGame.Quarter      = Int32.Parse(game[2]);
                    parsedGame.StartingTime = GetStartingTime(game[1], DateTime.Today);
                    String[] timeLeft = (game[3] as String).Split(':');
                    parsedGame.TimeLeft = new TimeSpan(0, Int32.Parse(timeLeft[0]), Int32.Parse(timeLeft[1]));
                    break;

                default:
                    break;
                }
                yield return(parsedGame);
            }
        }
Exemple #17
0
        private void AddLastGamesForUpdateToDb(List <FootballGameBM> lastGamesForUpdate)
        {
            foreach (var game in lastGamesForUpdate)
            {
                var existGame = this.db
                                .FootballGames
                                .Where(g =>
                                       (g.MatchDate.Date == game.MatchDate.Date) &&
                                       (g.HomeTeam.UniqueName == game.HomeTeam.UniqueName) &&
                                       (g.AwayTeam.UniqueName == game.AwayTeam.UniqueName) &&
                                       (g.League.Name == game.League.Name))
                                .FirstOrDefault();

                if (existGame == null)
                {
                    // Add home team to the DB and to current game
                    var homeTeam = this.db
                                   .Teams
                                   .Where(t => t.UniqueName == game.HomeTeam.UniqueName)
                                   .FirstOrDefault();

                    if (homeTeam == null)
                    {
                        homeTeam = new Team
                        {
                            Name       = game.HomeTeam.Name,
                            UniqueName = game.HomeTeam.UniqueName
                        };

                        this.db.Add(homeTeam);
                        this.db.SaveChanges();
                    }

                    // Add away team to the DB and to current game
                    var awayTeam = this.db
                                   .Teams
                                   .Where(t => t.UniqueName == game.AwayTeam.UniqueName)
                                   .FirstOrDefault();

                    if (awayTeam == null)
                    {
                        awayTeam = new Team
                        {
                            Name       = game.AwayTeam.Name,
                            UniqueName = game.AwayTeam.UniqueName
                        };

                        this.db.Add(awayTeam);
                        this.db.SaveChanges();
                    }


                    // Add league to the DB and to current game
                    var league = this.db
                                 .Leagues
                                 .Where(l => l.UniqueName == game.League.UniqueName)
                                 .FirstOrDefault();

                    if (league == null)
                    {
                        league = new League
                        {
                            Name       = game.League.Name,
                            Country    = game.League.Country,
                            Year       = game.League.Year,
                            Stage      = game.League.Stage,
                            Type       = game.League.Type,
                            UniqueName = game.League.UniqueName
                        };

                        this.db.Add(league);
                        this.db.SaveChanges();
                    }

                    // Add current game
                    existGame = new FootballGame
                    {
                        MatchDate  = game.MatchDate,
                        LeagueId   = league.Id,
                        League     = league,
                        HomeTeamId = homeTeam.Id,
                        HomeTeam   = homeTeam,
                        AwayTeamId = awayTeam.Id,
                        AwayTeam   = awayTeam
                    };

                    this.db.Add(existGame);
                    this.db.SaveChanges();

                    league.Games.Add(existGame);

                    this.db.SaveChanges();
                }

                // Add full time result to the DB and to current game
                if (game.FullTimeResult != null)
                {
                    GameResult fullTimeResult = new GameResult
                    {
                        Result        = game.FullTimeResult.Result,
                        HomeTeamGoals = game.FullTimeResult.HomeTeamGoals,
                        AwayTeamGoals = game.FullTimeResult.AwayTeamGoals
                    };

                    this.db.Add(fullTimeResult);
                    this.db.SaveChanges();

                    existGame.FullTimeResult   = fullTimeResult;
                    existGame.FullTimeResultId = fullTimeResult.Id;
                }

                // Add first time result to the DB and to current game
                if (game.FirstHalfResult != null)
                {
                    GameResult firstHalf = new GameResult
                    {
                        Result        = game.FirstHalfResult.Result,
                        HomeTeamGoals = game.FirstHalfResult.HomeTeamGoals,
                        AwayTeamGoals = game.FirstHalfResult.AwayTeamGoals
                    };

                    this.db.Add(firstHalf);
                    this.db.SaveChanges();

                    existGame.FirstHalfResult   = firstHalf;
                    existGame.FirstHalfResultId = firstHalf.Id;
                }

                // Add game statistic to the DB and to current game
                if (game.GameStatistic != null)
                {
                    GameStatistic gameStatistic = new GameStatistic
                    {
                        HomeTeamCorners       = game.GameStatistic.HomeTeamCorners,
                        AwayTeamCorners       = game.GameStatistic.AwayTeamCorners,
                        HomeTeamShotsOnTarget = game.GameStatistic.HomeTeamShotsOnTarget,
                        AwayTeamShotsOnTarget = game.GameStatistic.AwayTeamShotsOnTarget,
                        HomeTeamShotsWide     = game.GameStatistic.HomeTeamShotsWide,
                        AwayTeamShotsWide     = game.GameStatistic.AwayTeamShotsWide,
                        HomeTeamFouls         = game.GameStatistic.HomeTeamFouls,
                        AwayTeamFouls         = game.GameStatistic.AwayTeamFouls,
                        HomeTeamOffsides      = game.GameStatistic.HomeTeamOffsides,
                        AwayTeamOffsides      = game.GameStatistic.AwayTeamOffsides
                    };

                    this.db.Add(gameStatistic);
                    this.db.SaveChanges();

                    existGame.GameStatistic   = gameStatistic;
                    existGame.GameStatisticId = gameStatistic.Id;
                }

                this.db.SaveChanges();
            }
        }
Exemple #18
0
        private void AddOldGamesToDb(List <FootballGameBM> lastGamesForUpdate)
        {
            foreach (var game in lastGamesForUpdate)
            {
                this.db.ChangeTracker.AutoDetectChangesEnabled = false;

                // Add home team to the DB and to current game
                var homeTeam = this.db
                               .Teams
                               .Where(t => t.UniqueName == game.HomeTeam.UniqueName)
                               .FirstOrDefault();

                if (homeTeam == null)
                {
                    homeTeam = new Team
                    {
                        Name       = game.HomeTeam.Name,
                        UniqueName = game.HomeTeam.UniqueName
                    };

                    this.db.AddRange(homeTeam);
                    this.db.SaveChanges();
                }

                // Add away team to the DB and to current game
                var awayTeam = this.db
                               .Teams
                               .Where(t => t.UniqueName == game.AwayTeam.UniqueName)
                               .FirstOrDefault();

                if (awayTeam == null)
                {
                    awayTeam = new Team
                    {
                        Name       = game.AwayTeam.Name,
                        UniqueName = game.AwayTeam.UniqueName
                    };

                    this.db.AddRange(awayTeam);
                    this.db.SaveChanges();
                }


                // Add league to the DB and to current game
                var league = this.db
                             .Leagues
                             .Where(l => l.UniqueName == game.League.UniqueName)
                             .FirstOrDefault();

                if (league == null)
                {
                    league = new League
                    {
                        Name       = game.League.Name,
                        Country    = game.League.Country,
                        Year       = game.League.Year,
                        Stage      = game.League.Stage,
                        Type       = game.League.Type,
                        UniqueName = game.League.UniqueName
                    };

                    this.db.AddRange(league);
                    this.db.SaveChanges();
                }

                GameResult fullTimeResult = null;
                if (game.FullTimeResult != null)
                {
                    fullTimeResult = new GameResult
                    {
                        Result        = game.FullTimeResult.Result,
                        HomeTeamGoals = game.FullTimeResult.HomeTeamGoals,
                        AwayTeamGoals = game.FullTimeResult.AwayTeamGoals
                    };

                    this.db.AddRange(fullTimeResult);
                    this.db.SaveChanges();
                }

                GameResult firstHalf = null;
                // Add first time result to the DB and to current game
                if (game.FirstHalfResult != null)
                {
                    firstHalf = new GameResult
                    {
                        Result        = game.FirstHalfResult.Result,
                        HomeTeamGoals = game.FirstHalfResult.HomeTeamGoals,
                        AwayTeamGoals = game.FirstHalfResult.AwayTeamGoals
                    };

                    this.db.AddRange(firstHalf);
                    this.db.SaveChanges();
                }

                GameStatistic gameStatistic = null;
                // Add game statistic to the DB and to current game
                if (game.GameStatistic != null)
                {
                    gameStatistic = new GameStatistic
                    {
                        HomeTeamCorners       = game.GameStatistic.HomeTeamCorners,
                        AwayTeamCorners       = game.GameStatistic.AwayTeamCorners,
                        HomeTeamShotsOnTarget = game.GameStatistic.HomeTeamShotsOnTarget,
                        AwayTeamShotsOnTarget = game.GameStatistic.AwayTeamShotsOnTarget,
                        HomeTeamShotsWide     = game.GameStatistic.HomeTeamShotsWide,
                        AwayTeamShotsWide     = game.GameStatistic.AwayTeamShotsWide,
                        HomeTeamFouls         = game.GameStatistic.HomeTeamFouls,
                        AwayTeamFouls         = game.GameStatistic.AwayTeamFouls,
                        HomeTeamOffsides      = game.GameStatistic.HomeTeamOffsides,
                        AwayTeamOffsides      = game.GameStatistic.AwayTeamOffsides
                    };

                    this.db.AddRange(gameStatistic);
                    this.db.SaveChanges();
                }

                // Add current game
                var existGame = new FootballGame
                {
                    MatchDate       = game.MatchDate,
                    League          = league,
                    HomeTeam        = homeTeam,
                    AwayTeam        = awayTeam,
                    FullTimeResult  = fullTimeResult,
                    FirstHalfResult = firstHalf,
                    GameStatistic   = gameStatistic
                };

                this.db.AddRange(existGame);
                this.db.SaveChanges();


                // Add full time result to the DB and to current game


                this.db.SaveChanges();
            }
        }
Exemple #19
0
        private String RespondToGameScore(IFootballSensor sensor, FootballTeam team)
        {
            FootballGame score = sensor.LoadLatestScoreForTeam(team.Key);

            if (score == null)
            {
                return(String.Format("The {0} are not playing this week.", team.Name));
            }

            String startingPhrase = String.Empty;

            switch (score.State)
            {
            case GameState.Started:
                if (score.WinningTeamScore.Score == score.LosingTeamScore.Score)
                {
                    if (score.WinningTeamScore.Team.Equals(team))
                    {
                        startingPhrase = String.Format("The {0} and the {1} are tied at {2} a piece. ", team.Name, score.LosingTeamScore.Team.Name, score.WinningTeamScore.Score);
                    }
                    else
                    {
                        startingPhrase = String.Format("The {0} and the {1} are tied at {2} a piece. ", team.Name, score.WinningTeamScore.Team.Name, score.WinningTeamScore.Score);
                    }
                }
                else if (score.WinningTeamScore.Team.Equals(team))
                {
                    startingPhrase = String.Format("The {0} are beating the {1} by a score of {2} to {3}. ", team.Name, score.LosingTeamScore.Team.Name, score.WinningTeamScore.Score, score.LosingTeamScore.Score);
                }
                else
                {
                    startingPhrase = String.Format("The {0} are losing to the {1} by a score of {2} to {3}. ", team.Name, score.WinningTeamScore.Team.Name, score.WinningTeamScore.Score, score.LosingTeamScore.Score);
                }

                String quarterNum = SayOrdinal(score.Quarter);
                if (score.TimeLeft.Equals(TimeSpan.Zero))
                {
                    startingPhrase += String.Format("at the end of the {0} quarter.", quarterNum);
                }
                else if (score.TimeLeft.Equals(new TimeSpan(0, 15, 0)))
                {
                    startingPhrase += String.Format("at the beginning of the {0} quarter.", quarterNum);
                }
                else
                {
                    startingPhrase += String.Format("with {0} {1} remaining in the {2} quarter.", score.TimeLeft.Minutes, score.TimeLeft.Seconds, quarterNum);
                }
                break;

            case GameState.GameHasntStarted:
                if (score.HomeTeamScore.Team.Equals(team))
                {
                    startingPhrase = String.Format("The {0} will be playing the {1} at {2} on {3}.", team.Name, score.AwayTeamScore.Team.Name, score.StartingTime.ToShortTimeString(), score.StartingTime.DayOfWeek.ToString());
                }
                else
                {
                    startingPhrase = String.Format("The {0} will be playing the {1} at {2} on {3}.", team.Name, score.HomeTeamScore.Team.Name, score.StartingTime.ToShortTimeString(), score.StartingTime.DayOfWeek.ToString());
                }
                break;

            case GameState.Completed:
                if (score.WinningTeamScore.Team.Equals(team))
                {
                    startingPhrase = String.Format("The {0} beat the {1} by a score of {2} to {3}.", team.Name, score.LosingTeamScore.Team.Name, score.WinningTeamScore.Score, score.LosingTeamScore.Score);
                }
                else
                {
                    startingPhrase = String.Format("The {0} lost to the {1} by a score of {2} to {3}.", team.Name, score.WinningTeamScore.Team.Name, score.WinningTeamScore.Score, score.LosingTeamScore.Score);
                }
                break;
            }
            return(startingPhrase);
        }
        public CityEvent GetEventForBuilding(ref Building thisBuilding)
        {
            CityEvent buildingEvent = null;

            if (!Experiments.ExperimentsToggle.UseXMLEvents)
            {
                switch (thisBuilding.Info.name)
                {
                case "Modern Art Museum":
                    buildingEvent = new ArtExhibit();
                    break;

                case "Grand Mall":
                    buildingEvent = new ShopOpening();
                    break;

                case "Library":
                    buildingEvent = new BookSigning();
                    break;

                case "ExpoCenter":
                    switch (Singleton <SimulationManager> .instance.m_randomizer.Int32(5))
                    {
                    case 0:
                        buildingEvent = new BusinessExpo();
                        break;

                    case 1:
                        buildingEvent = new CaravanExpo();
                        break;

                    case 2:
                        buildingEvent = new ComicExpo();
                        break;

                    case 3:
                        buildingEvent = new ElectronicExpo();
                        break;

                    case 4:
                        buildingEvent = new GameExpo();
                        break;
                    }
                    break;

                case "Stadium":
                    buildingEvent = new FootballGame();
                    break;

                case "Opera House":
                    buildingEvent = new OperaEvent();
                    break;

                case "Posh Mall":
                    buildingEvent = new ShopOpening();
                    break;

                case "Observatory":
                    //coming soon
                    break;

                case "Official Park":
                    //buildingEvent = new Memorial();
                    break;

                case "Theater of Wonders":
                    buildingEvent = new TheaterEvent();
                    break;

                case "Trash Mall":
                    buildingEvent = new ShopOpening();
                    break;

                case "SeaWorld":
                    buildingEvent = new AquariumEvent();
                    break;
                }
            }
            else
            {
                buildingEvent = GetEventForBuilding(ref thisBuilding, CityEventManager.instance.m_xmlEvents);
            }

            return(buildingEvent);
        }