belote-cli 0.9.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.
- belote_cli-0.9.0/.gitignore +149 -0
- belote_cli-0.9.0/CHANGELOG.md +17 -0
- belote_cli-0.9.0/DEVELOPMENT.md +84 -0
- belote_cli-0.9.0/LICENSE +21 -0
- belote_cli-0.9.0/PKG-INFO +177 -0
- belote_cli-0.9.0/README.md +138 -0
- belote_cli-0.9.0/pyproject.toml +35 -0
- belote_cli-0.9.0/src/__init__.py +0 -0
- belote_cli-0.9.0/src/belote/__init__.py +0 -0
- belote_cli-0.9.0/src/belote/ai.py +412 -0
- belote_cli-0.9.0/src/belote/ansi.py +141 -0
- belote_cli-0.9.0/src/belote/bidding.py +68 -0
- belote_cli-0.9.0/src/belote/deck.py +156 -0
- belote_cli-0.9.0/src/belote/game.py +537 -0
- belote_cli-0.9.0/src/belote/input.py +151 -0
- belote_cli-0.9.0/src/belote/main.py +352 -0
- belote_cli-0.9.0/src/belote/rules.py +104 -0
- belote_cli-0.9.0/src/belote/scoring.py +488 -0
- belote_cli-0.9.0/src/belote/ui.py +825 -0
- belote_cli-0.9.0/tests/__init__.py +0 -0
- belote_cli-0.9.0/tests/test_belote.py +733 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so may be deleted safely.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.pytest_cache/
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the Python version
|
|
87
|
+
# is usually managed by the user.
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or even
|
|
94
|
+
# fail to install.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
#poetry.lock
|
|
100
|
+
|
|
101
|
+
# pdm
|
|
102
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
103
|
+
#pdm.lock
|
|
104
|
+
|
|
105
|
+
# PEP 582; used by e.g. github.com/pdm-project/pdm
|
|
106
|
+
__pypackages__/
|
|
107
|
+
|
|
108
|
+
# Celery stuff
|
|
109
|
+
celerybeat-schedule
|
|
110
|
+
celerybeat.pid
|
|
111
|
+
|
|
112
|
+
# SageMath parsed files
|
|
113
|
+
*.sage.py
|
|
114
|
+
|
|
115
|
+
# Environments
|
|
116
|
+
.env
|
|
117
|
+
.venv
|
|
118
|
+
env/
|
|
119
|
+
venv/
|
|
120
|
+
ENV/
|
|
121
|
+
env.bak/
|
|
122
|
+
venv.bak/
|
|
123
|
+
|
|
124
|
+
# Spyder project settings
|
|
125
|
+
.spyderproject
|
|
126
|
+
.spyproject
|
|
127
|
+
|
|
128
|
+
# Rope project settings
|
|
129
|
+
.ropeproject
|
|
130
|
+
|
|
131
|
+
# mkdocs documentation
|
|
132
|
+
/site
|
|
133
|
+
|
|
134
|
+
# mypy
|
|
135
|
+
.mypy_cache/
|
|
136
|
+
.dmypy.json
|
|
137
|
+
dmypy.json
|
|
138
|
+
|
|
139
|
+
# Pyre type checker
|
|
140
|
+
.pyre/
|
|
141
|
+
|
|
142
|
+
# pytype static type analyzer
|
|
143
|
+
.pytype/
|
|
144
|
+
|
|
145
|
+
# Cython debug symbols
|
|
146
|
+
cython_debug/
|
|
147
|
+
|
|
148
|
+
# PyCharm
|
|
149
|
+
.idea/
|
|
@@ -0,0 +1,17 @@
|
|
|
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.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.9.0] - 2026-04-26
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release as a standard Python package.
|
|
12
|
+
- Full-screen terminal UI for French Belote.
|
|
13
|
+
- AI difficulty levels: Easy, Medium, Hard.
|
|
14
|
+
- Bidding and scoring systems.
|
|
15
|
+
- Multilingual (EN/FR) rules and history viewer.
|
|
16
|
+
- Standard project structure with `src` layout.
|
|
17
|
+
- Git repository initialization and GitHub sync.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Development Guide
|
|
2
|
+
|
|
3
|
+
Welcome to the Belote development guide. This project is structured as a standard Python package.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
1. **Clone the repository:**
|
|
8
|
+
```bash
|
|
9
|
+
git clone <repository-url>
|
|
10
|
+
cd belote
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. **Create a virtual environment:**
|
|
14
|
+
```bash
|
|
15
|
+
python -m venv .venv
|
|
16
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
3. **Install in editable mode:**
|
|
20
|
+
```bash
|
|
21
|
+
pip install -e .
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Running the Game
|
|
25
|
+
|
|
26
|
+
After installing, you can run the game using the `belote` command:
|
|
27
|
+
```bash
|
|
28
|
+
belote
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or via python:
|
|
32
|
+
```bash
|
|
33
|
+
python -m belote.main
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Testing
|
|
37
|
+
|
|
38
|
+
We use `pytest` for testing. Install it if you haven't already:
|
|
39
|
+
```bash
|
|
40
|
+
pip install pytest
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Run tests:
|
|
44
|
+
```bash
|
|
45
|
+
PYTHONPATH=src pytest
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Releasing a New Version
|
|
49
|
+
|
|
50
|
+
### Code-only update (push to GitHub without releasing a new PyPI version)
|
|
51
|
+
|
|
52
|
+
If you're just iterating on code, fixing typos, updating docs, etc., and don't want to cut a new PyPI release yet:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git add <files>
|
|
56
|
+
git commit -m "<what changed>"
|
|
57
|
+
git push origin master
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Releasing a New Version (Manual)
|
|
61
|
+
|
|
62
|
+
1. **Bump the version** in `pyproject.toml`.
|
|
63
|
+
2. **Add a CHANGELOG entry** at the top of `CHANGELOG.md`.
|
|
64
|
+
3. **Clean stale build artifacts:**
|
|
65
|
+
```bash
|
|
66
|
+
rm -rf dist/ build/ *.egg-info/
|
|
67
|
+
```
|
|
68
|
+
4. **Build, validate, and upload:**
|
|
69
|
+
```bash
|
|
70
|
+
pipx run build --sdist --wheel
|
|
71
|
+
pipx run twine check dist/*
|
|
72
|
+
pipx run twine upload dist/*
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
*Note: `twine upload` will prompt for your PyPI credentials or use your `~/.pypirc` file.*
|
|
76
|
+
|
|
77
|
+
5. **Commit and tag in git:**
|
|
78
|
+
```bash
|
|
79
|
+
git add pyproject.toml CHANGELOG.md
|
|
80
|
+
git commit -m "Release vX.Y.Z"
|
|
81
|
+
git tag -a vX.Y.Z -m "vX.Y.Z"
|
|
82
|
+
git push origin master --tags
|
|
83
|
+
```
|
|
84
|
+
```
|
belote_cli-0.9.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Benjamin
|
|
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,177 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: belote-cli
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: A 4-player terminal card game
|
|
5
|
+
Project-URL: Homepage, https://github.com/ElysiumDisc/belote
|
|
6
|
+
Project-URL: Repository, https://github.com/ElysiumDisc/belote
|
|
7
|
+
Project-URL: Issues, https://github.com/ElysiumDisc/belote/issues
|
|
8
|
+
Author-email: Benjamin <benjamin@example.com>
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 Benjamin
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Classifier: Environment :: Console
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Operating System :: OS Independent
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Requires-Python: >=3.10
|
|
36
|
+
Provides-Extra: test
|
|
37
|
+
Requires-Dist: pytest; extra == 'test'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# Belote – 4-Player Terminal Card Game
|
|
41
|
+
|
|
42
|
+
Complete implementation of the French card game Belote for the terminal, with a full-screen green felt table and full card graphics at compass positions (N/W/E/S).
|
|
43
|
+
|
|
44
|
+
## Showcase
|
|
45
|
+
|
|
46
|
+
### Main Menu
|
|
47
|
+
```text
|
|
48
|
+
⢠⣴⣶⣶⣶⣄
|
|
49
|
+
⣿⣿⣿⣿⣿⣿⣦
|
|
50
|
+
⢰⣿⣿⣿⣿⡿⠟⠁⣠⣴⣶⣦⠄
|
|
51
|
+
⢸⣿⣿⠟⠉⣠⣴⣿⣿⣿⠟⠁⣠⣾⣿⣦⡀
|
|
52
|
+
⠉⣀⣴⣾⣿⣿⣿⠟⢁⣤⣾⣿⣿⣿⣿⣿⡆
|
|
53
|
+
⢀⣤⣾⣿⣿⣿⡿⠛⢁⣴⣿⣿⣿⣿⣿⣿⣿⠟⠁⡀
|
|
54
|
+
⢼⣿⣿⣿⡿⠋⣀⣴⣿⣿⣿⣿⣿⣿⣿⡿⠉⣠⣾⣿⡆
|
|
55
|
+
⠘⢿⡿⠋⣠⣾⣿⣿⣿⠟⠁⣿⣿⣿⣿⣿⠟⢁⣀
|
|
56
|
+
⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣴⣿⣿⣿⠋⢠⣾⣿⣷⣦⡀
|
|
57
|
+
⢻⣿⣿⣿⣿⣿⣿⣿⠟⢁⣴⣿⣿⣿⡿⠁⣰⣿⣿⣿⣿⣿⣿
|
|
58
|
+
⠹⢿⣿⣿⣿⡿⠋⣠⣾⣿⣿⣿⠟⢀⣼⣿⣿⣿⣿⣿⣿⡟
|
|
59
|
+
⠉⠉⠉⠀⢾⣿⣿⣿⣿⠋⠀⠚⠛⠛⠛⠛⠛⠛⠁
|
|
60
|
+
|
|
61
|
+
(
|
|
62
|
+
) (
|
|
63
|
+
___...(-------)-....___
|
|
64
|
+
.-'' ) ( ''-.
|
|
65
|
+
.-'``'|-._ ) _.-|
|
|
66
|
+
/ .--.| `''---...........---''` |
|
|
67
|
+
/ / | > Start Game < |
|
|
68
|
+
| | | Difficulty: Medium |
|
|
69
|
+
\ \ | Target Score: 1000 |
|
|
70
|
+
`\ `\ | Speed: Normal |
|
|
71
|
+
`\ `| Rules & History |
|
|
72
|
+
_/ /\ Quit /
|
|
73
|
+
(__/ \ /
|
|
74
|
+
_..---''` \ /`''---.._
|
|
75
|
+
.-' \ / '-.
|
|
76
|
+
: `-.__ __.-' :
|
|
77
|
+
: ) ''---...---'' ( :
|
|
78
|
+
'._ `''...___...--''` _.'
|
|
79
|
+
jgs \''--..__ __..--''/
|
|
80
|
+
'._ '''----.....______.....----''' _.'
|
|
81
|
+
`''--..,,_____ _____,,..--''`
|
|
82
|
+
`'''----'''`
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Card Graphics
|
|
86
|
+
```text
|
|
87
|
+
┌────┐ ┌────┐ ┌────┐ ┌────┐
|
|
88
|
+
│J ♠ │ │Q ♦ │ │K ♥ │ │A ♣ │
|
|
89
|
+
│ ⚔ │ │ ♕ │ │ ♔ │ │ ★ │
|
|
90
|
+
│ J ♠│ │ Q ♦│ │ K ♥│ │ A ♣│
|
|
91
|
+
└────┘ └────┘ └────┘ └────┘
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Requirements
|
|
95
|
+
|
|
96
|
+
- Python >= 3.10
|
|
97
|
+
- No third-party dependencies (stdlib only)
|
|
98
|
+
- Terminal with >= 100 columns x 40 rows
|
|
99
|
+
- UTF-8 support (for card symbols: ♠♥♦♣)
|
|
100
|
+
|
|
101
|
+
## Quick Start
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Install in editable mode (recommended for development)
|
|
105
|
+
pip install -e .
|
|
106
|
+
|
|
107
|
+
# Or install from PyPI (once uploaded)
|
|
108
|
+
pip install belote-cli
|
|
109
|
+
|
|
110
|
+
# Play using the belote command
|
|
111
|
+
belote
|
|
112
|
+
|
|
113
|
+
# Custom settings
|
|
114
|
+
belote --difficulty hard --target 500
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Controls
|
|
118
|
+
|
|
119
|
+
**Main Menu:**
|
|
120
|
+
- `↑` `↓`: Navigate options
|
|
121
|
+
- `Enter`: Select option
|
|
122
|
+
- `Q`: Quit application
|
|
123
|
+
|
|
124
|
+
**Gameplay:**
|
|
125
|
+
- `←` `→` or `↑` `↓`: Move selection
|
|
126
|
+
- `Enter`: Confirm action
|
|
127
|
+
- `1`-`8`: Direct card/bid selection
|
|
128
|
+
- `Q`: Return to main menu during gameplay
|
|
129
|
+
|
|
130
|
+
## Features
|
|
131
|
+
|
|
132
|
+
- **Rich Terminal UI:** Full-screen green felt table with detailed card graphics, face card art (Roi ♔, Dame ♕, Valet ⚔), and distinct color palettes.
|
|
133
|
+
- **Main Menu:** Configure Difficulty, Target Score, and Game Speed, and access **Rules & History** (EN/FR) without restarting the app.
|
|
134
|
+
- **Live HUD:** Real-time round scoring displays points won during the current round, with a smooth "rolling" numerical animation for total scores.
|
|
135
|
+
- **Trick History:** Visual "Last Trick" panel helps track the flow of the game.
|
|
136
|
+
- **High Fidelity:** Full implementation of French Belote rules including a two-round bidding system, "Dix de Der", and "Capot" (250 pts) announcements.
|
|
137
|
+
- **Rules & History Viewer:** A scrollable, bilingual (English/French) in-game reference for the game's heritage and mechanics.
|
|
138
|
+
- **Robust Input:** High-performance unbuffered key reading for responsive navigation and 'q' to quit functionality.
|
|
139
|
+
|
|
140
|
+
## AI
|
|
141
|
+
|
|
142
|
+
Three difficulty levels:
|
|
143
|
+
- **Easy**: Random legal moves, bids on 2+ honors
|
|
144
|
+
- **Medium**: Heuristic suit scoring, strategic play (cover/duck/duck)
|
|
145
|
+
- **Hard**: Void inference, 1-ply lookahead, Monte-Carlo bidding
|
|
146
|
+
|
|
147
|
+
## Project Structure
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
belote/
|
|
151
|
+
├── src/belote/
|
|
152
|
+
│ ├── main.py # Entry point, game loop, CLI args
|
|
153
|
+
│ ├── deck.py # Card, Suit, Rank, deck operations, points
|
|
154
|
+
│ ├── game.py # GameState, phases, pure transitions, legal moves
|
|
155
|
+
│ ├── bidding.py # Bidding phase state machine
|
|
156
|
+
│ ├── scoring.py # Declarations, round scoring, capot
|
|
157
|
+
│ ├── ai.py # Three-tier AI (easy/medium/hard)
|
|
158
|
+
│ ├── ansi.py # ANSI escape helpers (colors, cursor)
|
|
159
|
+
│ ├── input.py # Platform-dispatched key reader
|
|
160
|
+
│ ├── ui.py # Render, prompts, full-screen layout
|
|
161
|
+
│ └── rules.py # Game rules content
|
|
162
|
+
├── tests/
|
|
163
|
+
│ └── test_belote.py # 36 pytest tests
|
|
164
|
+
├── pyproject.toml # Build system configuration
|
|
165
|
+
├── LICENSE # MIT License
|
|
166
|
+
└── DEVELOPMENT.md # Detailed setup and dev guide
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Running Tests
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
PYTHONPATH=src pytest
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Terminal Hygiene
|
|
176
|
+
|
|
177
|
+
Signal handlers (SIGINT, SIGTERM) and atexit hooks ensure the terminal is always restored — cursor visible, colors reset, alt-screen off — even after Ctrl+C or crashes.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Belote – 4-Player Terminal Card Game
|
|
2
|
+
|
|
3
|
+
Complete implementation of the French card game Belote for the terminal, with a full-screen green felt table and full card graphics at compass positions (N/W/E/S).
|
|
4
|
+
|
|
5
|
+
## Showcase
|
|
6
|
+
|
|
7
|
+
### Main Menu
|
|
8
|
+
```text
|
|
9
|
+
⢠⣴⣶⣶⣶⣄
|
|
10
|
+
⣿⣿⣿⣿⣿⣿⣦
|
|
11
|
+
⢰⣿⣿⣿⣿⡿⠟⠁⣠⣴⣶⣦⠄
|
|
12
|
+
⢸⣿⣿⠟⠉⣠⣴⣿⣿⣿⠟⠁⣠⣾⣿⣦⡀
|
|
13
|
+
⠉⣀⣴⣾⣿⣿⣿⠟⢁⣤⣾⣿⣿⣿⣿⣿⡆
|
|
14
|
+
⢀⣤⣾⣿⣿⣿⡿⠛⢁⣴⣿⣿⣿⣿⣿⣿⣿⠟⠁⡀
|
|
15
|
+
⢼⣿⣿⣿⡿⠋⣀⣴⣿⣿⣿⣿⣿⣿⣿⡿⠉⣠⣾⣿⡆
|
|
16
|
+
⠘⢿⡿⠋⣠⣾⣿⣿⣿⠟⠁⣿⣿⣿⣿⣿⠟⢁⣀
|
|
17
|
+
⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣴⣿⣿⣿⠋⢠⣾⣿⣷⣦⡀
|
|
18
|
+
⢻⣿⣿⣿⣿⣿⣿⣿⠟⢁⣴⣿⣿⣿⡿⠁⣰⣿⣿⣿⣿⣿⣿
|
|
19
|
+
⠹⢿⣿⣿⣿⡿⠋⣠⣾⣿⣿⣿⠟⢀⣼⣿⣿⣿⣿⣿⣿⡟
|
|
20
|
+
⠉⠉⠉⠀⢾⣿⣿⣿⣿⠋⠀⠚⠛⠛⠛⠛⠛⠛⠁
|
|
21
|
+
|
|
22
|
+
(
|
|
23
|
+
) (
|
|
24
|
+
___...(-------)-....___
|
|
25
|
+
.-'' ) ( ''-.
|
|
26
|
+
.-'``'|-._ ) _.-|
|
|
27
|
+
/ .--.| `''---...........---''` |
|
|
28
|
+
/ / | > Start Game < |
|
|
29
|
+
| | | Difficulty: Medium |
|
|
30
|
+
\ \ | Target Score: 1000 |
|
|
31
|
+
`\ `\ | Speed: Normal |
|
|
32
|
+
`\ `| Rules & History |
|
|
33
|
+
_/ /\ Quit /
|
|
34
|
+
(__/ \ /
|
|
35
|
+
_..---''` \ /`''---.._
|
|
36
|
+
.-' \ / '-.
|
|
37
|
+
: `-.__ __.-' :
|
|
38
|
+
: ) ''---...---'' ( :
|
|
39
|
+
'._ `''...___...--''` _.'
|
|
40
|
+
jgs \''--..__ __..--''/
|
|
41
|
+
'._ '''----.....______.....----''' _.'
|
|
42
|
+
`''--..,,_____ _____,,..--''`
|
|
43
|
+
`'''----'''`
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Card Graphics
|
|
47
|
+
```text
|
|
48
|
+
┌────┐ ┌────┐ ┌────┐ ┌────┐
|
|
49
|
+
│J ♠ │ │Q ♦ │ │K ♥ │ │A ♣ │
|
|
50
|
+
│ ⚔ │ │ ♕ │ │ ♔ │ │ ★ │
|
|
51
|
+
│ J ♠│ │ Q ♦│ │ K ♥│ │ A ♣│
|
|
52
|
+
└────┘ └────┘ └────┘ └────┘
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Requirements
|
|
56
|
+
|
|
57
|
+
- Python >= 3.10
|
|
58
|
+
- No third-party dependencies (stdlib only)
|
|
59
|
+
- Terminal with >= 100 columns x 40 rows
|
|
60
|
+
- UTF-8 support (for card symbols: ♠♥♦♣)
|
|
61
|
+
|
|
62
|
+
## Quick Start
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Install in editable mode (recommended for development)
|
|
66
|
+
pip install -e .
|
|
67
|
+
|
|
68
|
+
# Or install from PyPI (once uploaded)
|
|
69
|
+
pip install belote-cli
|
|
70
|
+
|
|
71
|
+
# Play using the belote command
|
|
72
|
+
belote
|
|
73
|
+
|
|
74
|
+
# Custom settings
|
|
75
|
+
belote --difficulty hard --target 500
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Controls
|
|
79
|
+
|
|
80
|
+
**Main Menu:**
|
|
81
|
+
- `↑` `↓`: Navigate options
|
|
82
|
+
- `Enter`: Select option
|
|
83
|
+
- `Q`: Quit application
|
|
84
|
+
|
|
85
|
+
**Gameplay:**
|
|
86
|
+
- `←` `→` or `↑` `↓`: Move selection
|
|
87
|
+
- `Enter`: Confirm action
|
|
88
|
+
- `1`-`8`: Direct card/bid selection
|
|
89
|
+
- `Q`: Return to main menu during gameplay
|
|
90
|
+
|
|
91
|
+
## Features
|
|
92
|
+
|
|
93
|
+
- **Rich Terminal UI:** Full-screen green felt table with detailed card graphics, face card art (Roi ♔, Dame ♕, Valet ⚔), and distinct color palettes.
|
|
94
|
+
- **Main Menu:** Configure Difficulty, Target Score, and Game Speed, and access **Rules & History** (EN/FR) without restarting the app.
|
|
95
|
+
- **Live HUD:** Real-time round scoring displays points won during the current round, with a smooth "rolling" numerical animation for total scores.
|
|
96
|
+
- **Trick History:** Visual "Last Trick" panel helps track the flow of the game.
|
|
97
|
+
- **High Fidelity:** Full implementation of French Belote rules including a two-round bidding system, "Dix de Der", and "Capot" (250 pts) announcements.
|
|
98
|
+
- **Rules & History Viewer:** A scrollable, bilingual (English/French) in-game reference for the game's heritage and mechanics.
|
|
99
|
+
- **Robust Input:** High-performance unbuffered key reading for responsive navigation and 'q' to quit functionality.
|
|
100
|
+
|
|
101
|
+
## AI
|
|
102
|
+
|
|
103
|
+
Three difficulty levels:
|
|
104
|
+
- **Easy**: Random legal moves, bids on 2+ honors
|
|
105
|
+
- **Medium**: Heuristic suit scoring, strategic play (cover/duck/duck)
|
|
106
|
+
- **Hard**: Void inference, 1-ply lookahead, Monte-Carlo bidding
|
|
107
|
+
|
|
108
|
+
## Project Structure
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
belote/
|
|
112
|
+
├── src/belote/
|
|
113
|
+
│ ├── main.py # Entry point, game loop, CLI args
|
|
114
|
+
│ ├── deck.py # Card, Suit, Rank, deck operations, points
|
|
115
|
+
│ ├── game.py # GameState, phases, pure transitions, legal moves
|
|
116
|
+
│ ├── bidding.py # Bidding phase state machine
|
|
117
|
+
│ ├── scoring.py # Declarations, round scoring, capot
|
|
118
|
+
│ ├── ai.py # Three-tier AI (easy/medium/hard)
|
|
119
|
+
│ ├── ansi.py # ANSI escape helpers (colors, cursor)
|
|
120
|
+
│ ├── input.py # Platform-dispatched key reader
|
|
121
|
+
│ ├── ui.py # Render, prompts, full-screen layout
|
|
122
|
+
│ └── rules.py # Game rules content
|
|
123
|
+
├── tests/
|
|
124
|
+
│ └── test_belote.py # 36 pytest tests
|
|
125
|
+
├── pyproject.toml # Build system configuration
|
|
126
|
+
├── LICENSE # MIT License
|
|
127
|
+
└── DEVELOPMENT.md # Detailed setup and dev guide
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Running Tests
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
PYTHONPATH=src pytest
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Terminal Hygiene
|
|
137
|
+
|
|
138
|
+
Signal handlers (SIGINT, SIGTERM) and atexit hooks ensure the terminal is always restored — cursor visible, colors reset, alt-screen off — even after Ctrl+C or crashes.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "belote-cli"
|
|
7
|
+
version = "0.9.0"
|
|
8
|
+
description = "A 4-player terminal card game"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = {file = "LICENSE"}
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Benjamin", email = "benjamin@example.com" },
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Environment :: Console",
|
|
20
|
+
]
|
|
21
|
+
dependencies = []
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
test = ["pytest"]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/ElysiumDisc/belote"
|
|
28
|
+
Repository = "https://github.com/ElysiumDisc/belote"
|
|
29
|
+
Issues = "https://github.com/ElysiumDisc/belote/issues"
|
|
30
|
+
|
|
31
|
+
[project.scripts]
|
|
32
|
+
belote = "belote.main:main"
|
|
33
|
+
|
|
34
|
+
[tool.hatch.build.targets.wheel]
|
|
35
|
+
packages = ["src/belote"]
|
|
File without changes
|
|
File without changes
|