예제 #1
0
 public void WicketBallBowled(Batsman batsman)
 {
     var ball = new Ball();
     ball.Runs = 0;
     ball.IsPenaltyBall = false;
     WicketBall += ball.OnWicketBall;
     DeliverBall(ball);
     OnWicketBall(batsman);
 }
예제 #2
0
 public Game()
 {
     a = DateTime.Now.Millisecond;
     SetupBowlers();
     SetupBatsmen();
     Bowler = Bowlers.First();
     Batsman1 = Batsmen.First();
     Batsman2 = Batsmen.First(x => x != Batsman1);
     Batsman1.Status = "*";
     Batsman2.Status = "";
     SetupOver();
     Score = 0;
 }
예제 #3
0
 public void OnWicketBall(Batsman batsman)
 {
     Wickets++;
 }
예제 #4
0
 public void SwopBatsmen()
 {
     Batsman b = Batsman1;
     Batsman1 = Batsman2;
     Batsman2 = b;
     Batsman1.Status = "*";
     Batsman2.Status = "";
     RegisterEvents();
 }
예제 #5
0
 private void SetupBatsmen()
 {
     int iCount = 0;
     while(iCount<8)
     {
         string[] name = GetRandomName().Split(' ');
         var player = new Batsman(name[0],name[1]);
         Batsmen.Add(player);
         iCount++;
     }
 }
예제 #6
0
 private void OnWicketBall(Batsman batsman)
 {
     Wickets++;
     if (Batsman1.Equals(batsman))
     {
         Batsman1 = Batsmen.First(x => x.Status == "Active");
         Batsman1.Status = "*";
     }
     else
     {
         Batsman2 = Batsmen.First(x => x.Status == "Active");
         Batsman2.Status = "";
     }
     RegisterEvents();
 }
예제 #7
0
        private void CheckScores()
        {
            if(Batsman1.Score>49)
            {
                Batsman1.Status = "Retired";
                Batsman1 = Batsmen.First(x => x.Status == "Active");
                Batsman1.Status = "*";
                RegisterEvents();
            }

            if (Batsman2.Score > 49)
            {
                Batsman2.Status = "Retired";
                Batsman2 = Batsmen.First(x => x.Status == "Active");
                Batsman2.Status = "";
                RegisterEvents();
            }
        }
 public void OnWicketBall(Batsman batsman)
 {
     if(batsman.Equals(this))
         Status = "Bowled";
 }
예제 #9
0
 public void OnWicketBall(Batsman batsman)
 {
     WicketBall handler = WicketBall;
     if (handler != null)
         handler(batsman);
 }