Example #1
0
        // Checks if the last delivery completed the over, if so the total overs are updated to the next highest round number */
        public bool Check_End_Of_Over(List <Player> batList, List <Player> bowlList, List <Innings> inningsList, List <Over> overAnalysisList, List <FallOfWicket> fallOfWicketList, int inningsId, string folderName)
        {
            bool   endOfOver           = false;
            Player player              = new Player();
            int    bowlId              = player.Check_Bowler_Bowling(bowlList, inningsList[inningsId].topBowlId, inningsList[inningsId].bottomBowlId);
            double oversTotal          = Math.Round(inningsList[inningsId].Innings_Overs, 1);
            double Updated_Over_Amount = oversTotal;
            double test_total          = Math.Round((oversTotal - Math.Truncate(oversTotal)), 1);

            if (test_total == .6)
            {
                Updated_Over_Amount = Math.Ceiling(Updated_Over_Amount);
            }

            if (Updated_Over_Amount - Math.Truncate(Updated_Over_Amount) == 0)
            {
                bowlList[bowlId].Bowl_Overs          = Math.Ceiling(bowlList[bowlId].Bowl_Overs);
                inningsList[inningsId].Innings_Overs = Math.Ceiling(inningsList[inningsId].Innings_Overs);

                // Check if completed over was a maiden, if not set maiden flag back to true for next over
                if (inningsList[inningsId].maiden)
                {
                    // Add 1 to the innings and bowler's maidens
                    inningsList[inningsId].Bowl_Total_Maidens = inningsList[inningsId].Bowl_Total_Maidens + 1;
                    bowlList[bowlId].Bowl_Maidens             = bowlList[bowlId].Bowl_Maidens + 1;
                }
                else
                {
                    inningsList[inningsId].maiden = true;
                }
                // Convert over number from double to int to allow new line to be added to Over Analysis table
                inningsList[inningsId].Over_Analysis_Overs = Convert.ToInt32(inningsList[inningsId].Innings_Overs);

                Over over = new Over();
                over.Create_Over(inningsList[inningsId].Over_Analysis_Overs, (bowlId) + 1, inningsList[inningsId].Over_Analysis_Runs, inningsList[inningsId].Over_Analysis_Wickets);
                overAnalysisList.Add(over);

                // Save the over to a new text file
                over.Save_Over(fallOfWicketList, batList, bowlList, inningsList, overAnalysisList, inningsId, folderName);
                endOfOver = true;
            }
            return(endOfOver);
        }
Example #2
0
        // Checks if the last delivery completed the over, if so the total overs are updated to the next highest round number */
        public bool Check_End_Of_Over(List<Player> batList, List<Player> bowlList, List<Innings> inningsList, List<Over> overAnalysisList, List<FallOfWicket> fallOfWicketList, int inningsId, string folderName)
        {
            bool endOfOver = false;
            Player player = new Player();
            int bowlId = player.Check_Bowler_Bowling(bowlList, inningsList[inningsId].topBowlId, inningsList[inningsId].bottomBowlId);
            double oversTotal = Math.Round(inningsList[inningsId].Innings_Overs, 1);
            double Updated_Over_Amount = oversTotal;
            double test_total = Math.Round((oversTotal - Math.Truncate(oversTotal)), 1);
            if (test_total == .6)
            {
                Updated_Over_Amount = Math.Ceiling(Updated_Over_Amount);
            }

            if (Updated_Over_Amount - Math.Truncate(Updated_Over_Amount) == 0)
            {
                bowlList[bowlId].Bowl_Overs = Math.Ceiling(bowlList[bowlId].Bowl_Overs);
                inningsList[inningsId].Innings_Overs = Math.Ceiling(inningsList[inningsId].Innings_Overs);

                // Check if completed over was a maiden, if not set maiden flag back to true for next over
                if (inningsList[inningsId].maiden)
                {
                    // Add 1 to the innings and bowler's maidens
                    inningsList[inningsId].Bowl_Total_Maidens = inningsList[inningsId].Bowl_Total_Maidens + 1;
                    bowlList[bowlId].Bowl_Maidens = bowlList[bowlId].Bowl_Maidens + 1;
                }
                else
                {
                    inningsList[inningsId].maiden = true;
                }
                // Convert over number from double to int to allow new line to be added to Over Analysis table
                inningsList[inningsId].Over_Analysis_Overs = Convert.ToInt32(inningsList[inningsId].Innings_Overs);

                Over over = new Over();
                over.Create_Over(inningsList[inningsId].Over_Analysis_Overs, (bowlId) + 1, inningsList[inningsId].Over_Analysis_Runs, inningsList[inningsId].Over_Analysis_Wickets);
                overAnalysisList.Add(over);

                // Save the over to a new text file
                over.Save_Over(fallOfWicketList, batList, bowlList, inningsList, overAnalysisList, inningsId, folderName);
                endOfOver = true;
            }
            return endOfOver;
        }