Skip to content

Commit

Permalink
Improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Arisan committed Nov 20, 2020
1 parent f70908b commit 3de5f8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,16 @@ async def play_hangman(ctx, word):
if word[i] == message_content:
current_string[i] = message_content
if '#' not in current_string:
await ctx.send(' '.join(current_string))
await ctx.send('You won!')
await ctx.send(' '.join(current_string) + '\n' + 'You won!')
return
await ctx.send(hangman_visuals[tries])
await ctx.send('Letters tried: {}'.format(','.join(sorted(prev_letters))))
await ctx.send(' '.join(current_string))
response = '{}\nLetters tried: {}\n{}'\
.format(hangman_visuals[tries], ','.join(sorted(prev_letters)), ' '.join(current_string))
await ctx.send(response)
else:
tries += 1
await ctx.send(hangman_visuals[tries])
await ctx.send('Letters tried: {}'.format(', '.join(sorted(prev_letters))))
await ctx.send(' '.join(current_string))
response = '{}\nLetters tried: {}\n{}' \
.format(hangman_visuals[tries], ','.join(sorted(prev_letters)), ' '.join(current_string))
await ctx.send(response)
if tries == 6:
await ctx.send('Game Over. The word was {}.'.format(''.join(word)))
await ctx.invoke(bot.get_command('fall'))
Expand Down
2 changes: 1 addition & 1 deletion hangman_visual.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
+---+
| |
| |
|
|
|
Expand Down

0 comments on commit 3de5f8e

Please sign in to comment.