From 9d04f98db0f2b3d7173975fd7daf6dff82b1284f Mon Sep 17 00:00:00 2001 From: AlexCami1902 Date: Wed, 7 May 2025 18:34:12 +1000 Subject: [PATCH] Update main.py Fixed bug in #34 that now allows the bye message and no ball message to not be over the top of each other Signed-off-by: AlexCami1902 --- main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 8c1cea6..ded365b 100644 --- a/main.py +++ b/main.py @@ -102,6 +102,10 @@ def byes(): def wide(): global runs global extras + global bye_status + global noball_status + bye_status = False # Sets the bye status to false to let the code know to trigger the various events + noball_status = False # Sets the no-ball status to false to let the code know to trigger the various events runs += 1 extras += 1 @@ -110,6 +114,8 @@ def noball(): global overs global extras global noball_status + global bye_status + bye_status = False # Sets the bye status to false to let the code know to trigger the various events noball_status = True # Sets the no-ball status to true to let the code know to trigger the various events runs += 1 extras += 1 @@ -150,6 +156,10 @@ def scoring(ballscore): def add_wicket(): global wickets + global bye_status + global noball_status + bye_status = False # Sets the bye status to false to let the code know to trigger the various events + noball_status = False # Sets the no-ball status to false to let the code know to trigger the various events if wickets < 10: history.append((overs, runs, wickets, extras, noball_status, bye_status)) # Saves the current state of play before making any changes wickets += 1 @@ -159,7 +169,10 @@ def add_wicket(): def add_ball(): global overs, runs, wickets, extras - + global bye_status + global noball_status + bye_status = False # Sets the bye status to false to let the code know to trigger the various events + noball_status = False # Sets the no-ball status to false to let the code know to trigger the various events history.append((overs, runs, wickets, extras, noball_status, bye_status)) # Appends the history list for the undo fucntion with the new ball if overs % 1 == 0.5: # Uses the modulous operator to figure out the remainder of the overs @@ -324,6 +337,7 @@ def toggle_bold(): # Function to toggle between regular and bold font if bye_status: draw_text("How many byes?", font, red, screen, 200, 50) # Asks the user how many byes were scored + draw_text(f"Run Rate: {round(run_rate, 2)}", font, black, screen, 50, 700) # Print the various calculations made