private Result ConductOver(ref Player striker, ref Player runner) { Over over = new Over(); over.overNumber = Overs.Count; Overs.Add(over); for (int i = 0; i < BallsPerOver; i++) { System.Threading.Thread.Sleep(1000); Ball newBall = new Ball(striker.Name); over.Bowler.Bowl(ref striker, newBall); striker.updateScore(newBall); over.updateScore(newBall); if (!newBall.IsWicket) { ScoreCard.updateScore(newBall); } else { ScoreCard.updateScore(newBall); } if (over.ControlPlayerBetweenWickets(newBall)) { SwapPlayers(ref striker, ref runner); } scoreDisplay.commentarybyBall(newBall, over); if (striker.isOutorNot) { scoreDisplay.CommentaryAfterWicket(striker); striker = GetTheNextPlayer(); if (striker != null) { striker.IsplayingCurrently = true; } } if (ScoreCard.RunsScored > ScoreCard.Target) { return(Result.Won); } if (ScoreCard.RunsScored == ScoreCard.Target && over.overNumber == overslimit && i == BallsPerOver) { return(Result.MatchTied); } if (ScoreCard.WicketsLeft == 0) { return(Result.Allout); } } return(Result.Continue); }
public void commentarybyBall(Ball ball, Over over) { int overNumber = over.overNumber; int ballNumber = over.Balls.Count; string player = ball.Playedby; int runScored = ball.RunsScored; string runsScoredPlural = runScored == 1 || runScored == 0 ? runScored.ToString() + " run" : runScored.ToString() + " runs"; if (ball.IsWicket) { printMessage = string.Format("{0}.{1} Its a Wicket !!! {2} got out ", overNumber, ballNumber, player); Console.WriteLine(printMessage); } else { printMessage = string.Format("{0}.{1} {2} scores {3}", overNumber, ballNumber, player, runsScoredPlural); Console.WriteLine(printMessage); } }
private void ChangeStrikeAfterOver(ref Player firstPlayer, ref Player secondPlayer, Over over) { Ball lastBallofOver = over.Balls[over.Balls.Count - 1]; //if (lastBallofOver.RunsScored == 0 || lastBallofOver.RunsScored == 2 || lastBallofOver.RunsScored == 4 || lastBallofOver.RunsScored == 6) SwapPlayers(ref firstPlayer, ref secondPlayer); }