Пример #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);
        }
Пример #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;
        }
        private void End_OF_Over_Check()
        {
            Over over = new Over();
            if (over.Check_End_Of_Over(BatList, BowlList, InningsList, OverAnalysisList, FallOfWicketList, Innings_Id, folderName))
            {
                Update_Innings_Over_Analysis();
                Create_Graphs();
                // Swap batsmen and bowlers for start of new over
                Swap_Batsman();
                Swap_Bowler();

                // Check if end of innings has been reached
                Innings innings = new Innings();
                if (innings.Check_End_Of_Innings(Innings_Id, InningsList))
                {
                    End_Of_Innings();
                }
            }
        }
        // Inintialises all variables at the start of an innings
        private void Set_Default_Variables()
        {
            HideAllPanels();
            Innings innings = new Innings();
            innings.Create_Innings(MatchDetailsList, Toss_Winner_Combo_Box.SelectedItem.ToString(), Innings_Of);
            InningsList.Add(innings);
            // Gets the team name for the second innings
            GraphSeriesList.Add(InningsList[Innings_Id].Team_Name);
            Over over = new Over();
            over.Create_Over(0,0,0,0);
            OverAnalysisList.Add(over);

            // Sets Extra table details
            Wides_Total_Value.Text = innings.Extras_Wides.ToString();
            No_Balls_Total_Value.Text = innings.Extras_No_Balls.ToString();
            Byes_Total_Value.Text = innings.Extras_Byes.ToString();
            Leg_Byes_Total_Value.Text = innings.Extras_Leg_Byes.ToString();
            Penaltys_Total_Value.Text = innings.Extras_Penaltys.ToString();
            Total_Extras_Value.Text = innings.Extras_Total.ToString();

            // Sets match details
            Scoring_Date_Value.Text = innings.Date;
            Scoring_Innings_Of_Value.Text = InningsList[Innings_Id].Team_Name;
            Scoring_Total_Value.Text = innings.Innings_Total.ToString();
            Scoring_Wickets_Down_Value.Text = innings.Innings_Wickets.ToString();
            Scoring_Total_Overs_Value.Text = innings.Innings_Overs.ToString();

            // Initialise opening player objects
            Player batTop = new Player();
            Player batBottom = new Player();
            Player bowlTop = new Player();
            Player bowlBottom = new Player();

            if (Innings_Id == 0)
            {
                batTop.Create_Batsman((InningsList[0].topBatId + 1), Open_Select_Bat_1.SelectedItem.ToString(), true);
                batBottom.Create_Batsman((InningsList[0].bottomBatId + 1), Open_Select_Bat_2.SelectedItem.ToString(), false);
                bowlTop.Create_Bowler((InningsList[0].topBowlId + 1), Open_Select_Bowl_1.SelectedItem.ToString(), true);
                bowlBottom.Create_Bowler((InningsList[0].bottomBowlId + 1), Open_Select_Bowl_2.SelectedItem.ToString(), false);
            }
            else
            {
                batTop.Create_Batsman((InningsList[1].topBatId + 1), Open_Select_Bat_1_Inn_2.SelectedItem.ToString(), true);
                batBottom.Create_Batsman((InningsList[1].bottomBatId + 1), Open_Select_Bat_2_Inn_2.SelectedItem.ToString(), false);
                bowlTop.Create_Bowler((InningsList[1].topBowlId + 1), Open_Select_Bowl_1_Inn_2.SelectedItem.ToString(), true);
                bowlBottom.Create_Bowler((InningsList[1].bottomBowlId + 1), Open_Select_Bowl_2_Inn_2.SelectedItem.ToString(), false);
            }
            BatList.Add(batTop);
            BatList.Add(batBottom);
            BowlList.Add(bowlTop);
            BowlList.Add(bowlBottom);
            Update_Next_Batsman_List(batTop.Bat_Name);
            Update_Next_Batsman_List(batBottom.Bat_Name);
            Create_Graphs();
            Update_Last_Man_Out_Table();
        }