mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-02-04 11:07:59 -08:00
Flake8 errors
This commit is contained in:
@@ -131,7 +131,7 @@ def main() -> None:
|
||||
# Main loop of game
|
||||
print_intro()
|
||||
while (
|
||||
keep_playing := parse_input(
|
||||
_keep_playing := parse_input(
|
||||
"Are you thinking of an animal? ", True, root
|
||||
)
|
||||
== "y"
|
||||
|
||||
@@ -139,7 +139,7 @@ class Basketball:
|
||||
else:
|
||||
print("Shot is off target.")
|
||||
if self.defense / 6 * random.random() > 0.45:
|
||||
print(f"Rebound to {self.opponent}" + "\n")
|
||||
print(f"Rebound to {self.opponent}\n")
|
||||
self.opponent_ball()
|
||||
else:
|
||||
print("Dartmouth controls the rebound.")
|
||||
@@ -185,7 +185,7 @@ class Basketball:
|
||||
if 7 / self.defense * random.random() > 0.925:
|
||||
print("Charging foul. Dartmouth loses the ball.\n")
|
||||
else:
|
||||
print(f"Shot blocked. {self.opponent}" + "'s ball.\n")
|
||||
print(f"Shot blocked. {self.opponent}'s ball.\n")
|
||||
else:
|
||||
self.foul_shots(1)
|
||||
self.opponent_ball()
|
||||
@@ -270,7 +270,7 @@ class Basketball:
|
||||
or self.defense != 6
|
||||
and random.random() <= 0.5
|
||||
):
|
||||
print(f"Pass back to {self.opponent}" + " guard.\n")
|
||||
print(f"Pass back to {self.opponent} guard.\n")
|
||||
self.opponent_ball()
|
||||
elif self.defense == 6 and random.random() > 0.75:
|
||||
print("Ball stolen. Easy lay up for Dartmouth.")
|
||||
@@ -310,14 +310,14 @@ class Basketball:
|
||||
and random.random() <= 0.75
|
||||
and random.random() <= 0.5
|
||||
):
|
||||
print(f"Pass back to {self.opponent}" + " guard.\n")
|
||||
print(f"Pass back to {self.opponent} guard.\n")
|
||||
self.opponent_ball()
|
||||
elif self.defense == 6 and random.random() > 0.75:
|
||||
print("Ball stolen. Easy lay up for Dartmouth.")
|
||||
self.add_points(1, 2)
|
||||
self.opponent_ball()
|
||||
else:
|
||||
print(f"Pass back to {self.opponent}" + " guard\n")
|
||||
print(f"Pass back to {self.opponent} guard\n")
|
||||
self.opponent_ball()
|
||||
else:
|
||||
print("Dartmouth controls the rebound.\n")
|
||||
|
||||
@@ -29,7 +29,7 @@ def determine_player_kills(
|
||||
print(f"THE {player_type}{plural_form} DID A {job_qualities[job_quality]} JOB.")
|
||||
if job_quality >= 4:
|
||||
if job_quality == 5:
|
||||
if player_was_killed := random.choice([True, False]):
|
||||
if _player_was_killed := random.choice([True, False]):
|
||||
print(f"ONE OF THE {player_type}{plural_form} WAS KILLED.")
|
||||
else:
|
||||
if player_type != "TOREAD":
|
||||
|
||||
@@ -127,7 +127,7 @@ def print_header() -> None:
|
||||
|
||||
|
||||
def instructions() -> None:
|
||||
if wants_it := ask_binary(
|
||||
if _wants_it := ask_binary(
|
||||
"WOULD YOU LIKE THE INSTRUCTIONS? ", "ANSWER YES OR NO!!"
|
||||
):
|
||||
print()
|
||||
@@ -229,7 +229,7 @@ def team2_action(
|
||||
z1 = 3
|
||||
elif pass_value == 2:
|
||||
print("IT'S A ' 3 ON 2 '!\n")
|
||||
print(f"ONLY {team_a.players[3]} AND {team_a.players[4]}" + " ARE BACK.\n")
|
||||
print(f"ONLY {team_a.players[3]} AND {team_a.players[4]} ARE BACK.\n")
|
||||
print(
|
||||
team_b.players[player_index[j - 2]]
|
||||
+ " GIVES OFF TO "
|
||||
@@ -374,7 +374,7 @@ def handle_hit(
|
||||
else:
|
||||
print(f"{team_b.name}: {team_b.score}\t{team_a.name}: {team_a.score}\n")
|
||||
team = team_a if controlling_team == 1 else team_b
|
||||
print(f"GOAL SCORED BY: {team.players[goal_player]}" + "\n")
|
||||
print(f"GOAL SCORED BY: {team.players[goal_player]}\n")
|
||||
if goal_assistant1 != 0:
|
||||
if goal_assistant2 != 0:
|
||||
print(
|
||||
@@ -402,16 +402,16 @@ def handle_miss(
|
||||
saving_player = randint(1, 7)
|
||||
if controlling_team == 1:
|
||||
if saving_player == 1:
|
||||
print(f"KICK SAVE AND A BEAUTY BY {team_b.players[5]}" + "\n")
|
||||
print(f"CLEARED OUT BY {team_b.players[3]}" + "\n")
|
||||
print(f"KICK SAVE AND A BEAUTY BY {team_b.players[5]}\n")
|
||||
print(f"CLEARED OUT BY {team_b.players[3]}\n")
|
||||
remaining_time -= 1
|
||||
return ("continue", remaining_time)
|
||||
if saving_player == 2:
|
||||
print(f"WHAT A SPECTACULAR GLOVE SAVE BY {team_b.players[5]}" + "\n")
|
||||
print(f"WHAT A SPECTACULAR GLOVE SAVE BY {team_b.players[5]}\n")
|
||||
print(f"AND {team_b.players[5]}" + " GOLFS IT INTO THE CROWD\n")
|
||||
return ("break", remaining_time)
|
||||
if saving_player == 3:
|
||||
print(f"SKATE SAVE ON A LOW STEAMER BY {team_b.players[5]}" + "\n")
|
||||
print(f"SKATE SAVE ON A LOW STEAMER BY {team_b.players[5]}\n")
|
||||
remaining_time -= 1
|
||||
return ("continue", remaining_time)
|
||||
if saving_player == 4:
|
||||
@@ -447,20 +447,20 @@ def handle_miss(
|
||||
print("ON THE LOOSE PUCK!\n")
|
||||
return ("break", remaining_time)
|
||||
if saving_player == 3:
|
||||
print(f"SKATE SAVE BY {team_a.players[5]}" + "\n")
|
||||
print(f"SKATE SAVE BY {team_a.players[5]}\n")
|
||||
print(team_a.players[5] + " WHACKS THE LOOSE PUCK INTO THE STANDS\n")
|
||||
return ("break", remaining_time)
|
||||
if saving_player == 4:
|
||||
print(f"STICK SAVE BY {team_a.players[5]}" + " AND HE CLEARS IT OUT HIMSELF\n")
|
||||
print(f"STICK SAVE BY {team_a.players[5]} AND HE CLEARS IT OUT HIMSELF\n")
|
||||
remaining_time -= 1
|
||||
return ("continue", remaining_time)
|
||||
if saving_player == 5:
|
||||
print(f"KICKED OUT BY {team_a.players[5]}" + "\n")
|
||||
print(f"KICKED OUT BY {team_a.players[5]}\n")
|
||||
print("AND IT REBOUNDS ALL THE WAY TO CENTER ICE\n")
|
||||
remaining_time -= 1
|
||||
return ("continue", remaining_time)
|
||||
if saving_player == 6:
|
||||
print(f"GLOVE SAVE {team_a.players[5]}" + " AND HE HANGS ON\n")
|
||||
print(f"GLOVE SAVE {team_a.players[5]} AND HE HANGS ON\n")
|
||||
return ("break", remaining_time)
|
||||
return ("continue", remaining_time)
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ def run_simulation() -> None:
|
||||
return
|
||||
|
||||
if capsule.velocity > 0 and new_state.velocity < 0:
|
||||
if landed := handle_flyaway(sim_clock, capsule):
|
||||
if _landed := handle_flyaway(sim_clock, capsule):
|
||||
process_final_tick(delta_t, sim_clock, capsule)
|
||||
return
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ def play_game() -> None:
|
||||
|
||||
print(f"YOUR NUMBER WAS {d}, RIGHT?")
|
||||
|
||||
if response := get_yes_or_no():
|
||||
if _response := get_yes_or_no():
|
||||
print("HOW ABOUT THAT!!")
|
||||
else:
|
||||
print("I FEEL YOUR ARITHMETIC IS IN ERROR.")
|
||||
|
||||
@@ -78,14 +78,14 @@ def main() -> None:
|
||||
|
||||
# Start game loop
|
||||
input("\nPress Enter to start the Game:\n")
|
||||
end = False
|
||||
_end = False
|
||||
while True:
|
||||
game.print_pegs()
|
||||
|
||||
# Players Move
|
||||
command = input("\nYOUR MOVE - Number of PILE, Number of Object? ")
|
||||
game.remove_pegs(command)
|
||||
if end := game.check_for_win():
|
||||
if _end := game.check_for_win():
|
||||
print("\nPlayer Wins the Game, Congratulations!!")
|
||||
input("\nPress any key to exit")
|
||||
break
|
||||
@@ -96,7 +96,7 @@ def main() -> None:
|
||||
f"\nA.I MOVE - A.I Removed {ai_command[1]} pegs from Pile {ai_command[0]}"
|
||||
)
|
||||
game.remove_pegs(f"{str(ai_command[0])},{str(ai_command[1])}")
|
||||
if end := game.check_for_win():
|
||||
if _end := game.check_for_win():
|
||||
print("\nComputer Wins the Game, Better Luck Next Time\n")
|
||||
input("Press any key to exit")
|
||||
break
|
||||
|
||||
@@ -155,7 +155,7 @@ def main() -> None:
|
||||
|
||||
player_name = print_instructions()
|
||||
|
||||
if more_directions := yes_no_prompt("DO YOU NEED MORE DIRECTIONS?"):
|
||||
if _more_directions := yes_no_prompt("DO YOU NEED MORE DIRECTIONS?"):
|
||||
print_more_directions(player_name)
|
||||
|
||||
understand = yes_no_prompt("UNDERSTAND?")
|
||||
|
||||
@@ -171,7 +171,7 @@ def display(game: TicTacToe) -> None:
|
||||
if game.board[i][game.dim_sz - 1] == "blur":
|
||||
line1 = line1 + " \n"
|
||||
else:
|
||||
line1 = f"{line1} {game.board[i][game.dim_sz - 1]}" + " \n"
|
||||
line1 = f"{line1} {game.board[i][game.dim_sz - 1]} \n"
|
||||
print(line1, "\n\n")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user