Esempio n. 1
0
 public void CommentaryBymatchifLost(ScoreCard score, List <Over> overs)
 {
     printMessage = string.Format("Lengburu lost by {0}", TakecareofPlurals(score.RequiredRuns - 1, "run"));
     Console.WriteLine(printMessage);
     if (score.Teams != null)
     {
         DisplayPlayerScores(score.Teams[0].Players);
     }
 }
Esempio n. 2
0
 public void CommentaryBymatchIfTied(ScoreCard score, List <Over> overs)
 {
     printMessage = string.Format("Match is Tied.Score is {0}", TakecareofPlurals(score.RunsScored, "run"));
     Console.WriteLine(printMessage);
     if (score.Teams != null)
     {
         DisplayPlayerScores(score.Teams[0].Players);
     }
 }
Esempio n. 3
0
        public void CommentaryBymatchifWon(ScoreCard score, List <Over> overs)
        {
            int remainingBalls = (_OversMatch * 6) - GetNumberofBallsRemaining(overs);

            printMessage = string.Format("Lengaburu won by {0} and {1} remaining", TakecareofPlurals(score.WicketsLeft, "wickets"), TakecareofPlurals(remainingBalls, "balls"));
            Console.WriteLine(printMessage);
            if (score.Teams != null)
            {
                DisplayPlayerScores(score.Teams[0].Players);
            }
        }
Esempio n. 4
0
        public Match()
        {
            List <Team> teams = new List <Team>();

            team = new Team("Lengaburu");
            teams.Add(team);
            ScoreCard    = new ScoreCard(overslimit, 40, 3, 0, team.Players);
            ScoreCard    = new ScoreCard(overslimit, 40, 3, 0, teams);
            Overs        = new List <Over>();
            scoreDisplay = new Commentary();
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        public bool ConductMatch()
        {
            Player firstPlayer  = ScoreCard.Teams[0].Players[0];
            Player secondPlayer = ScoreCard.Teams[0].Players[1];

            firstPlayer.IsBattingNow        = true;
            firstPlayer.IsplayingCurrently  = true;
            secondPlayer.IsplayingCurrently = true;
            Result result = Result.Continue;

            for (int i = 0; i < overslimit; i++)
            {
                result = ConductOver(ref firstPlayer, ref secondPlayer);
                ScoreCard.updateOver();
                scoreDisplay.CommentarybyOver(ScoreCard, Overs);
                if (result == Result.Won || result == Result.Allout)
                {
                    if (result == Result.Won)
                    {
                        scoreDisplay.CommentaryBymatchifWon(ScoreCard, Overs);
                    }
                    else if (result == Result.Allout)
                    {
                        scoreDisplay.CommentaryBymatchifLost(ScoreCard, Overs);
                    }
                    else if (result == Result.MatchTied)
                    {
                    }
                    break;
                }

                ChangeStrikeAfterOver(ref firstPlayer, ref secondPlayer, Overs[Overs.Count - 1]);
            }
            if (ScoreCard.OversLeft == 0 && ScoreCard.RunsScored < ScoreCard.Target && result != Result.Allout)
            {
                scoreDisplay.CommentaryBymatchifLost(ScoreCard, Overs);
            }
            return(true);
        }
Esempio n. 7
0
 public void CommentarybyOver(ScoreCard scoreCard, List <Over> over)
 {
     Console.WriteLine("After completion of over {0}. The score is {1}", over.Count, scoreCard.RunsScored);
     Console.WriteLine("Tagert {0}, Runs Required {1}, Remaining balls {2}", scoreCard.Target, scoreCard.RequiredRuns, (_OversMatch * 6) - GetNumberofBallsRemaining(over));
     Console.WriteLine("------------------------------------");
 }