/// <summary> /// Simulates the ball of the match. /// </summary> /// <remarks>Updates the score card based on the player score.</remarks> /// <param name="currentMatch"></param> /// <param name="striker"></param> /// <param name="nonStriker"></param> /// <param name="currentOver"></param> public void NextBall(CurrentMatchDetails currentMatch, ref PlayerDetails striker, ref PlayerDetails nonStriker, double currentOver) { switch (_playerScoreHelper.Strike(striker)) { case 0: currentMatch.BallsRemaining -= 1; striker.BallsFaced += 1; ScoreBoardService.UpdateCommentory(striker, currentOver, 0); break; case 1: ScoreBoardService.UpdateScore(currentMatch, striker, 1, currentOver); RotateStriker(ref striker, ref nonStriker); break; case 2: ScoreBoardService.UpdateScore(currentMatch, striker, 2, currentOver); break; case 3: ScoreBoardService.UpdateScore(currentMatch, striker, 3, currentOver); RotateStriker(ref striker, ref nonStriker); break; case 4: ScoreBoardService.UpdateScore(currentMatch, striker, 4, currentOver); break; case 5: ScoreBoardService.UpdateScore(currentMatch, striker, 5, currentOver); RotateStriker(ref striker, ref nonStriker); break; case 6: ScoreBoardService.UpdateScore(currentMatch, striker, 6, currentOver); break; case 7: ScoreBoardService.UpdateWicket(currentMatch, ref striker, nonStriker, currentOver); break; default: throw new ArgumentException("Ivalid strike"); } }
/// <summary> /// Simulates the over of the match. /// </summary> /// <remarks>Rotate the striker at the end of over.</remarks> /// <param name="currentMatch"></param> /// <param name="striker"></param> /// <param name="nonStriker"></param> /// <param name="currentOver"></param> public void NextOver(CurrentMatchDetails currentMatch, ref PlayerDetails striker, ref PlayerDetails nonStriker, ref double currentOver) { for (int j = 1; j <= 6; j++) { currentOver += 0.1; NextBall(currentMatch, ref striker, ref nonStriker, currentOver); } RotateStriker(ref striker, ref nonStriker); }