Ejemplo n.º 1
0
 public Team(int id, string name, string divisionName, string conferenceName)
 {
     Id               = id;
     Name             = name;
     DivisionName     = divisionName;
     ConferenceName   = conferenceName;
     OverallWins      = 0;
     OverallLosses    = 0;
     OverallTies      = 0;
     ConferenceWins   = 0;
     ConferenceLosses = 0;
     ConferenceTies   = 0;
     Schedule         = new GameList();
 }
        public GameList FilterByTeams(List <int> teamIds)
        {
            GameList filtered = new GameList();

            foreach (Game game in mGames)
            {
                foreach (int teamId in teamIds)
                {
                    if (game.InvolvesTeam(teamId))
                    {
                        filtered.Add(game);
                        break;
                    }
                }
            }

            return(filtered);
        }
Ejemplo n.º 3
0
        public void IntegrateGames(GameList games)
        {
            foreach (Game game in games)
            {
                Team homeTeam = FindTeam(game.home_team);
                Team awayTeam = FindTeam(game.away_team);

                if (homeTeam != null)
                {
                    game.HomeTeamId = homeTeam.Id;
                }
                else
                {
                    Console.WriteLine("Check");
                }
                if (awayTeam != null)
                {
                    game.AwayTeamId = awayTeam.Id;
                }
                else
                {
                    Console.WriteLine("Check");
                }

                game.DivisionGame = homeTeam?.DivisionName != null && awayTeam?.DivisionName != null && homeTeam.DivisionName.Equals(awayTeam.DivisionName);

                homeTeam?.Schedule.Add(game);
                awayTeam?.Schedule.Add(game);

                if (!game.GameAlreadyPlayed)
                {
                    continue;
                }

                if (game.HomeWin.Value)
                {
                    homeTeam?.RecordWin(game.ConferenceGame);
                    awayTeam?.RecordLoss(game.ConferenceGame);
                }
                else if (game.AwayWin.Value)
                {
                    homeTeam?.RecordLoss(game.ConferenceGame);
                    awayTeam?.RecordWin(game.ConferenceGame);
                }
                else
                {
                    homeTeam?.RecordTie(game.ConferenceGame);
                    awayTeam?.RecordTie(game.ConferenceGame);
                }
            }

            foreach (Conference conference in Conferences)
            {
                foreach (Division division in conference.Divisions)
                {
                    foreach (Team team in division.Teams)
                    {
                        team.Schedule.Sort();
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public League(List <Conference> conferences, List <Team> teams, GameList games)
        {
            Conferences = Load(conferences, teams);

            IntegrateGames(games);
        }