public void WicketBallBowled(Batsman batsman) { var ball = new Ball(); ball.Runs = 0; ball.IsPenaltyBall = false; WicketBall += ball.OnWicketBall; DeliverBall(ball); OnWicketBall(batsman); }
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; }
public void OnWicketBall(Batsman batsman) { Wickets++; }
public void SwopBatsmen() { Batsman b = Batsman1; Batsman1 = Batsman2; Batsman2 = b; Batsman1.Status = "*"; Batsman2.Status = ""; RegisterEvents(); }
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++; } }
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(); }
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"; }
public void OnWicketBall(Batsman batsman) { WicketBall handler = WicketBall; if (handler != null) handler(batsman); }