diff options
author | 2023-05-09 16:01:01 +0100 | |
---|---|---|
committer | 2023-05-09 16:01:01 +0100 | |
commit | c3e23e60278d34658f801bd7d7ed721d5a272637 (patch) | |
tree | e159a0fae7850d706d713cf2b49dfed2140ce655 /bot/exts/fun/hangman.py | |
parent | Bump sentry-sdk from 1.21.1 to 1.22.1 (#1273) (diff) | |
parent | Move unshared contants inside modules (diff) |
Merge pull request #1270 from python-discord/migrate-to-ruff
Migrate to ruff
Diffstat (limited to 'bot/exts/fun/hangman.py')
-rw-r--r-- | bot/exts/fun/hangman.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/bot/exts/fun/hangman.py b/bot/exts/fun/hangman.py index f385a955..7a02a552 100644 --- a/bot/exts/fun/hangman.py +++ b/bot/exts/fun/hangman.py @@ -89,7 +89,7 @@ class Hangman(commands.Cog): word = choice(filtered_words) # `pretty_word` is used for comparing the indices where the guess of the user is similar to the word # The `user_guess` variable is prettified by adding spaces between every dash, and so is the `pretty_word` - pretty_word = ''.join([f"{letter} " for letter in word])[:-1] + pretty_word = "".join([f"{letter} " for letter in word])[:-1] user_guess = ("_ " * len(word))[:-1] tries = 6 guessed_letters = set() @@ -104,7 +104,7 @@ class Hangman(commands.Cog): )) # Game loop - while user_guess.replace(' ', '') != word: + while user_guess.replace(" ", "") != word: # Edit the message to the current state of the game await original_message.edit(embed=self.create_embed(tries, user_guess)) @@ -136,7 +136,7 @@ class Hangman(commands.Cog): continue # Checks for repeated guesses - elif normalized_content in guessed_letters: + if normalized_content in guessed_letters: already_guessed_embed = Embed( title=choice(NEGATIVE_REPLIES), description=f"You have already guessed `{normalized_content}`, try again!", @@ -146,12 +146,11 @@ class Hangman(commands.Cog): continue # Checks for correct guesses from the user - elif normalized_content in word: + if normalized_content in word: positions = {idx for idx, letter in enumerate(pretty_word) if letter == normalized_content} user_guess = "".join( [normalized_content if index in positions else dash for index, dash in enumerate(user_guess)] ) - else: tries -= 1 |