hangman-p 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hangman_p-0.1.0/PKG-INFO +103 -0
- hangman_p-0.1.0/README.md +93 -0
- hangman_p-0.1.0/hangman_p/__init__.py +2 -0
- hangman_p-0.1.0/hangman_p/__main__.py +5 -0
- hangman_p-0.1.0/hangman_p/dictionary.txt +41211 -0
- hangman_p-0.1.0/hangman_p/game_engine.py +144 -0
- hangman_p-0.1.0/hangman_p/game_persistence.py +76 -0
- hangman_p-0.1.0/hangman_p/level.py +66 -0
- hangman_p-0.1.0/hangman_p/messages.py +79 -0
- hangman_p-0.1.0/hangman_p/project.py +70 -0
- hangman_p-0.1.0/hangman_p/utilities.py +46 -0
- hangman_p-0.1.0/hangman_p.egg-info/PKG-INFO +103 -0
- hangman_p-0.1.0/hangman_p.egg-info/SOURCES.txt +17 -0
- hangman_p-0.1.0/hangman_p.egg-info/dependency_links.txt +1 -0
- hangman_p-0.1.0/hangman_p.egg-info/entry_points.txt +3 -0
- hangman_p-0.1.0/hangman_p.egg-info/requires.txt +3 -0
- hangman_p-0.1.0/hangman_p.egg-info/top_level.txt +1 -0
- hangman_p-0.1.0/pyproject.toml +22 -0
- hangman_p-0.1.0/setup.cfg +4 -0
hangman_p-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hangman-p
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A command-line Hangman game.
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: inflect>=7.5.0
|
|
8
|
+
Requires-Dist: maskpass>=0.3.7
|
|
9
|
+
Requires-Dist: termcolor>=3.3.0
|
|
10
|
+
|
|
11
|
+
# Hangman
|
|
12
|
+
|
|
13
|
+
#### Video Demo: _[CS50P Final project demo](https://youtu.be/2FduPPZd-YU)_
|
|
14
|
+
|
|
15
|
+
### Description
|
|
16
|
+
|
|
17
|
+
**_Hangman_** is a command-line word-guessing game implemented in Python.
|
|
18
|
+
Players attempt to guess a hidden word one letter at a time before running out of chances. The game supports multiple difficulty levels, game persistence (saving and loading games), and multiplayer challenge mode.
|
|
19
|
+
|
|
20
|
+
This project demonstrates concepts such as object-oriented design, input validation, persistence using pickle, modular architecture, and automated testing with pytest.
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
* Three difficulty levels with different word lengths
|
|
24
|
+
* Multiplayer challenge mode
|
|
25
|
+
* Game saving and loading
|
|
26
|
+
* Automatic deletion of completed saved games
|
|
27
|
+
* Input validation and error handling
|
|
28
|
+
* Automated unit tests using pytest
|
|
29
|
+
* CLI-based interactive gameplay
|
|
30
|
+
|
|
31
|
+
### Usage
|
|
32
|
+
|
|
33
|
+
This game is a REPL game, i.e it is being played from and with the Terminal.
|
|
34
|
+
|
|
35
|
+
To run it locally from this repository:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python project.py
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
After installing it as a package, run:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
hangman-p
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
You can also run it as a Python module:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
python -m hangman_p
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
To build distribution files for publishing:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv build
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
This creates a wheel and source distribution in `dist/`. To upload them to PyPI after configuring a PyPI API token:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
uv publish
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Once started, the game is very intuitive and easy to follow.
|
|
66
|
+
|
|
67
|
+
###"Welcome to Hangman, the no-nonsense game Be smart, then you live. if not, you'll have to die by Hanging. You have a couple of options to pick from..... Press 'P' or 'play' if you think you are ready for the challenge, You may press 'I' or 'instructions' for a short explanation of how to play You may continue a previously saved game by pressing 'L' or 'load' Or you could just quit by pressing a 'Q' or typing 'quit'" "The word to guess is represented by a row of dashes These dashes represent each letter of the word. Words you cannot use include proper nouns such as names, places, and brands. If the guessing player suggests a letter which occurs in the word, the other player writes it in all its correct positions."
|
|
68
|
+
|
|
69
|
+
The guessing player must guess all of the letters of the word within a limited amount of chances. Failure to do so will result in his death by hanging.
|
|
70
|
+
|
|
71
|
+
#### Important note
|
|
72
|
+
In human mode, if the player is typing his word, it will not be displayed on the screen, it will be masked so as not to give the challenged player undue advantage.
|
|
73
|
+
|
|
74
|
+
#### Extras
|
|
75
|
+
>You can actually reveal the word by pressing `:c` or `cheat`. This is a cheat for solving the problem and it is not recommended.
|
|
76
|
+
|
|
77
|
+
>You can quit at any point by pressing `:q` or typing `quit` whereby you will be asked if you want to save the game or just quit. (The option to save is only available in the computer mode.)
|
|
78
|
+
>
|
|
79
|
+
>If you press `:h` or type `history`, a list showing your guesses will be displayed.
|
|
80
|
+
|
|
81
|
+
### Project structure
|
|
82
|
+
```bash
|
|
83
|
+
project.py # Main entry point
|
|
84
|
+
hangman_p/level.py # Difficulty configuration
|
|
85
|
+
hangman_p/game_engine.py # Core gameplay logic
|
|
86
|
+
hangman_p/utilities.py # Helper input validation utilities
|
|
87
|
+
hangman_p/dictionary.txt # list of possible words to be used (Computer mode)
|
|
88
|
+
hangman_p/game_persistence.py # Save/load game handling
|
|
89
|
+
pyproject.toml # package metadata and dependencies
|
|
90
|
+
test_project.py # pytest file
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Design Decisions
|
|
94
|
+
* **Object-oriented structure:** I wasn't sure whether to use OOP or procedural paradigm. After thinking about what I will like to achieve, I decided that OOP was more convenient as it will handle game states more easily.
|
|
95
|
+
* **Pickle-based persistence:** I had the option of shelve or json as well, but I decided to vote for pickle mainly because of its elegant serialization and deserialization of python objects
|
|
96
|
+
* **Modular utilities:** This decision was made after I found that I was validating inputs in several places of the program. I decided to extract the logic to `utilities.py` to make input validation reusable and testable.
|
|
97
|
+
* **Pytest fixtures:** were used for automated testing of interactive functions by monkeypatching input/output.
|
|
98
|
+
|
|
99
|
+
### Author
|
|
100
|
+
Mayowa Pitan
|
|
101
|
+
|
|
102
|
+
# Enjoy your Hangman experience and try not to be hanged...
|
|
103
|
+
good luck...
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Hangman
|
|
2
|
+
|
|
3
|
+
#### Video Demo: _[CS50P Final project demo](https://youtu.be/2FduPPZd-YU)_
|
|
4
|
+
|
|
5
|
+
### Description
|
|
6
|
+
|
|
7
|
+
**_Hangman_** is a command-line word-guessing game implemented in Python.
|
|
8
|
+
Players attempt to guess a hidden word one letter at a time before running out of chances. The game supports multiple difficulty levels, game persistence (saving and loading games), and multiplayer challenge mode.
|
|
9
|
+
|
|
10
|
+
This project demonstrates concepts such as object-oriented design, input validation, persistence using pickle, modular architecture, and automated testing with pytest.
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
* Three difficulty levels with different word lengths
|
|
14
|
+
* Multiplayer challenge mode
|
|
15
|
+
* Game saving and loading
|
|
16
|
+
* Automatic deletion of completed saved games
|
|
17
|
+
* Input validation and error handling
|
|
18
|
+
* Automated unit tests using pytest
|
|
19
|
+
* CLI-based interactive gameplay
|
|
20
|
+
|
|
21
|
+
### Usage
|
|
22
|
+
|
|
23
|
+
This game is a REPL game, i.e it is being played from and with the Terminal.
|
|
24
|
+
|
|
25
|
+
To run it locally from this repository:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
python project.py
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
After installing it as a package, run:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
hangman-p
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
You can also run it as a Python module:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
python -m hangman_p
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
To build distribution files for publishing:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
uv build
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This creates a wheel and source distribution in `dist/`. To upload them to PyPI after configuring a PyPI API token:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv publish
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Once started, the game is very intuitive and easy to follow.
|
|
56
|
+
|
|
57
|
+
###"Welcome to Hangman, the no-nonsense game Be smart, then you live. if not, you'll have to die by Hanging. You have a couple of options to pick from..... Press 'P' or 'play' if you think you are ready for the challenge, You may press 'I' or 'instructions' for a short explanation of how to play You may continue a previously saved game by pressing 'L' or 'load' Or you could just quit by pressing a 'Q' or typing 'quit'" "The word to guess is represented by a row of dashes These dashes represent each letter of the word. Words you cannot use include proper nouns such as names, places, and brands. If the guessing player suggests a letter which occurs in the word, the other player writes it in all its correct positions."
|
|
58
|
+
|
|
59
|
+
The guessing player must guess all of the letters of the word within a limited amount of chances. Failure to do so will result in his death by hanging.
|
|
60
|
+
|
|
61
|
+
#### Important note
|
|
62
|
+
In human mode, if the player is typing his word, it will not be displayed on the screen, it will be masked so as not to give the challenged player undue advantage.
|
|
63
|
+
|
|
64
|
+
#### Extras
|
|
65
|
+
>You can actually reveal the word by pressing `:c` or `cheat`. This is a cheat for solving the problem and it is not recommended.
|
|
66
|
+
|
|
67
|
+
>You can quit at any point by pressing `:q` or typing `quit` whereby you will be asked if you want to save the game or just quit. (The option to save is only available in the computer mode.)
|
|
68
|
+
>
|
|
69
|
+
>If you press `:h` or type `history`, a list showing your guesses will be displayed.
|
|
70
|
+
|
|
71
|
+
### Project structure
|
|
72
|
+
```bash
|
|
73
|
+
project.py # Main entry point
|
|
74
|
+
hangman_p/level.py # Difficulty configuration
|
|
75
|
+
hangman_p/game_engine.py # Core gameplay logic
|
|
76
|
+
hangman_p/utilities.py # Helper input validation utilities
|
|
77
|
+
hangman_p/dictionary.txt # list of possible words to be used (Computer mode)
|
|
78
|
+
hangman_p/game_persistence.py # Save/load game handling
|
|
79
|
+
pyproject.toml # package metadata and dependencies
|
|
80
|
+
test_project.py # pytest file
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Design Decisions
|
|
84
|
+
* **Object-oriented structure:** I wasn't sure whether to use OOP or procedural paradigm. After thinking about what I will like to achieve, I decided that OOP was more convenient as it will handle game states more easily.
|
|
85
|
+
* **Pickle-based persistence:** I had the option of shelve or json as well, but I decided to vote for pickle mainly because of its elegant serialization and deserialization of python objects
|
|
86
|
+
* **Modular utilities:** This decision was made after I found that I was validating inputs in several places of the program. I decided to extract the logic to `utilities.py` to make input validation reusable and testable.
|
|
87
|
+
* **Pytest fixtures:** were used for automated testing of interactive functions by monkeypatching input/output.
|
|
88
|
+
|
|
89
|
+
### Author
|
|
90
|
+
Mayowa Pitan
|
|
91
|
+
|
|
92
|
+
# Enjoy your Hangman experience and try not to be hanged...
|
|
93
|
+
good luck...
|