public void PickTeam(Team team, IUniversalRepository universalRepository)
        {
            var countryName = team.Country.Name;
            var playersForCountry = universalRepository.Query<Player>().Where(p => p.Country.Name.Equals(countryName));

            var random = new Random();
            var availablePlayers = playersForCountry.ToList();
            while (availablePlayers.Any() && ! team.IsTeamComplete())
            {
                var pickedPlayer = availablePlayers[random.Next(availablePlayers.Count)];
                team.AddMember(pickedPlayer);
                availablePlayers.Remove(pickedPlayer);
            }
        }
Esempio n. 2
0
        public virtual TeamInnings NewInnings(Team battingTeam)
        {
            if (battingTeam == null) throw new ArgumentNullException("battingTeam");
            if (! (battingTeam.Equals(Team1) || battingTeam.Equals(Team2)))
                throw new InvalidOperationException("Team must be one of the teams in the match!");

            TeamInnings teamInnings;

            if (battingTeam.Equals(Team1))
            {
                teamInnings = new TeamInnings(Team1, Team2);
            }
            else
            {
                teamInnings = new TeamInnings(Team2, Team1);
            }

            innings.Add(teamInnings);

            return teamInnings;
        }
Esempio n. 3
0
 //public virtual Player FacingBatter { get; private set; }
 internal TeamInnings(Team battingTeam, Team fieldingTeam)
 {
     this.battingTeam = battingTeam;
     this.fieldingTeam = fieldingTeam;
 }
Esempio n. 4
0
 //public virtual Player FacingBatter { get; private set; }
 internal TeamInnings(Team battingTeam, Team fieldingTeam)
 {
     BattingTeam = battingTeam;
     FieldingTeam = fieldingTeam;
 }