Ejemplo n.º 1
0
        public void Clean()
        {
            HomeTeam = HomeTeam.Trim();
            AwayTeam = AwayTeam.Trim();

            var timeSplit = KickOffTimeString.Split(':');

            KickOffHours    = int.Parse(timeSplit[0]);
            KickOffMintutes = int.Parse(timeSplit[1]);

            var scoreSplit = Score.Replace(" - ", "-").Split('-');

            HomeTeamScore = int.Parse(scoreSplit[0]);
            AwayTeamScore = int.Parse(scoreSplit[1]);

            if (League == "Barclays Prem")
            {
                LeagueEnum = Model.LeagueEnum.Premier;
            }
            else if (League == "Sky Bet Ch'ship")
            {
                LeagueEnum = Model.LeagueEnum.Championship;
            }
            else if (League == "Sky Bet League 1")
            {
                LeagueEnum = Model.LeagueEnum.League1;
            }
            else
            {
                LeagueEnum = Model.LeagueEnum.League2;
            }
        }
Ejemplo n.º 2
0
 private void NextInning()
 {
     if (HomeScore > AwayScore && Inning.Num >= 9)
     {
         EndGame();
         return;
     }
     else if (AwayScore > HomeScore && Inning.Num >= 9 && Inning.Half == Inning.Side.Bottom)
     {
         EndGame();
         return;
     }
     else
     {
         Inning++;
     }
     Outs = 0;
     ResetCount();
     ClearBases();
     if (Inning.Half == Inning.Side.Bottom)
     {
         HomeTeam.NextInning();
     }
     else
     {
         AwayTeam.NextInning();
     }
 }
Ejemplo n.º 3
0
 public void Play()
 {
     homeLineup = HomeTeam.ChooseLineupHungarian();
     awayLineup = AwayTeam.ChooseLineupHungarian();
     Stats      = new MatchFSM(HomeLineup, AwayLineup).Start();
     hasPlayed  = true;
 }
Ejemplo n.º 4
0
        private HomeTeam ParseHomeTeamNode(XmlNode homeTeamNode)
        {
            try
            {
                HomeTeam homeTeam = new HomeTeam();

                if (homeTeamNode.ChildNodes != null)
                {
                    foreach (XmlNode xmlNode in homeTeamNode.ChildNodes)
                    {
                        switch (xmlNode.Name)
                        {
                        case Tags.HomeTeamID:
                            homeTeam.homeTeamIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.HomeTeamName:
                            homeTeam.homeTeamNameField = xmlNode.InnerText;
                            break;
                        }
                    }
                }

                return(homeTeam);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        public ActionResult DeleteConfirmed(int id)
        {
            HomeTeam homeTeam = db.HomeTeams.Find(id);

            db.HomeTeams.Remove(homeTeam);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        internal IEnumerable <EventOfMatch> GetFullEventsOfMatch(IEnumerable <EventOfMatch> eventsList)
        {
            int homeScore = 0;
            int awayScore = 0;

            foreach (var eventOfMatch in eventsList ?? Enumerable.Empty <EventOfMatch>())
            {
                eventOfMatch.HomeTeamScore    = 0;
                eventOfMatch.AwayTeamScore    = 0;
                eventOfMatch.HomeTeam         = eventOfMatch?.EventTeam == HomeTeam ? HomeTeam : string.Empty;
                eventOfMatch.AwayTeam         = eventOfMatch?.EventTeam == AwayTeam ? AwayTeam : string.Empty;
                eventOfMatch.HomeMainPlayer   = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == HomeTeam.ToUpper().Trim() ? eventOfMatch?.MainPlayerOfMatchID : null);
                eventOfMatch.HomeSecondPlayer = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == HomeTeam.ToUpper().Trim() ? eventOfMatch?.SecondPlayerOfMatchID : null);
                eventOfMatch.AwayMainPlayer   = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == AwayTeam.ToUpper().Trim() ? eventOfMatch?.MainPlayerOfMatchID : null);
                eventOfMatch.AwaySecondPlayer = GetEventPlayer(eventOfMatch?.EventTeam.ToUpper().Trim() == AwayTeam.ToUpper().Trim() ? eventOfMatch?.SecondPlayerOfMatchID : null);


                eventOfMatch.HomeTeamVisible = eventOfMatch.HomeTeamVisible = !string.IsNullOrEmpty(eventOfMatch.HomeTeam);
                eventOfMatch.AwayTeamVisible = eventOfMatch.AwayTeamVisible = !string.IsNullOrEmpty(eventOfMatch.AwayTeam);

                if (IsGoal(eventOfMatch))
                {
                    if (eventOfMatch.EventTeam.ToUpper().Trim() == HomeTeam.ToUpper().Trim())
                    {
                        homeScore += 1;
                    }
                    if (eventOfMatch.EventTeam.ToUpper().Trim() == AwayTeam.ToUpper().Trim())
                    {
                        awayScore += 1;
                    }
                }
                eventOfMatch.HomeTeamScore = homeScore;
                eventOfMatch.AwayTeamScore = awayScore;

                if (eventOfMatch.EventName == "GOAL")
                {
                    int eventIndex = eventsList.ToList().IndexOf(eventOfMatch);
                    if (eventIndex + 1 < eventsList.Count())
                    {
                        EventOfMatch nextEvent = eventsList.ToList()[eventIndex + 1];
                        if (nextEvent.EventName == "ASSIST")
                        {
                            if (eventOfMatch.EventTeam.ToUpper().Trim() == HomeTeam.ToUpper().Trim())
                            {
                                eventOfMatch.HomeSecondPlayer = GetEventPlayer(nextEvent?.EventTeam.ToUpper().Trim() == HomeTeam.ToUpper().Trim() ? nextEvent?.MainPlayerOfMatchID : null);
                            }
                            if (eventOfMatch.EventTeam.ToUpper().Trim() == AwayTeam.ToUpper().Trim())
                            {
                                eventOfMatch.AwaySecondPlayer = GetEventPlayer(nextEvent?.EventTeam.ToUpper().Trim() == AwayTeam.ToUpper().Trim() ? nextEvent?.MainPlayerOfMatchID : null);
                            }
                        }
                    }
                }
            }

            return(eventsList);
        }
Ejemplo n.º 7
0
 public void ScoreGoalsHomeTeam(int goal)
 {
     HomeTeamGoals = goal;
     for (int i = 0; i < goal; i++)
     {
         HomeTeam.ScoreAGoal();
         VisitingTeam.Table.ScoreConcededGoals();
     }
 }
Ejemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "ID,ImagePath")] HomeTeam homeTeam)
 {
     if (ModelState.IsValid)
     {
         db.Entry(homeTeam).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(homeTeam));
 }
Ejemplo n.º 9
0
 public void ChangeSides()
 {
     if (Stats.IsFinished)
     {
         return;
     }
     Stats.ResetScore();
     HomeTeam.ChangeSides();
     AwayTeam.ChangeSides();
 }
Ejemplo n.º 10
0
        public ActionResult Create([Bind(Include = "ID,ImagePath")] HomeTeam homeTeam)
        {
            if (ModelState.IsValid)
            {
                db.HomeTeams.Add(homeTeam);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(homeTeam));
        }
Ejemplo n.º 11
0
 internal bool LossFor(string teamCode)
 {
     if (HomeTeam.Equals(teamCode) && AwayScore > HomeScore)
     {
         return(true);
     }
     if (AwayTeam.Equals(teamCode) && HomeScore > AwayScore)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 12
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = Id.GetHashCode();
         hashCode = (hashCode * 397) ^ DateTime.GetHashCode();
         hashCode = (hashCode * 397) ^ (Sport != null ? Sport.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HomeTeam != null ? HomeTeam.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AwayTeam != null ? AwayTeam.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Comments != null ? Comments.GetHashCode() : 0);
         return(hashCode);
     }
 }
Ejemplo n.º 13
0
 internal bool Involves(
     string teamCode)
 {
     if (HomeTeam.Equals(teamCode))
     {
         return(true);
     }
     if (AwayTeam.Equals(teamCode))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 14
0
        // GET: HomeTeams/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HomeTeam homeTeam = db.HomeTeams.Find(id);

            if (homeTeam == null)
            {
                return(HttpNotFound());
            }
            return(View(homeTeam));
        }
Ejemplo n.º 15
0
        //public Match(MatchInfo matchInfo)
        //{
        //    Date = matchInfo.Date;
        //    HomeTeamId = matchInfo.;
        //    AwayTeamId = awayTeamId;
        //    TourId = tourId;
        //    Score = String.Empty;
        //}

        public MatchDto GetDto()
        {
            if (HomeTeam == null)
            {
                throw new ArgumentNullException("HomeTeam cannot be null");
            }

            if (AwayTeam == null)
            {
                throw new ArgumentNullException("AwayTeam cannot be null");
            }

            return(new MatchDto(Date, HomeTeam.GetDto(), AwayTeam.GetDto()));
        }
Ejemplo n.º 16
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = MatchDay;
         hashCode = (hashCode * 397) ^ DateTime.GetHashCode();
         hashCode = (hashCode * 397) ^ HomeTeamScore;
         hashCode = (hashCode * 397) ^ AwayTeamScore;
         hashCode = (hashCode * 397) ^ (HomeTeam != null ? HomeTeam.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AwayTeam != null ? AwayTeam.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Season != null ? Season.GetHashCode() : 0);
         return(hashCode);
     }
 }
Ejemplo n.º 17
0
 private void Run()
 {
     if (Inning.Half == Inning.Side.Top)
     {
         AwayTeam.Run(Inning.Num);
         AwayScore++;
     }
     else
     {
         HomeTeam.Run(Inning.Num);
         HomeScore++;
         CheckEndGame();
     }
 }
Ejemplo n.º 18
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 23;
         hash = hash * 37 + PlayDay.GetHashCode();
         hash = hash * 37 + GameId.GetHashCode();
         hash = hash * 37 + SeasonId.GetHashCode();
         hash = hash * 37 + Date.GetHashCode();
         hash = hash * 37 + (HomeTeam != null ? HomeTeam.GetHashCode() : 0);
         hash = hash * 37 + (AwayTeam != null ? AwayTeam.GetHashCode() : 0);
         hash = hash * 37 + (Arena != null ? Arena.GetHashCode() : 0);
         return(hash);
     }
 }
Ejemplo n.º 19
0
        public void ApproveServe()
        {
            if (!HomeTeam.IsWaitingForServe() && !AwayTeam.IsWaitingForServe())
            {
                return;
            }
            List <Player> players = GetAllPlayers();

            var playerWaiting = players.FirstOrDefault(p => p.ServeState == ServeStateEnum.AwaitingApproval);

            if (playerWaiting == null)
            {
                return;
            }
            playerWaiting.ServeState = ServeStateEnum.Approved;
        }
Ejemplo n.º 20
0
 private void EndGame()
 {
     if (HomeTeam.Runs > AwayTeam.Runs)
     {
         HomeTeam.Win();
         AwayTeam.Lose();
     }
     else
     {
         AwayTeam.Win();
         HomeTeam.Lose();
     }
     GameOver      = true;
     Result        = AwayTeam.DisplayName + " " + AwayScore + " - " + HomeScore + " " + HomeTeam.DisplayName + '\n';
     GameFeed.Text = "";
 }
Ejemplo n.º 21
0
        public void Initialize()
        {
            HomeTeam.NewGame();
            AwayTeam.NewGame();

            AwayTeam.Box.Insert(0, 0);

            GameFeed      = new TextBox();
            GameFeed.Text = "";
            Bases         = new bool[3];
            for (int i = 0; i < 3; i++)
            {
                Bases[i] = false;
            }

            Initialized = true;
        }
        public void StartGame_Add_NotEmpty()
        {
            var scoreBoard  = new ScoreBoard();
            var GameStarter = new GameStarter(scoreBoard);

            var homeTeam = new HomeTeam()
            {
                Name = "Barcelona"
            };
            var awayTeam = new AwayTeam()
            {
                Name = "Madrid"
            };

            GameStarter.StartGame(homeTeam, awayTeam);

            Assert.NotEmpty(scoreBoard.Games);
        }
        void ReleaseDesignerOutlets()
        {
            if (AwayScore != null)
            {
                AwayScore.Dispose();
                AwayScore = null;
            }

            if (AwayTeam != null)
            {
                AwayTeam.Dispose();
                AwayTeam = null;
            }

            if (Date != null)
            {
                Date.Dispose();
                Date = null;
            }

            if (HomeScore != null)
            {
                HomeScore.Dispose();
                HomeScore = null;
            }

            if (HomeTeam != null)
            {
                HomeTeam.Dispose();
                HomeTeam = null;
            }

            if (Indicator != null)
            {
                Indicator.Dispose();
                Indicator = null;
            }

            if (Time != null)
            {
                Time.Dispose();
                Time = null;
            }
        }
Ejemplo n.º 24
0
        public bool MarkPicked(Pick pick, Mlb5Context db)
        {
            Picked = true;
            PickId = pick.Id;
            if (AwayTeam.Code == pick.TeamCode)
            {
                AwayTeam.MarkPicked();
            }
            else
            {
                HomeTeam.MarkPicked();
            }

            if (Status == GameStatus.Completed && pick.Status == PickStatus.New)
            {
                var pickToUpdate = db.Picks.Single(x => x.Id == pick.Id);
                // if pick won then mark run and calculate runs
                if (AwayTeam.Runs > HomeTeam.Runs && AwayTeam.Picked)
                {
                    pickToUpdate.Status = PickStatus.Won;
                    pickToUpdate.Runs   = AwayTeam.Runs - HomeTeam.Runs;
                }
                else if (HomeTeam.Runs > AwayTeam.Runs && HomeTeam.Picked)
                {
                    pickToUpdate.Status = PickStatus.Won;
                    pickToUpdate.Runs   = HomeTeam.Runs - AwayTeam.Runs;
                }
                else
                {
                    pickToUpdate.Status = PickStatus.Lost;
                }
                // add homers and strikeouts
                var myPick = GetPickedTeam();
                pickToUpdate.Homeruns   = myPick.Homeruns;
                pickToUpdate.Strikeouts = myPick.Strikeouts;

                db.SaveChanges();

                return(true);
            }
            return(false);
        }
Ejemplo n.º 25
0
        public void Hit(int hitSuccess)
        {
            if (hitSuccess < 9)
            {
                int hitType = random.Next(101);
                if (hitType < 65)
                {
                    AdvanceBases(1);
                    UpdateFeed(1);
                }
                else if (hitType < 85)
                {
                    AdvanceBases(2);
                    UpdateFeed(2);
                }
                else if (hitType < 90)
                {
                    AdvanceBases(3);
                    UpdateFeed(3);
                }
                else
                {
                    AdvanceBases(4);
                    UpdateFeed(4);
                }

                if (Inning.Half == Inning.Side.Top)
                {
                    AwayTeam.Hit();
                }
                else
                {
                    HomeTeam.Hit();
                }
            }
            else
            {
                Out(hitSuccess);
            }
            ResetCount();
        }
Ejemplo n.º 26
0
 private void LoadMatches()
 {
     foreach (Match match in matches)
     {
         if (match.home_team_country == country || match.away_team_country == country)
         {
             Match    specificMatch = new Match();
             HomeTeam ht            = new HomeTeam();
             AwayTeam at            = new AwayTeam();
             ht.country               = match.home_team.country;
             ht.code                  = match.home_team.code;
             at.country               = match.away_team.country;
             at.code                  = match.away_team.code;
             specificMatch.venue      = match.venue;
             specificMatch.attendance = match.attendance;
             ht.goals                 = match.home_team.goals;
             at.goals                 = match.away_team.goals;
             specificMatch.home_team  = ht;
             specificMatch.away_team  = at;
             chosenMatches.Add(specificMatch);
         }
     }
 }
Ejemplo n.º 27
0
 public void AdicionarGol(Player player, bool against)
 {
     if (player.Team.Id == HomeTeam.Id)
     {
         if (!against)
         {
             this.GoalsHomeTeam++;
             VisitingTeam.TakeGoal();
             player.Team.AddGoal();
             player.AddGoal();
         }
         else
         {
             this.GoalsVisitingTeam++;
             VisitingTeam.AddGoal();
             HomeTeam.TakeGoal();
             player.AddGoalAgainst();
         }
     }
     else
     {
         if (!against)
         {
             this.GoalsVisitingTeam++;
             HomeTeam.TakeGoal();
             player.Team.AddGoal();
             player.AddGoal();
         }
         else
         {
             this.GoalsHomeTeam++;
             HomeTeam.AddGoal();
             VisitingTeam.TakeGoal();
             player.AddGoalAgainst();
         }
     }
 }
Ejemplo n.º 28
0
        public void PlayMatch(List <string> HplayerNames, List <string> VplayerNames)
        {
            HomeTeamGoals = 0; VisitingTeamGoals = 0;

            foreach (var name in HplayerNames)
            {
                var HomePlayer = HomeTeam.GetPlayerById(HomeTeam.GetPlayerIdByName(name));
                HomePlayer.GiveGoal();
                ScoreGoalHomeTeam();
            }



            foreach (var name in VplayerNames)
            {
                var VisitingPlayer = VisitingTeam.GetPlayerById(VisitingTeam.GetPlayerIdByName(name));
                VisitingPlayer.GiveGoal();
                ScoreGoalVisitingTeam();
            }

            if (HomeTeamGoals > VisitingTeamGoals)
            {
                HomeTeam.ScoreWin();
                VisitingTeam.ScoreDefeat();
            }
            else if (HomeTeamGoals < VisitingTeamGoals)
            {
                VisitingTeam.ScoreWin();
                HomeTeam.ScoreDefeat();
            }
            else
            {
                VisitingTeam.ScoreDraw();
                HomeTeam.ScoreDraw();
            }
        }
Ejemplo n.º 29
0
 public bool IsHomeTeam(string teamCode)
 {
     return(HomeTeam.Equals(teamCode));
 }
Ejemplo n.º 30
0
 public void ScoreGoalVisitingTeam()
 {
     VisitingTeamGoals++;
     VisitingTeam.ScoreMakedGoals();
     HomeTeam.ScoreConcededGoals();
 }