A simple Hangman game module for Discord bots
Project description
Usage
Here's how you can use the Hangman class in your Discord bot:
python
Import the Hangman class
from void-hangman import Hangman
Create a new game instance
game = Hangman()
Make a guess
result = game.guess('a') # Guess a letter
current_word = game.get_display_word() # This will show the current guessed letters
Check if the game is over
if game.is_game_over(): if game.is_word_guessed(): print("You've guessed the word!") else: print("Game over! The word was:", game.word)
Methods
__init__(self): Initializes a new Hangman game with a random word and resets attempts.guess(letter): Takes a letter as input, checks if it's in the word, and updates the game state.get_display_word(): Returns the current state of the word with guessed letters revealed.is_game_over(): Checks if the game is over (either the word is guessed or attempts are exhausted).is_word_guessed(): Checks if the player has successfully guessed the word.get_attempts_left(): Returns the number of attempts left.get_hangman_visual(): Returns the current visual representation of the hangman based on attempts left.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file voidhangman-0.1.1.tar.gz.
File metadata
- Download URL: voidhangman-0.1.1.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14ad671c0f5b44fa9e4b157f4fe1bc907bc5477f700bbbe9c405a9b4cf5df098
|
|
| MD5 |
b964a3a419944245a4f82637c7334f34
|
|
| BLAKE2b-256 |
f59bdcc60889bc06c4d0b9de8cab94a9beec39a67b6dd3fbafe6940cd0115eb6
|
File details
Details for the file VoidHangman-0.1.1-py3-none-any.whl.
File metadata
- Download URL: VoidHangman-0.1.1-py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64b167e6285801ec33d53206d5225aa744046f8bf10196314e59d73cca29c4b0
|
|
| MD5 |
481e180166fac3d630e4222e257dde0f
|
|
| BLAKE2b-256 |
3d48efad6bd93fbf4398ab09e99765f7762a5171e91ebd89a0feafda108d10a9
|