コード例 #1
0
        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);
            }
        }
コード例 #2
0
ファイル: Match.cs プロジェクト: christensena/DDDIntro
        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;
        }
コード例 #3
0
ファイル: TeamInnings.cs プロジェクト: christensena/DDDIntro
 //public virtual Player FacingBatter { get; private set; }
 internal TeamInnings(Team battingTeam, Team fieldingTeam)
 {
     this.battingTeam = battingTeam;
     this.fieldingTeam = fieldingTeam;
 }
コード例 #4
0
ファイル: TeamInnings.cs プロジェクト: simonfox/DDDIntro
 //public virtual Player FacingBatter { get; private set; }
 internal TeamInnings(Team battingTeam, Team fieldingTeam)
 {
     BattingTeam = battingTeam;
     FieldingTeam = fieldingTeam;
 }