// Saves all objects into separate text files to create a backup for the system public void Save_Over(List <FallOfWicket> fallOfWicketList, List <Player> batList, List <Player> bowlList, List <Innings> inningsList, List <Over> overAnalysisList, int inningsId, string folderName) { // Save player objects to file Player player = new Player(); player.Save_Batsmen(batList, inningsList[inningsId].Team_Name, folderName); player.Save_Bowlers(bowlList, inningsList[inningsId].Team_Name, folderName); // Save fall of wicket objects to file FallOfWicket fallOfWicket = new FallOfWicket(); fallOfWicket.Save_Fall_Of_Wicket_List(fallOfWicketList, inningsList[inningsId].Team_Name, folderName); // Save over analysis objects to file Save_Over_Analysis(overAnalysisList, inningsList[inningsId].Team_Name, folderName); // Save innings objects to file Innings innings = new Innings(); innings.Save_Innings(folderName, inningsId, inningsList, fallOfWicketList); }
// Saves all objects into separate text files to create a backup for the system public void Save_Over(List<FallOfWicket> fallOfWicketList, List<Player> batList, List<Player> bowlList, List<Innings> inningsList, List<Over> overAnalysisList, int inningsId, string folderName) { // Save player objects to file Player player = new Player(); player.Save_Batsmen(batList, inningsList[inningsId].Team_Name, folderName); player.Save_Bowlers(bowlList, inningsList[inningsId].Team_Name, folderName); // Save fall of wicket objects to file FallOfWicket fallOfWicket = new FallOfWicket(); fallOfWicket.Save_Fall_Of_Wicket_List(fallOfWicketList, inningsList[inningsId].Team_Name, folderName); // Save over analysis objects to file Save_Over_Analysis(overAnalysisList, inningsList[inningsId].Team_Name, folderName); // Save innings objects to file Innings innings = new Innings(); innings.Save_Innings(folderName, inningsId, inningsList, fallOfWicketList); }
/* When a wicket is taken the application updates the Last Man Out table, Fall Of Wicket table and the batting tables. * 1. Adds 1 ball to the batsman, bowler and total overs * 2. Adds 1 to bowler and total wickets if batsman is 'caught', 'bowled', 'lbw', 'stumped' or 'caught and bowled' * 3. Adds 1 to total wickets if batsman is 'run out' or 'retired' */ public void WicketTaken(string wicketType, string fielder_Name, bool crossed, int outBatId, int notOutBatId, int bowlId) { Player player = new Player(); bool newBatFacing = true; // add ball to bowler and out batsman player.Bowling_Add_Ball(BowlList, bowlId); player.Batting_Add_Ball(BatList, outBatId); //add wicket to bowler and total innings wickets if (wicketType != "runOut") { BowlList[bowlId].Bowl_Wickets = BowlList[bowlId].Bowl_Wickets + 1; } InningsList[Innings_Id].Innings_Wickets = InningsList[Innings_Id].Innings_Wickets + 1; // Used to update the last man out table in Update_Score() Last_Bat_Out = outBatId; // Get the fielder and bowler names associated with the wicket. string fielderName = player.Get_Player_Short_Name(fielder_Name); string bowlerName = player.Get_Player_Short_Name(BowlList[bowlId].Bowl_Name); // Checks if the crossed checkbox has been checked if (crossed) { Swap_Batsman(); newBatFacing = false; } else { BatList[outBatId].Bat_Facing = false; Current_Batsman_Number_Top.BackColor = Color.Transparent; Current_Batsman_Number_Bottom.BackColor = Color.White; } switch (wicketType) { case "caught": BatList[outBatId].Bat_How_Out = "Ct " + fielderName; BatList[outBatId].Bat_Out_Bwlr = bowlerName; InningsList[Innings_Id].Bowl_Total_Wickets = InningsList[Innings_Id].Bowl_Total_Wickets + 1; break; case "runOut": BatList[outBatId].Bat_How_Out = "Run Out"; BatList[outBatId].Bat_Out_Bwlr = fielderName; break; case "bowled": BatList[outBatId].Bat_How_Out = "Bowled"; BatList[outBatId].Bat_Out_Bwlr = bowlerName; InningsList[Innings_Id].Bowl_Total_Wickets = InningsList[Innings_Id].Bowl_Total_Wickets + 1; break; case "stumped": BatList[outBatId].Bat_How_Out = "Stumped"; BatList[outBatId].Bat_Out_Bwlr = bowlerName; InningsList[Innings_Id].Bowl_Total_Wickets = InningsList[Innings_Id].Bowl_Total_Wickets + 1; break; case "lbw": BatList[outBatId].Bat_How_Out = "LBW"; BatList[outBatId].Bat_Out_Bwlr = bowlerName; InningsList[Innings_Id].Bowl_Total_Wickets = InningsList[Innings_Id].Bowl_Total_Wickets + 1; break; case "caughtAndBowled": BatList[outBatId].Bat_How_Out = "Ct && Bwld"; BatList[outBatId].Bat_Out_Bwlr = bowlerName; InningsList[Innings_Id].Bowl_Total_Wickets = InningsList[Innings_Id].Bowl_Total_Wickets + 1; break; case "retired": BatList[outBatId].Bat_How_Out = "Retired"; BatList[outBatId].Bat_Out_Bwlr = "Out"; break; } FallOfWicket fallOfWicket = new FallOfWicket(); fallOfWicket.Create_Fall_Of_Wicket(InningsList, BatList, Innings_Id, outBatId, notOutBatId); FallOfWicketList.Add(fallOfWicket); fallOfWicket.Save_Fall_Of_Wicket_List(FallOfWicketList, InningsList[Innings_Id].Team_Name, this.folderName); if (InningsList[Innings_Id].Innings_Wickets < 10) { // Checks if the Current Batsman table rows need to be swapped. // Only if the batting side has wickets in hand if (outBatId < notOutBatId) { Wicket_Change_Top_Batsman(); } // Adds new batsman object into the table and list with Id one greater than the batsman on the bottom row. Player newBatsman = new Player(); newBatsman.Create_Batsman((BatList[InningsList[Innings_Id].bottomBatId].Bat_Number + 1), (Wicket_Next_Bat_Combo_Box.SelectedItem.ToString()), newBatFacing); BatList.Add(newBatsman); Update_Next_Batsman_List(newBatsman.Bat_Name); InningsList[Innings_Id].bottomBatId = InningsList[Innings_Id].bottomBatId + 1; Update_Batsman_Bottom(); InningsList[Innings_Id].Over_Analysis_Wickets = InningsList[Innings_Id].Over_Analysis_Wickets + 1; } Innings innings = new Innings(); if (innings.Check_End_Of_Innings(Innings_Id, InningsList)) { End_Of_Innings(); } }