reznum-minesweeper 0.2.2__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.
Files changed (39) hide show
  1. reznum_minesweeper-0.2.2/CHANGELOG.md +31 -0
  2. reznum_minesweeper-0.2.2/CONTRIBUTING.md +62 -0
  3. reznum_minesweeper-0.2.2/LICENSE +21 -0
  4. reznum_minesweeper-0.2.2/MANIFEST.in +7 -0
  5. reznum_minesweeper-0.2.2/PKG-INFO +288 -0
  6. reznum_minesweeper-0.2.2/README.md +253 -0
  7. reznum_minesweeper-0.2.2/pyproject.toml +72 -0
  8. reznum_minesweeper-0.2.2/setup.cfg +4 -0
  9. reznum_minesweeper-0.2.2/src/minesweeper_cli/__init__.py +5 -0
  10. reznum_minesweeper-0.2.2/src/minesweeper_cli/__main__.py +7 -0
  11. reznum_minesweeper-0.2.2/src/minesweeper_cli/board.py +225 -0
  12. reznum_minesweeper-0.2.2/src/minesweeper_cli/cell.py +30 -0
  13. reznum_minesweeper-0.2.2/src/minesweeper_cli/cli.py +84 -0
  14. reznum_minesweeper-0.2.2/src/minesweeper_cli/config.py +62 -0
  15. reznum_minesweeper-0.2.2/src/minesweeper_cli/controls.py +97 -0
  16. reznum_minesweeper-0.2.2/src/minesweeper_cli/game.py +225 -0
  17. reznum_minesweeper-0.2.2/src/minesweeper_cli/menu.py +523 -0
  18. reznum_minesweeper-0.2.2/src/minesweeper_cli/persistence.py +83 -0
  19. reznum_minesweeper-0.2.2/src/minesweeper_cli/platform_compat.py +71 -0
  20. reznum_minesweeper-0.2.2/src/minesweeper_cli/py.typed +1 -0
  21. reznum_minesweeper-0.2.2/src/minesweeper_cli/records.py +137 -0
  22. reznum_minesweeper-0.2.2/src/minesweeper_cli/renderer.py +281 -0
  23. reznum_minesweeper-0.2.2/src/minesweeper_cli/settings.py +89 -0
  24. reznum_minesweeper-0.2.2/src/minesweeper_cli/themes.py +246 -0
  25. reznum_minesweeper-0.2.2/src/minesweeper_cli/timer.py +57 -0
  26. reznum_minesweeper-0.2.2/src/reznum_minesweeper.egg-info/PKG-INFO +288 -0
  27. reznum_minesweeper-0.2.2/src/reznum_minesweeper.egg-info/SOURCES.txt +37 -0
  28. reznum_minesweeper-0.2.2/src/reznum_minesweeper.egg-info/dependency_links.txt +1 -0
  29. reznum_minesweeper-0.2.2/src/reznum_minesweeper.egg-info/entry_points.txt +2 -0
  30. reznum_minesweeper-0.2.2/src/reznum_minesweeper.egg-info/requires.txt +8 -0
  31. reznum_minesweeper-0.2.2/src/reznum_minesweeper.egg-info/top_level.txt +1 -0
  32. reznum_minesweeper-0.2.2/tests/__init__.py +1 -0
  33. reznum_minesweeper-0.2.2/tests/test_board.py +192 -0
  34. reznum_minesweeper-0.2.2/tests/test_cli.py +55 -0
  35. reznum_minesweeper-0.2.2/tests/test_controls.py +61 -0
  36. reznum_minesweeper-0.2.2/tests/test_game.py +105 -0
  37. reznum_minesweeper-0.2.2/tests/test_integration.py +125 -0
  38. reznum_minesweeper-0.2.2/tests/test_records.py +79 -0
  39. reznum_minesweeper-0.2.2/tests/test_settings.py +70 -0
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.2.2] - 2026-09-19
9
+
10
+ ### Added
11
+ - Rich interactive Terminal User Interface (TUI) with responsive styling.
12
+ - 7 distinct color themes: Classic, Ocean, Matrix, Dracula, Cyberpunk, Nord, and Monochrome.
13
+ - Traditional Minesweeper engine with first-move protection guaranteeing a safe initial cell.
14
+ - Predefined difficulty levels: Easy (9x9), Medium (16x16), Hard (30x16), and Expert (30x24).
15
+ - Custom game mode with interactive dimension and mine count validation.
16
+ - Responsive board viewport scrolling for smaller terminals, phones, and Termux on Android.
17
+ - Cross-platform single-key input (`readchar`) with seamless fallback to line/command input mode.
18
+ - Fully customizable keybindings with collision validation and default reset.
19
+ - Persistent high scores, best completion times, and statistics per difficulty.
20
+ - Custom game statistics tracking.
21
+ - Dedicated "About the Creator" screen and comprehensive "How to Play" guide.
22
+ - CLI flags support: `--difficulty`, `--custom`, `--theme`, `--version`, and `--help`.
23
+ - Automated test suite covering board logic, game loop, persistence, settings, and CLI.
24
+ - GitHub Actions CI matrix for tests across Windows, Linux, and macOS.
25
+
26
+ ## [0.2.0] - 2026-08-15
27
+ - Prototype terminal board rendering.
28
+ - Basic cell reveal and flag mechanics.
29
+
30
+ ## [0.1.0] - 2026-07-01
31
+ - Initial core engine proof-of-concept.
@@ -0,0 +1,62 @@
1
+ # Contributing to Minesweeper CLI
2
+
3
+ Thank you for your interest in contributing to Minesweeper CLI! We welcome bug reports, feature suggestions, and pull requests.
4
+
5
+ ## Development Setup
6
+
7
+ 1. **Clone the repository:**
8
+ ```bash
9
+ git clone https://github.com/ItsReZNuM/Minesweeper-CLI.git
10
+ cd Minesweeper-CLI
11
+ ```
12
+
13
+ 2. **Create a virtual environment (recommended):**
14
+ ```bash
15
+ python -m venv .venv
16
+ # Windows:
17
+ .venv\Scripts\activate
18
+ # Linux/macOS:
19
+ source .venv/bin/activate
20
+ ```
21
+
22
+ 3. **Install the package in editable mode with development dependencies:**
23
+ ```bash
24
+ python -m pip install -e ".[dev]"
25
+ ```
26
+
27
+ 4. **Run the game:**
28
+ ```bash
29
+ minesweeper
30
+ # or
31
+ python -m minesweeper_cli
32
+ ```
33
+
34
+ ## Running Tests
35
+
36
+ Ensure all automated tests pass before submitting a pull request:
37
+ ```bash
38
+ python -m pytest tests/ -v
39
+ ```
40
+
41
+ ## Packaging Verification
42
+
43
+ Check distribution builds:
44
+ ```bash
45
+ python -m build
46
+ python -m twine check dist/*
47
+ ```
48
+
49
+ ## Code Guidelines
50
+
51
+ - Target **Python 3.10+**.
52
+ - Follow **PEP 8** style conventions.
53
+ - Maintain cross-platform compatibility (Windows, Linux, macOS, Android/Termux).
54
+ - Avoid unnecessary external dependencies.
55
+ - Keep comments concise and reserved for non-obvious algorithms or platform quirks.
56
+ - Write tests for new gameplay logic or CLI behaviors.
57
+
58
+ ## Submitting Pull Requests
59
+
60
+ 1. Create a feature branch: `git checkout -b feature/your-feature-name`.
61
+ 2. Commit changes using clear, descriptive messages.
62
+ 3. Push to your branch and open a Pull Request with a summary of changes.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ItsReZNuM
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ include CONTRIBUTING.md
5
+ include pyproject.toml
6
+ recursive-include src/minesweeper_cli *.py py.typed
7
+ recursive-include tests *.py
@@ -0,0 +1,288 @@
1
+ Metadata-Version: 2.4
2
+ Name: reznum-minesweeper
3
+ Version: 0.2.2
4
+ Summary: A modern, beautiful, and interactive terminal Minesweeper game written in Python with Rich.
5
+ Author: ItsReZNuM
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ItsReZNuM/Minesweeper-CLI
8
+ Project-URL: Repository, https://github.com/ItsReZNuM/Minesweeper-CLI
9
+ Project-URL: Issues, https://github.com/ItsReZNuM/Minesweeper-CLI/issues
10
+ Project-URL: Changelog, https://github.com/ItsReZNuM/Minesweeper-CLI/blob/main/CHANGELOG.md
11
+ Keywords: minesweeper,cli,terminal,game,rich,cross-platform,termux,retro,tui
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: End Users/Desktop
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Games/Entertainment :: Board Games
22
+ Classifier: Topic :: Games/Entertainment :: Puzzle Games
23
+ Classifier: Topic :: Terminals
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: rich>=13.0.0
28
+ Requires-Dist: readchar>=4.0.0
29
+ Requires-Dist: platformdirs>=3.0.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
32
+ Requires-Dist: build>=1.0.0; extra == "dev"
33
+ Requires-Dist: twine>=5.0.0; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # Minesweeper CLI ๐Ÿ’ฃ
37
+
38
+ [![PyPI Version](https://img.shields.io/pypi/v/reznum-minesweeper.svg)](https://pypi.org/project/reznum-minesweeper/)
39
+ [![Tests & Lint](https://github.com/ItsReZNuM/Minesweeper-CLI/actions/workflows/tests.yml/badge.svg)](https://github.com/ItsReZNuM/Minesweeper-CLI/actions/workflows/tests.yml)
40
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
41
+ [![Python Version](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://www.python.org/)
42
+ [![Code Style](https://img.shields.io/badge/code%20style-pep8-brightgreen.svg)](https://pep8.org/)
43
+
44
+ A modern, colorful, production-quality terminal Minesweeper game built in Python using [Rich](https://github.com/Textualize/rich). Designed for cross-platform play across Windows (CMD, PowerShell, Windows Terminal), Linux, macOS, SSH, and Android (Termux).
45
+
46
+ ```text
47
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
48
+ โ”‚ ๐Ÿ’ฃ MINESWEEPER CLI ๐Ÿ’ฃ โ”‚
49
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
50
+ โ”‚ Medium ๐Ÿ’ฃ Mines: 40 ๐Ÿšฉ Flags: 12 Left: 28 โฑ๏ธ 01:42 โ”‚
51
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
52
+ โ”‚ Minesweeper Board โ”‚
53
+ โ”‚ 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 โ”‚
54
+ โ”‚ 0 โ”‚ ยท ยท 1 โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ”‚
55
+ โ”‚ 1 โ”‚ 1 1 2 โ–  [2] โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ”‚
56
+ โ”‚ 2 โ”‚ 0 0 1 โ–  ๐Ÿšฉ โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ”‚
57
+ โ”‚ 3 โ”‚ 0 0 1 1 2 โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ”‚
58
+ โ”‚ 4 โ”‚ 1 1 0 0 1 โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ”‚
59
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
60
+ ```
61
+
62
+ ---
63
+
64
+ ## โœจ Features
65
+
66
+ - **First-Move Protection**: Your first clicked tile is guaranteed safe and opens up the initial clearing.
67
+ - **7 Visual Themes**: Classic, Ocean, Matrix, Dracula, Cyberpunk, Nord, and Monochrome.
68
+ - **Predefined Difficulties**:
69
+ - **Easy**: 9x9 board with 10 mines
70
+ - **Medium**: 16x16 board with 40 mines
71
+ - **Hard**: 30x16 board with 99 mines
72
+ - **Expert**: 30x24 board with 150 mines
73
+ - **Custom Board Mode**: Configure your own width (4โ€“60), height (4โ€“40), and mine density.
74
+ - **Chord Reveal**: Press `C` on a revealed number when all surrounding flags are placed to instantly open remaining neighbors.
75
+ - **Cross-Platform Single-Key Input**: Responsive single-key control (`readchar`) with automatic fallback to Enter-based command mode if raw terminal mode is unavailable.
76
+ - **Responsive Layout & Viewport Scrolling**: Auto-scrolls and pans around the cursor on small screens, preventing broken line wraps in mobile terminals like Termux.
77
+ - **Configurable Controls**: Remap any gameplay action with key conflict validation.
78
+ - **Persistent High Scores & Statistics**: Tracks completion best times, total games played, wins, losses, and custom configurations.
79
+ - **Zero Heavy Frameworks**: Pure Python with lightweight, high-performance terminal rendering.
80
+
81
+ ---
82
+
83
+ ## ๐Ÿš€ Installation
84
+
85
+ ### Local Development Installation (Current)
86
+
87
+ Clone the repository and install in editable mode:
88
+
89
+ ```bash
90
+ git clone https://github.com/ItsReZNuM/Minesweeper-CLI.git
91
+ cd Minesweeper-CLI
92
+ python -m pip install -e .
93
+ ```
94
+
95
+ You can now run the game directly:
96
+
97
+ ```bash
98
+ minesweeper
99
+ ```
100
+
101
+ Or run via module execution without PATH modification:
102
+
103
+ ```bash
104
+ python -m minesweeper_cli
105
+ ```
106
+
107
+ ### PyPI Installation
108
+
109
+ Install directly from PyPI:
110
+
111
+ ```bash
112
+ pip install reznum-minesweeper
113
+ minesweeper
114
+ ```
115
+
116
+ ---
117
+
118
+ ## ๐ŸŽฎ How to Play & Controls
119
+
120
+ Navigate the cursor over tiles, reveal safe cells, and flag suspected mines.
121
+
122
+ ### Default Controls
123
+
124
+ | Action | Default Keys | Description |
125
+ | :--- | :--- | :--- |
126
+ | **Move Cursor** | `W` / `A` / `S` / `D` or `Arrow Keys` | Move cursor Up, Left, Down, Right |
127
+ | **Reveal Cell** | `Enter` or `Space` | Open hidden cell at cursor |
128
+ | **Toggle Flag** | `F` | Place or remove a flag on cursor |
129
+ | **Chord Reveal**| `C` | Open all adjacent unflagged cells |
130
+ | **Restart Game**| `R` | Reset and generate a fresh board |
131
+ | **Quit to Menu**| `Q` or `Esc` | Return to main menu |
132
+
133
+ ### Fallback Command Mode
134
+
135
+ If running in non-interactive terminals, redirected streams, or legacy shells without raw input support:
136
+ - Type `w`, `a`, `s`, `d` to move.
137
+ - Type `r` to reveal or `f` to flag.
138
+ - Type direct coordinates: `r <x> <y>` to reveal cell `(x, y)` or `f <x> <y>` to flag `(x, y)`.
139
+ - Type `q` to return to the menu.
140
+
141
+ ---
142
+
143
+ ## โš™๏ธ Command-Line Arguments
144
+
145
+ Launch directly into specific game modes or themes:
146
+
147
+ ```bash
148
+ # Display help and usage
149
+ minesweeper --help
150
+
151
+ # Display version
152
+ minesweeper --version
153
+
154
+ # Directly launch specific difficulty preset
155
+ minesweeper --difficulty easy
156
+ minesweeper --difficulty medium
157
+ minesweeper --difficulty hard
158
+ minesweeper --difficulty expert
159
+
160
+ # Directly open custom board configuration dialog
161
+ minesweeper --custom
162
+
163
+ # Select a visual theme on launch
164
+ minesweeper --theme matrix
165
+ ```
166
+
167
+ ---
168
+
169
+ ## ๐ŸŽจ Themes Showcase
170
+
171
+ Themes alter board colors, borders, menus, status indicators, and numbers 1โ€“8:
172
+
173
+ 1. **Classic**: Traditional Windows Minesweeper palette with bright primary numbers.
174
+ 2. **Matrix**: Digital phosphor rain with emerald borders and hacker aesthetic.
175
+ 3. **Ocean**: Deep blues, cyan reefs, and serene marine highlights.
176
+ 4. **Dracula**: Modern dark mode with purple, pink, and vibrant accents.
177
+ 5. **Cyberpunk**: High-voltage neon yellow, electric magenta, and neon cyan.
178
+ 6. **Nord**: Cool arctic blues, slate gray, and pastel typography.
179
+ 7. **Monochrome**: High-contrast grayscale suitable for any 8-color terminal or monochrome display.
180
+
181
+ You can switch themes in **Settings > Theme** or via `minesweeper --theme <name>`.
182
+
183
+ ---
184
+
185
+ ## ๐Ÿ“ฑ Termux & Mobile Compatibility
186
+
187
+ Minesweeper CLI is built to run smoothly on Android via **Termux**:
188
+ - Viewport auto-centers around the cursor when boards are wider than the terminal.
189
+ - Supports compact rendering mode (`Settings > Compact Mode: ON` or auto-detected).
190
+ - Uses standard terminal character fallbacks if your mobile font lacks full Unicode emoji support.
191
+
192
+ To install on Termux:
193
+ ```bash
194
+ pkg update && pkg install python git
195
+ git clone https://github.com/ItsReZNuM/Minesweeper-CLI.git
196
+ cd Minesweeper-CLI
197
+ pip install -e .
198
+ minesweeper
199
+ ```
200
+
201
+ ---
202
+
203
+ ## ๐Ÿ“ Project Structure
204
+
205
+ ```text
206
+ Minesweeper-CLI/
207
+ โ”œโ”€โ”€ .github/
208
+ โ”‚ โ””โ”€โ”€ workflows/
209
+ โ”‚ โ”œโ”€โ”€ tests.yml # CI test matrix (Python 3.10-3.13 on Linux/Win/macOS)
210
+ โ”‚ โ””โ”€โ”€ release.yml # Release packaging automation
211
+ โ”œโ”€โ”€ src/
212
+ โ”‚ โ””โ”€โ”€ minesweeper_cli/
213
+ โ”‚ โ”œโ”€โ”€ __init__.py # Package version and metadata
214
+ โ”‚ โ”œโ”€โ”€ __main__.py # python -m minesweeper_cli entrypoint
215
+ โ”‚ โ”œโ”€โ”€ board.py # Pure engine logic, flood-fill, chords, win/loss
216
+ โ”‚ โ”œโ”€โ”€ cell.py # Cell data structure and state
217
+ โ”‚ โ”œโ”€โ”€ cli.py # Command-line argument parsing and dispatcher
218
+ โ”‚ โ”œโ”€โ”€ config.py # Difficulty presets and application constants
219
+ โ”‚ โ”œโ”€โ”€ controls.py # Action mappings, key normalization, conflict checks
220
+ โ”‚ โ”œโ”€โ”€ game.py # Interactive game session and viewport scrolling
221
+ โ”‚ โ”œโ”€โ”€ menu.py # Main menu, custom dialogs, settings, records
222
+ โ”‚ โ”œโ”€โ”€ persistence.py # Atomic filesystem storage using platformdirs
223
+ โ”‚ โ”œโ”€โ”€ platform_compat.py # Cross-platform single-key reader & fallback
224
+ โ”‚ โ”œโ”€โ”€ records.py # Best times and gameplay statistics tracker
225
+ โ”‚ โ”œโ”€โ”€ renderer.py # Rich terminal UI components and styling
226
+ โ”‚ โ”œโ”€โ”€ settings.py # User configuration and keybinding storage
227
+ โ”‚ โ”œโ”€โ”€ themes.py # 7 distinct color themes
228
+ โ”‚ โ”œโ”€โ”€ timer.py # Non-busy monotonic gameplay duration timer
229
+ โ”‚ โ””โ”€โ”€ py.typed # PEP 561 type marker
230
+ โ”œโ”€โ”€ tests/
231
+ โ”‚ โ”œโ”€โ”€ test_board.py # Board generation, rules, chords, win/loss
232
+ โ”‚ โ”œโ”€โ”€ test_cli.py # CLI flags and arguments
233
+ โ”‚ โ”œโ”€โ”€ test_controls.py # Control mappings and conflict validation
234
+ โ”‚ โ”œโ”€โ”€ test_game.py # Viewport calculation and command parser
235
+ โ”‚ โ”œโ”€โ”€ test_records.py # Statistics, best times, custom records
236
+ โ”‚ โ””โ”€โ”€ test_settings.py # Settings persistence and corrupted data recovery
237
+ โ”œโ”€โ”€ CHANGELOG.md # Semantic version history
238
+ โ”œโ”€โ”€ CONTRIBUTING.md # Contribution guidelines
239
+ โ”œโ”€โ”€ LICENSE # MIT License
240
+ โ”œโ”€โ”€ MANIFEST.in # Package manifest
241
+ โ”œโ”€โ”€ pyproject.toml # Modern PEP 517/621 packaging configuration
242
+ โ””โ”€โ”€ README.md
243
+ ```
244
+
245
+ ---
246
+
247
+ ## ๐Ÿงช Testing
248
+
249
+ Run the automated test suite with `pytest`:
250
+
251
+ ```bash
252
+ python -m pytest tests/ -v
253
+ ```
254
+
255
+ ---
256
+
257
+ ## ๐Ÿ“ฆ Building and Packaging
258
+
259
+ Build the source distribution and wheel:
260
+
261
+ ```bash
262
+ python -m build
263
+ ```
264
+
265
+ Verify the distribution packages:
266
+
267
+ ```bash
268
+ python -m twine check dist/*
269
+ ```
270
+
271
+ ---
272
+
273
+ ## ๐Ÿ‘ค Author
274
+
275
+ **Made with โค๏ธ by ItsReZNuM**
276
+
277
+ - **GitHub Profile**: [https://github.com/ItsReZNuM](https://github.com/ItsReZNuM)
278
+ - **Repository**: [https://github.com/ItsReZNuM/Minesweeper-CLI](https://github.com/ItsReZNuM/Minesweeper-CLI)
279
+ - **Telegram**: [https://t.me/ItsReZNuM](https://t.me/ItsReZNuM)
280
+ - **Instagram**: [https://instagram.com/rez.num](https://instagram.com/rez.num)
281
+
282
+ โญ **Enjoying the game?** Please consider starring the repository on GitHub! It means a lot and supports future development.
283
+
284
+ ---
285
+
286
+ ## ๐Ÿ“„ License
287
+
288
+ This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,253 @@
1
+ # Minesweeper CLI ๐Ÿ’ฃ
2
+
3
+ [![PyPI Version](https://img.shields.io/pypi/v/reznum-minesweeper.svg)](https://pypi.org/project/reznum-minesweeper/)
4
+ [![Tests & Lint](https://github.com/ItsReZNuM/Minesweeper-CLI/actions/workflows/tests.yml/badge.svg)](https://github.com/ItsReZNuM/Minesweeper-CLI/actions/workflows/tests.yml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Python Version](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://www.python.org/)
7
+ [![Code Style](https://img.shields.io/badge/code%20style-pep8-brightgreen.svg)](https://pep8.org/)
8
+
9
+ A modern, colorful, production-quality terminal Minesweeper game built in Python using [Rich](https://github.com/Textualize/rich). Designed for cross-platform play across Windows (CMD, PowerShell, Windows Terminal), Linux, macOS, SSH, and Android (Termux).
10
+
11
+ ```text
12
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
13
+ โ”‚ ๐Ÿ’ฃ MINESWEEPER CLI ๐Ÿ’ฃ โ”‚
14
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
15
+ โ”‚ Medium ๐Ÿ’ฃ Mines: 40 ๐Ÿšฉ Flags: 12 Left: 28 โฑ๏ธ 01:42 โ”‚
16
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
17
+ โ”‚ Minesweeper Board โ”‚
18
+ โ”‚ 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 โ”‚
19
+ โ”‚ 0 โ”‚ ยท ยท 1 โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ”‚
20
+ โ”‚ 1 โ”‚ 1 1 2 โ–  [2] โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ”‚
21
+ โ”‚ 2 โ”‚ 0 0 1 โ–  ๐Ÿšฉ โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ”‚
22
+ โ”‚ 3 โ”‚ 0 0 1 1 2 โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ”‚
23
+ โ”‚ 4 โ”‚ 1 1 0 0 1 โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ–  โ”‚
24
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
25
+ ```
26
+
27
+ ---
28
+
29
+ ## โœจ Features
30
+
31
+ - **First-Move Protection**: Your first clicked tile is guaranteed safe and opens up the initial clearing.
32
+ - **7 Visual Themes**: Classic, Ocean, Matrix, Dracula, Cyberpunk, Nord, and Monochrome.
33
+ - **Predefined Difficulties**:
34
+ - **Easy**: 9x9 board with 10 mines
35
+ - **Medium**: 16x16 board with 40 mines
36
+ - **Hard**: 30x16 board with 99 mines
37
+ - **Expert**: 30x24 board with 150 mines
38
+ - **Custom Board Mode**: Configure your own width (4โ€“60), height (4โ€“40), and mine density.
39
+ - **Chord Reveal**: Press `C` on a revealed number when all surrounding flags are placed to instantly open remaining neighbors.
40
+ - **Cross-Platform Single-Key Input**: Responsive single-key control (`readchar`) with automatic fallback to Enter-based command mode if raw terminal mode is unavailable.
41
+ - **Responsive Layout & Viewport Scrolling**: Auto-scrolls and pans around the cursor on small screens, preventing broken line wraps in mobile terminals like Termux.
42
+ - **Configurable Controls**: Remap any gameplay action with key conflict validation.
43
+ - **Persistent High Scores & Statistics**: Tracks completion best times, total games played, wins, losses, and custom configurations.
44
+ - **Zero Heavy Frameworks**: Pure Python with lightweight, high-performance terminal rendering.
45
+
46
+ ---
47
+
48
+ ## ๐Ÿš€ Installation
49
+
50
+ ### Local Development Installation (Current)
51
+
52
+ Clone the repository and install in editable mode:
53
+
54
+ ```bash
55
+ git clone https://github.com/ItsReZNuM/Minesweeper-CLI.git
56
+ cd Minesweeper-CLI
57
+ python -m pip install -e .
58
+ ```
59
+
60
+ You can now run the game directly:
61
+
62
+ ```bash
63
+ minesweeper
64
+ ```
65
+
66
+ Or run via module execution without PATH modification:
67
+
68
+ ```bash
69
+ python -m minesweeper_cli
70
+ ```
71
+
72
+ ### PyPI Installation
73
+
74
+ Install directly from PyPI:
75
+
76
+ ```bash
77
+ pip install reznum-minesweeper
78
+ minesweeper
79
+ ```
80
+
81
+ ---
82
+
83
+ ## ๐ŸŽฎ How to Play & Controls
84
+
85
+ Navigate the cursor over tiles, reveal safe cells, and flag suspected mines.
86
+
87
+ ### Default Controls
88
+
89
+ | Action | Default Keys | Description |
90
+ | :--- | :--- | :--- |
91
+ | **Move Cursor** | `W` / `A` / `S` / `D` or `Arrow Keys` | Move cursor Up, Left, Down, Right |
92
+ | **Reveal Cell** | `Enter` or `Space` | Open hidden cell at cursor |
93
+ | **Toggle Flag** | `F` | Place or remove a flag on cursor |
94
+ | **Chord Reveal**| `C` | Open all adjacent unflagged cells |
95
+ | **Restart Game**| `R` | Reset and generate a fresh board |
96
+ | **Quit to Menu**| `Q` or `Esc` | Return to main menu |
97
+
98
+ ### Fallback Command Mode
99
+
100
+ If running in non-interactive terminals, redirected streams, or legacy shells without raw input support:
101
+ - Type `w`, `a`, `s`, `d` to move.
102
+ - Type `r` to reveal or `f` to flag.
103
+ - Type direct coordinates: `r <x> <y>` to reveal cell `(x, y)` or `f <x> <y>` to flag `(x, y)`.
104
+ - Type `q` to return to the menu.
105
+
106
+ ---
107
+
108
+ ## โš™๏ธ Command-Line Arguments
109
+
110
+ Launch directly into specific game modes or themes:
111
+
112
+ ```bash
113
+ # Display help and usage
114
+ minesweeper --help
115
+
116
+ # Display version
117
+ minesweeper --version
118
+
119
+ # Directly launch specific difficulty preset
120
+ minesweeper --difficulty easy
121
+ minesweeper --difficulty medium
122
+ minesweeper --difficulty hard
123
+ minesweeper --difficulty expert
124
+
125
+ # Directly open custom board configuration dialog
126
+ minesweeper --custom
127
+
128
+ # Select a visual theme on launch
129
+ minesweeper --theme matrix
130
+ ```
131
+
132
+ ---
133
+
134
+ ## ๐ŸŽจ Themes Showcase
135
+
136
+ Themes alter board colors, borders, menus, status indicators, and numbers 1โ€“8:
137
+
138
+ 1. **Classic**: Traditional Windows Minesweeper palette with bright primary numbers.
139
+ 2. **Matrix**: Digital phosphor rain with emerald borders and hacker aesthetic.
140
+ 3. **Ocean**: Deep blues, cyan reefs, and serene marine highlights.
141
+ 4. **Dracula**: Modern dark mode with purple, pink, and vibrant accents.
142
+ 5. **Cyberpunk**: High-voltage neon yellow, electric magenta, and neon cyan.
143
+ 6. **Nord**: Cool arctic blues, slate gray, and pastel typography.
144
+ 7. **Monochrome**: High-contrast grayscale suitable for any 8-color terminal or monochrome display.
145
+
146
+ You can switch themes in **Settings > Theme** or via `minesweeper --theme <name>`.
147
+
148
+ ---
149
+
150
+ ## ๐Ÿ“ฑ Termux & Mobile Compatibility
151
+
152
+ Minesweeper CLI is built to run smoothly on Android via **Termux**:
153
+ - Viewport auto-centers around the cursor when boards are wider than the terminal.
154
+ - Supports compact rendering mode (`Settings > Compact Mode: ON` or auto-detected).
155
+ - Uses standard terminal character fallbacks if your mobile font lacks full Unicode emoji support.
156
+
157
+ To install on Termux:
158
+ ```bash
159
+ pkg update && pkg install python git
160
+ git clone https://github.com/ItsReZNuM/Minesweeper-CLI.git
161
+ cd Minesweeper-CLI
162
+ pip install -e .
163
+ minesweeper
164
+ ```
165
+
166
+ ---
167
+
168
+ ## ๐Ÿ“ Project Structure
169
+
170
+ ```text
171
+ Minesweeper-CLI/
172
+ โ”œโ”€โ”€ .github/
173
+ โ”‚ โ””โ”€โ”€ workflows/
174
+ โ”‚ โ”œโ”€โ”€ tests.yml # CI test matrix (Python 3.10-3.13 on Linux/Win/macOS)
175
+ โ”‚ โ””โ”€โ”€ release.yml # Release packaging automation
176
+ โ”œโ”€โ”€ src/
177
+ โ”‚ โ””โ”€โ”€ minesweeper_cli/
178
+ โ”‚ โ”œโ”€โ”€ __init__.py # Package version and metadata
179
+ โ”‚ โ”œโ”€โ”€ __main__.py # python -m minesweeper_cli entrypoint
180
+ โ”‚ โ”œโ”€โ”€ board.py # Pure engine logic, flood-fill, chords, win/loss
181
+ โ”‚ โ”œโ”€โ”€ cell.py # Cell data structure and state
182
+ โ”‚ โ”œโ”€โ”€ cli.py # Command-line argument parsing and dispatcher
183
+ โ”‚ โ”œโ”€โ”€ config.py # Difficulty presets and application constants
184
+ โ”‚ โ”œโ”€โ”€ controls.py # Action mappings, key normalization, conflict checks
185
+ โ”‚ โ”œโ”€โ”€ game.py # Interactive game session and viewport scrolling
186
+ โ”‚ โ”œโ”€โ”€ menu.py # Main menu, custom dialogs, settings, records
187
+ โ”‚ โ”œโ”€โ”€ persistence.py # Atomic filesystem storage using platformdirs
188
+ โ”‚ โ”œโ”€โ”€ platform_compat.py # Cross-platform single-key reader & fallback
189
+ โ”‚ โ”œโ”€โ”€ records.py # Best times and gameplay statistics tracker
190
+ โ”‚ โ”œโ”€โ”€ renderer.py # Rich terminal UI components and styling
191
+ โ”‚ โ”œโ”€โ”€ settings.py # User configuration and keybinding storage
192
+ โ”‚ โ”œโ”€โ”€ themes.py # 7 distinct color themes
193
+ โ”‚ โ”œโ”€โ”€ timer.py # Non-busy monotonic gameplay duration timer
194
+ โ”‚ โ””โ”€โ”€ py.typed # PEP 561 type marker
195
+ โ”œโ”€โ”€ tests/
196
+ โ”‚ โ”œโ”€โ”€ test_board.py # Board generation, rules, chords, win/loss
197
+ โ”‚ โ”œโ”€โ”€ test_cli.py # CLI flags and arguments
198
+ โ”‚ โ”œโ”€โ”€ test_controls.py # Control mappings and conflict validation
199
+ โ”‚ โ”œโ”€โ”€ test_game.py # Viewport calculation and command parser
200
+ โ”‚ โ”œโ”€โ”€ test_records.py # Statistics, best times, custom records
201
+ โ”‚ โ””โ”€โ”€ test_settings.py # Settings persistence and corrupted data recovery
202
+ โ”œโ”€โ”€ CHANGELOG.md # Semantic version history
203
+ โ”œโ”€โ”€ CONTRIBUTING.md # Contribution guidelines
204
+ โ”œโ”€โ”€ LICENSE # MIT License
205
+ โ”œโ”€โ”€ MANIFEST.in # Package manifest
206
+ โ”œโ”€โ”€ pyproject.toml # Modern PEP 517/621 packaging configuration
207
+ โ””โ”€โ”€ README.md
208
+ ```
209
+
210
+ ---
211
+
212
+ ## ๐Ÿงช Testing
213
+
214
+ Run the automated test suite with `pytest`:
215
+
216
+ ```bash
217
+ python -m pytest tests/ -v
218
+ ```
219
+
220
+ ---
221
+
222
+ ## ๐Ÿ“ฆ Building and Packaging
223
+
224
+ Build the source distribution and wheel:
225
+
226
+ ```bash
227
+ python -m build
228
+ ```
229
+
230
+ Verify the distribution packages:
231
+
232
+ ```bash
233
+ python -m twine check dist/*
234
+ ```
235
+
236
+ ---
237
+
238
+ ## ๐Ÿ‘ค Author
239
+
240
+ **Made with โค๏ธ by ItsReZNuM**
241
+
242
+ - **GitHub Profile**: [https://github.com/ItsReZNuM](https://github.com/ItsReZNuM)
243
+ - **Repository**: [https://github.com/ItsReZNuM/Minesweeper-CLI](https://github.com/ItsReZNuM/Minesweeper-CLI)
244
+ - **Telegram**: [https://t.me/ItsReZNuM](https://t.me/ItsReZNuM)
245
+ - **Instagram**: [https://instagram.com/rez.num](https://instagram.com/rez.num)
246
+
247
+ โญ **Enjoying the game?** Please consider starring the repository on GitHub! It means a lot and supports future development.
248
+
249
+ ---
250
+
251
+ ## ๐Ÿ“„ License
252
+
253
+ This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.