// When a button is clicked in the scoring tab, this method is called to handle the updating of the correct lists and tables. public void GeneralButtonClickHandler(List <Player> batList, List <Player> bowlList, List <Innings> inningsList, List <Over> overAnalysisList, List <FallOfWicket> fallOfWicketList, int inningsId, string folderName, string type, bool batUsed, int runs) { Player player = new Player(); int batId = player.Check_Batsman_Facing(batList, inningsList[inningsId].topBatId, inningsList[inningsId].bottomBatId); int bowlId = player.Check_Bowler_Bowling(bowlList, inningsList[inningsId].topBowlId, inningsList[inningsId].bottomBowlId); Runs_Scored(batList, bowlList, inningsList, overAnalysisList, fallOfWicketList, inningsId, folderName, type, batUsed, runs, batId, bowlId); }
// 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); }
// 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; }
/* When a wicket is taken, this function is called to ensure that the correct batsman is selected as out * and that the correct players from the fielding side are referenced for the wicket. */ private void WicketButtonClick(string howOut, string fielder_Name, bool crossed) { Player player = new Player(); Create_Undo_Point(); // Add one ball to total over amount InningsList[Innings_Id].Innings_Overs = InningsList[Innings_Id].Innings_Overs + 0.1; if (howOut == "runOut") { if (Radio_Run_Out_Bat_Top.Checked) { WicketTaken(howOut, fielder_Name, crossed, InningsList[Innings_Id].topBatId, InningsList[Innings_Id].bottomBatId, player.Check_Bowler_Bowling(BowlList, InningsList[Innings_Id].topBowlId, InningsList[Innings_Id].bottomBowlId)); } else if (Radio_Run_Out_Bat_Bottom.Checked) { WicketTaken(howOut, fielder_Name, crossed, InningsList[Innings_Id].bottomBatId, InningsList[Innings_Id].topBatId, player.Check_Bowler_Bowling(BowlList, InningsList[Innings_Id].topBowlId, InningsList[Innings_Id].bottomBowlId)); } } else { if (BatList[InningsList[Innings_Id].topBatId].Bat_Facing == true) { WicketTaken(howOut, fielder_Name, crossed, InningsList[Innings_Id].topBatId, InningsList[Innings_Id].bottomBatId, player.Check_Bowler_Bowling(BowlList, InningsList[Innings_Id].topBowlId, InningsList[Innings_Id].bottomBowlId)); } else { WicketTaken(howOut, fielder_Name, crossed, InningsList[Innings_Id].bottomBatId, InningsList[Innings_Id].topBatId, player.Check_Bowler_Bowling(BowlList, InningsList[Innings_Id].topBowlId, InningsList[Innings_Id].bottomBowlId)); } } // Check if delivery was last in the over, then update the FOW table and all other tables and hide all flow panels End_OF_Over_Check(); Update_Innings_Fall_Of_Wicket(); Update_Score(); HideAllPanels(); // Check end of innings. Innings innings = new Innings(); if (innings.Check_End_Of_Innings(Innings_Id, InningsList)) { End_Of_Innings(); } }