Skip to content

Commit 8b33302

Browse files
committed
Improved hangman
1 parent a162992 commit 8b33302

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

cogs/games.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ async def _wumpus(self, ctx):
215215
"""Play Wumpus game"""
216216
await wumpus.play(self.bot, ctx)
217217

218-
@commands.command(name='hangman')
218+
@commands.command(name='hangman', aliases=['hang'])
219219
async def hangman(self, ctx):
220220
"""Play Hangman"""
221221
await hangman.play(self.bot, ctx)

games/hangman.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
11
import random
22
import asyncio
33

4-
words = ['rainbow', 'computer', 'science', 'programming',
5-
'python', 'mathematics', 'player', 'condition',
6-
'reverse', 'water', 'board', 'geek']
7-
4+
words = ['conversation', 'bowtie', 'skateboard', 'penguin', 'hospital', 'player', 'kangaroo',
5+
'garbage', 'whisper', 'achievement', 'flamingo', 'calculator', 'offense', 'spring',
6+
'performance', 'sunburn', 'reverse', 'round', 'horse', 'nightmare', 'popcorn',
7+
'hockey', 'exercise', 'programming', 'platypus', 'blading', 'music', 'opponent',
8+
'electricity', 'telephone', 'scissors', 'pressure', 'monkey', 'coconut', 'backbone',
9+
'rainbow', 'frequency', 'factory', 'cholesterol', 'lighthouse', 'president', 'palace',
10+
'excellent', 'telescope', 'python', 'government', 'pineapple', 'volcano', 'alcohol',
11+
'mailman', 'nature', 'dashboard', 'science', 'computer', 'circus', 'earthquake', 'bathroom',
12+
'toast', 'football', 'cowboy', 'mattress', 'translate', 'entertainment', 'glasses',
13+
'download', 'water', 'violence', 'whistle', 'alligator', 'independence', 'pizza',
14+
'permission', 'board', 'pirate', 'battery', 'outside', 'condition', 'shallow', 'baseball',
15+
'lightsaber', 'dentist', 'pinwheel', 'snowflake', 'stomach', 'reference', 'password', 'strength',
16+
'mushroom', 'student', 'mathematics', 'instruction', 'newspaper', 'gingerbread',
17+
'emergency', 'lawnmower', 'industry', 'evidence', 'dominoes', 'lightbulb', 'stingray',
18+
'background', 'atmosphere', 'treasure', 'mosquito', 'popsicle', 'aircraft', 'photograph',
19+
'imagination', 'landscape', 'digital', 'pepper', 'roller', 'bicycle', 'toothbrush', 'newsletter']
20+
21+
images = ['```\n +---+\n O | \n /|\\ | \n / \\ | \n ===```',
22+
'```\n +---+ \n O | \n /|\\ | \n / | \n ===```',
23+
'```\n +---+ \n O | \n /|\\ | \n | \n ===```',
24+
'```\n +---+ \n O | \n /| | \n | \n ===```',
25+
'```\n +---+ \n O | \n | | \n | \n ===```',
26+
'```\n +---+ \n O | \n | \n | \n ===```',
27+
'```\n +---+ \n | \n | \n | \n ===```']
828
async def play(bot, ctx):
929
def check(m):
1030
return m.author == ctx.author
1131
guesses = ''
12-
turns = 8
32+
turns = 6
1333
word = random.choice(words)
1434
await ctx.send("Guess the characters:")
15-
guess_msg = await ctx.send(f"Guesses left: `{turns}`")
35+
guess_msg = await ctx.send(images[turns])
1636
word_msg = await ctx.send(f"`{' '.join('_'*len(word))}`")
1737
while turns > 0:
1838
out = ''
@@ -47,6 +67,7 @@ def check(m):
4767
if guess not in word:
4868
turns -= 1
4969
await ctx.send("Wrong :x:", delete_after=1.0)
50-
await guess_msg.edit(content=f"Guesses left: `{turns}`")
70+
await guess_msg.edit(content=images[turns])
5171
if turns == 0:
72+
await word_msg.edit(content=f'**{word}**')
5273
return await ctx.send("You Loose :x:")

0 commit comments

Comments
 (0)