cli-arcade 2026.1.3__tar.gz → 2026.2.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.
Files changed (48) hide show
  1. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/MANIFEST.in +0 -1
  2. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/PKG-INFO +38 -10
  3. cli_arcade-2026.2.0/PYPI_README.md +65 -0
  4. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/README.md +15 -20
  5. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/cli.py +110 -67
  6. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/cli_arcade.egg-info/SOURCES.txt +6 -1
  7. cli_arcade-2026.2.0/game_classes/__pycache__/game_base.cpython-313.pyc +0 -0
  8. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/game_classes/__pycache__/menu.cpython-313.pyc +0 -0
  9. cli_arcade-2026.2.0/game_classes/__pycache__/ptk.cpython-313.pyc +0 -0
  10. cli_arcade-2026.2.0/game_classes/__pycache__/ptk_curses.cpython-313.pyc +0 -0
  11. cli_arcade-2026.2.0/game_classes/__pycache__/ptk_game_base.cpython-313.pyc +0 -0
  12. cli_arcade-2026.2.0/game_classes/__pycache__/ptk_menu.cpython-313.pyc +0 -0
  13. cli_arcade-2026.2.0/game_classes/__pycache__/ptk_tools.cpython-313.pyc +0 -0
  14. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/game_classes/__pycache__/tools.cpython-313.pyc +0 -0
  15. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/game_classes/game_base.py +5 -5
  16. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/game_classes/menu.py +4 -4
  17. cli_arcade-2026.2.0/game_classes/ptk.py +319 -0
  18. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/game_classes/tools.py +27 -25
  19. cli_arcade-2026.2.0/games/byte_bouncer/__pycache__/game.cpython-313.pyc +0 -0
  20. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/byte_bouncer/game.py +45 -21
  21. cli_arcade-2026.2.0/games/star_ship/__pycache__/game.cpython-313.pyc +0 -0
  22. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/star_ship/game.py +64 -24
  23. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/terminal_tumble/__pycache__/game.cpython-313.pyc +0 -0
  24. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/terminal_tumble/game.py +41 -38
  25. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/setup.cfg +2 -3
  26. cli_arcade-2026.1.3/CHANGELOG.md +0 -22
  27. cli_arcade-2026.1.3/PYPI_README.md +0 -37
  28. cli_arcade-2026.1.3/game_classes/__pycache__/game_base.cpython-313.pyc +0 -0
  29. cli_arcade-2026.1.3/games/byte_bouncer/__pycache__/game.cpython-313.pyc +0 -0
  30. cli_arcade-2026.1.3/games/star_ship/__pycache__/game.cpython-313.pyc +0 -0
  31. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/LICENSE +0 -0
  32. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/game_classes/__init__.py +0 -0
  33. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/game_classes/__pycache__/__init__.cpython-313.pyc +0 -0
  34. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/game_classes/__pycache__/highscores.cpython-313.pyc +0 -0
  35. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/game_classes/highscores.py +0 -0
  36. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/__init__.py +0 -0
  37. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/byte_bouncer/__init__.py +0 -0
  38. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/byte_bouncer/__pycache__/byte_bouncer.cpython-313.pyc +0 -0
  39. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/byte_bouncer/__pycache__/highscores.cpython-313.pyc +0 -0
  40. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/star_ship/__init__.py +0 -0
  41. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/star_ship/__pycache__/highscores.cpython-313.pyc +0 -0
  42. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/star_ship/__pycache__/nibbles.cpython-313.pyc +0 -0
  43. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/star_ship/__pycache__/snek.cpython-313.pyc +0 -0
  44. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/star_ship/__pycache__/star_ship.cpython-313.pyc +0 -0
  45. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/terminal_tumble/__init__.py +0 -0
  46. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/terminal_tumble/__pycache__/highscores.cpython-313.pyc +0 -0
  47. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/games/terminal_tumble/__pycache__/terminal_tumble.cpython-313.pyc +0 -0
  48. {cli_arcade-2026.1.3 → cli_arcade-2026.2.0}/pyproject.toml +0 -0
@@ -1,5 +1,4 @@
1
1
  include PYPI_README.md
2
- include CHANGELOG.md
3
2
  include LICENSE
4
3
  include setup.cfg
5
4
  recursive-include game_classes *
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cli-arcade
3
- Version: 2026.1.3
3
+ Version: 2026.2.0
4
4
  Summary: Collection of terminal CLI games
5
5
  Home-page: https://github.com/Bro-Code-Technologies/cli-arcade/tree/main/windows
6
6
  Author: Bro Code Technologies LLC
@@ -10,7 +10,7 @@ Project-URL: Source, https://github.com/Bro-Code-Technologies/cli-arcade/tree/ma
10
10
  Project-URL: Issues, https://github.com/Bro-Code-Technologies/cli-arcade/tree/main/windows
11
11
  Project-URL: Documentation, https://github.com/Bro-Code-Technologies/cli-arcade/tree/main/windows
12
12
  Project-URL: Package, https://pypi.org/project/cli-arcade/
13
- Keywords: cli,terminal,arcade,games,curses
13
+ Keywords: cli,terminal,arcade,games
14
14
  Classifier: Development Status :: 4 - Beta
15
15
  Classifier: Environment :: Console
16
16
  Classifier: Intended Audience :: End Users/Desktop
@@ -28,17 +28,17 @@ Requires-Python: >=3.8
28
28
  Description-Content-Type: text/markdown
29
29
  License-File: LICENSE
30
30
  Requires-Dist: appdirs
31
- Requires-Dist: windows-curses; sys_platform == "win32"
31
+ Requires-Dist: prompt_toolkit
32
32
  Dynamic: license-file
33
33
 
34
34
  # CLI Arcade
35
35
 
36
36
  Collection of small terminal games bundled with a single CLI launcher.
37
37
 
38
- Requirements
38
+ ## Requirements
39
39
  - Python 3.8+
40
40
 
41
- Quick start
41
+ ## Quick start
42
42
  ```powershell
43
43
  # list installed console aliases and available games
44
44
  clia list
@@ -56,15 +56,43 @@ clia reset "Byte Bouncer"
56
56
  clia reset -y # skip confirmation
57
57
  ```
58
58
 
59
- Commands
60
- - `clia` — interactive curses menu
59
+ ## Commands
60
+ - `clia` — interactive terminal menu
61
61
  - `clia list` — print available games and zero-based indices
62
62
  - `clia run <index|name>` — run a game directly (index is zero-based)
63
63
  - `clia reset [<index|name>] [-y]` — delete highscores for a game or all games
64
64
  - Aliases available: `cli-arcade`
65
65
 
66
- License
66
+ ## License
67
67
  - MIT
68
68
 
69
- Changelog
70
- - See CHANGELOG.md
69
+ # Changelog
70
+
71
+ All notable changes to this project will be documented in this file.
72
+
73
+ ## 2026.0.0
74
+ - Initial release as CLI Game.
75
+
76
+ ## 2026.1.0
77
+ - Project renamed to CLI Arcade.
78
+ - Packaging metadata updated for PyPI.
79
+ - Documentation refresh.
80
+
81
+ ### 2026.1.1
82
+ - Updated TITLE ASCII art.
83
+ - Added `clia update` command to check for and install updates from PyPI.
84
+ - (YANKED)
85
+
86
+ ### 2026.1.2 (YANKED)
87
+ - Version bump for testing the update mechanism.
88
+
89
+ ### 2026.1.3
90
+ - Removed `clia update` command.
91
+
92
+ ### 2026.2.0
93
+ - Refactoring using `prompt_toolkit` replacing `windows-curses` for better cross-platform compatibility.
94
+ - Restore/clear alternate screen on run/exit (no UI artifacts).
95
+ - Centralize terminal-size checks in CLI; games expose `MIN_COLS`/`MIN_ROWS`.
96
+ - Byte Bouncer & Star Ship: floor + off-screen right wall; left-column bug fixed.
97
+ - `ptk`: default-attribute/color emission fix; add helper to exit alt screen.
98
+ - Fixed 180 movement glitch in Star Ship.
@@ -0,0 +1,65 @@
1
+ # CLI Arcade
2
+
3
+ Collection of small terminal games bundled with a single CLI launcher.
4
+
5
+ ## Requirements
6
+ - Python 3.8+
7
+
8
+ ## Quick start
9
+ ```powershell
10
+ # list installed console aliases and available games
11
+ clia list
12
+
13
+ # run interactive menu
14
+ clia
15
+
16
+ # run a game by zero-based index or name
17
+ clia run 0
18
+ clia run "Byte Bouncer"
19
+
20
+ # reset highscores for one game or all
21
+ clia reset 0
22
+ clia reset "Byte Bouncer"
23
+ clia reset -y # skip confirmation
24
+ ```
25
+
26
+ ## Commands
27
+ - `clia` — interactive terminal menu
28
+ - `clia list` — print available games and zero-based indices
29
+ - `clia run <index|name>` — run a game directly (index is zero-based)
30
+ - `clia reset [<index|name>] [-y]` — delete highscores for a game or all games
31
+ - Aliases available: `cli-arcade`
32
+
33
+ ## License
34
+ - MIT
35
+
36
+ # Changelog
37
+
38
+ All notable changes to this project will be documented in this file.
39
+
40
+ ## 2026.0.0
41
+ - Initial release as CLI Game.
42
+
43
+ ## 2026.1.0
44
+ - Project renamed to CLI Arcade.
45
+ - Packaging metadata updated for PyPI.
46
+ - Documentation refresh.
47
+
48
+ ### 2026.1.1
49
+ - Updated TITLE ASCII art.
50
+ - Added `clia update` command to check for and install updates from PyPI.
51
+ - (YANKED)
52
+
53
+ ### 2026.1.2 (YANKED)
54
+ - Version bump for testing the update mechanism.
55
+
56
+ ### 2026.1.3
57
+ - Removed `clia update` command.
58
+
59
+ ### 2026.2.0
60
+ - Refactoring using `prompt_toolkit` replacing `windows-curses` for better cross-platform compatibility.
61
+ - Restore/clear alternate screen on run/exit (no UI artifacts).
62
+ - Centralize terminal-size checks in CLI; games expose `MIN_COLS`/`MIN_ROWS`.
63
+ - Byte Bouncer & Star Ship: floor + off-screen right wall; left-column bug fixed.
64
+ - `ptk`: default-attribute/color emission fix; add helper to exit alt screen.
65
+ - Fixed 180 movement glitch in Star Ship.
@@ -2,15 +2,11 @@
2
2
 
3
3
  Collection of small terminal games bundled with a single CLI launcher.
4
4
 
5
- Requirements
5
+ ## Requirements
6
6
  - Python 3.8+
7
- - On Windows: install `windows-curses` for curses support:
7
+ - prompt_toolkit (installed via requirements)
8
8
 
9
- ```powershell
10
- pip install windows-curses
11
- ```
12
-
13
- Quick start (developer)
9
+ ## Quick start (developer)
14
10
 
15
11
  ```powershell
16
12
  # install editable (recommended during development)
@@ -45,34 +41,33 @@ You can always run the CLI directly without installing:
45
41
  python -m cli
46
42
  ```
47
43
 
48
- Commands
49
- - `clia` — interactive curses menu
44
+ ### Commands
45
+ - `clia` — interactive terminal menu
50
46
  - `clia list` — print available games and zero-based indices
51
47
  - `clia run <index|name>` — run a game directly (index is zero-based)
52
48
  - `clia reset [<index|name>] [-y]` — delete highscores for a game or all games
53
49
  - Aliases available: `cli-arcade`
54
50
 
55
- Highscores storage and migration
51
+ ### Highscores storage and migration
56
52
  - Highscores are now stored in a user-writable application data directory. Typical locations:
57
53
  - Windows (appdirs): `%LOCALAPPDATA%\cli-arcade\games\<game>\highscores.json`
58
54
  - Fallback (no appdirs): `%USERPROFILE%\.cli-arcade\games\<game>\highscores.json`
59
55
  - On first run the CLI attempts to migrate any legacy `games/<game>/highscores.json` found in the project into the user data directory.
60
56
 
61
- Packaging & publishing (brief)
62
-
57
+ ### Packaging & publishing (brief)
63
58
  - `setup.cfg` now declares `packages = find:` and `include_package_data = true` so `game_classes/` and `games/` are included in sdist/wheels. Remember to add a `MANIFEST.in` if you need additional files in source distributions.
64
59
  - Update `setup.cfg` version.
65
- - Update `CHANGELOG.md` for new version.
60
+ - Update `PYPI_README.md` Changelog for new version.
66
61
  - Build: `py -m build` (requires `build` package).
67
62
  - Upload: `twine upload dist/*` (requires `twine`).
68
63
  - The package exposes several console script aliases (see `setup.cfg` -> `options.entry_points.console_scripts`).
69
64
 
70
- Notes & Troubleshooting
71
- - On Windows, `curses` requires `windows-curses`.
65
+ ### Notes & Troubleshooting
66
+ - No platform-specific terminal dependencies are required.
72
67
  - The CLI requires a minimum terminal size; if the menu exits with an error, try enlarging your terminal or run `python -m cli` in a larger window.
73
68
  - Games should live in their own subdirectory (`games/<slug>/game.py`) and export a `main(stdscr)` entry point. The CLI uses the directory name (slug) as the display title.
74
69
 
75
- Terminal recommendations (Windows)
70
+ ### Terminal recommendations (Windows)
76
71
  - Recommended: use Windows Terminal or the VS Code integrated terminal for the best UTF-8 + glyph support.
77
72
  - Install Windows Terminal via Microsoft Store or `winget`:
78
73
 
@@ -96,12 +91,12 @@ $env:PYTHONIOENCODING = 'utf-8'
96
91
 
97
92
  - Advanced: enable system-wide UTF-8 (Region → Administrative → Change system locale → check “Beta: Use Unicode UTF-8 for worldwide language support”) and restart. This affects other apps and requires caution.
98
93
 
99
- Contributing
94
+ ## Contributing
100
95
  - Add a new game by creating a subdirectory under `games/` with a `game.py` file that exports `main(stdscr)`.
101
96
  - Keep changes minimal and run `clia` locally to verify.
102
97
 
103
- License
98
+ ## License
104
99
  - MIT
105
100
 
106
- Changelog
107
- - See CHANGELOG.md
101
+ # Changelog
102
+ - See PYPI_README.md
@@ -1,14 +1,17 @@
1
- import curses
1
+ from game_classes import ptk
2
+ from game_classes.tools import verify_terminal_size
2
3
  import os
3
4
  import importlib.util
4
5
  import argparse
5
6
  import glob
6
7
  import sys
8
+ import re
9
+ import time
7
10
 
8
11
  # helper: recognize Enter from multiple terminals/keypads
9
12
  def is_enter_key(ch):
10
13
  try:
11
- enter_vals = {10, 13, getattr(curses, 'KEY_ENTER', -1), 343, 459}
14
+ enter_vals = {10, 13, getattr(ptk, 'KEY_ENTER', -1), 343, 459}
12
15
  except Exception:
13
16
  enter_vals = {10, 13}
14
17
  return ch in enter_vals
@@ -48,13 +51,38 @@ def _discover_games():
48
51
  file_to_check = os.path.join(dirpath, pyfiles[0])
49
52
  if not file_to_check:
50
53
  continue
54
+ # try to read declared minimum terminal size from the game file
55
+ min_cols = None
56
+ min_rows = None
57
+ try:
58
+ with open(file_to_check, 'r', encoding='utf-8') as fh:
59
+ src = fh.read()
60
+ m = re.search(r'MIN_TERMINAL\s*=\s*\(\s*(\d+)\s*,\s*(\d+)\s*\)', src)
61
+ if m:
62
+ min_cols = int(m.group(1))
63
+ min_rows = int(m.group(2))
64
+ else:
65
+ m1 = re.search(r'MIN_COLS\s*=\s*(\d+)', src)
66
+ m2 = re.search(r'MIN_ROWS\s*=\s*(\d+)', src)
67
+ if m1:
68
+ min_cols = int(m1.group(1))
69
+ if m2:
70
+ min_rows = int(m2.group(1))
71
+ except Exception:
72
+ min_cols = None
73
+ min_rows = None
51
74
  # use directory name as the display name
52
75
  name = entry.replace('_', ' ').title()
53
76
  rel = os.path.relpath(file_to_check, base).replace('\\', '/')
54
77
  games.append((name, rel))
78
+ try:
79
+ GAME_MINS[rel] = (min_cols, min_rows)
80
+ except Exception:
81
+ pass
55
82
  return games
56
83
 
57
84
 
85
+ GAME_MINS = {}
58
86
  GAMES = _discover_games()
59
87
 
60
88
 
@@ -74,29 +102,29 @@ def _read_console_aliases():
74
102
 
75
103
 
76
104
  def _menu(stdscr):
77
- curses.curs_set(0)
105
+ ptk.curs_set(0)
78
106
  stdscr.nodelay(False)
79
107
  # ensure a cyan color pair is available for the title
80
- if curses.has_colors():
108
+ if ptk.has_colors():
81
109
  try:
82
110
  # init colors
83
- curses.start_color()
84
- curses.use_default_colors()
111
+ ptk.start_color()
112
+ ptk.use_default_colors()
85
113
  # try to normalize key colors (0..1000 scale). Must run before init_pair.
86
- if curses.can_change_color() and curses.COLORS >= 8:
114
+ if ptk.can_change_color() and ptk.COLORS >= 8:
87
115
  try:
88
- curses.init_color(curses.COLOR_MAGENTA, 1000, 0, 1000)
89
- curses.init_color(curses.COLOR_YELLOW, 1000, 1000, 0)
90
- curses.init_color(curses.COLOR_WHITE, 1000, 1000, 1000)
91
- curses.init_color(curses.COLOR_CYAN, 0, 1000, 1000)
92
- curses.init_color(curses.COLOR_BLUE, 0, 0, 1000)
93
- curses.init_color(curses.COLOR_GREEN, 0, 800, 0)
94
- curses.init_color(curses.COLOR_RED, 1000, 0, 0)
95
- curses.init_color(curses.COLOR_BLACK, 0, 0, 0)
116
+ ptk.init_color(ptk.COLOR_MAGENTA, 1000, 0, 1000)
117
+ ptk.init_color(ptk.COLOR_YELLOW, 1000, 1000, 0)
118
+ ptk.init_color(ptk.COLOR_WHITE, 1000, 1000, 1000)
119
+ ptk.init_color(ptk.COLOR_CYAN, 0, 1000, 1000)
120
+ ptk.init_color(ptk.COLOR_BLUE, 0, 0, 1000)
121
+ ptk.init_color(ptk.COLOR_GREEN, 0, 800, 0)
122
+ ptk.init_color(ptk.COLOR_RED, 1000, 0, 0)
123
+ ptk.init_color(ptk.COLOR_BLACK, 0, 0, 0)
96
124
  except Exception:
97
125
  pass
98
126
  for i in range(1,8):
99
- curses.init_pair(i, i, -1)
127
+ ptk.init_pair(i, i, -1)
100
128
  except Exception:
101
129
  pass
102
130
  sel = 0
@@ -106,13 +134,13 @@ def _menu(stdscr):
106
134
  h, w = stdscr.getmaxyx()
107
135
  title_h = len(TITLE)
108
136
  title_start = 0
109
- colors = [curses.COLOR_MAGENTA, curses.COLOR_MAGENTA, curses.COLOR_CYAN, curses.COLOR_CYAN, curses.COLOR_GREEN, curses.COLOR_GREEN]
137
+ colors = [ptk.COLOR_MAGENTA, ptk.COLOR_MAGENTA, ptk.COLOR_CYAN, ptk.COLOR_CYAN, ptk.COLOR_GREEN, ptk.COLOR_GREEN]
110
138
  for i, line in enumerate(TITLE):
111
139
  try:
112
- stdscr.addstr(title_start + i, 0, line, curses.color_pair(colors[i]))
140
+ stdscr.addstr(title_start + i, 0, line, ptk.color_pair(colors[i]))
113
141
  except Exception:
114
142
  pass
115
- stdscr.addstr(title_h + 1, 2, "Use Up/Down, PageUp/PageDown, Enter to start, ESC to quit", curses.color_pair(curses.COLOR_WHITE))
143
+ stdscr.addstr(title_h + 1, 2, "Use Up/Down, PageUp/PageDown, Enter to start, ESC to quit", ptk.color_pair(ptk.COLOR_WHITE))
116
144
  start_y = title_h + 3
117
145
  # number of lines available for the game list
118
146
  avail = max(1, h - start_y - 2)
@@ -126,9 +154,9 @@ def _menu(stdscr):
126
154
  for vis_i in range(min(avail, total)):
127
155
  i = top + vis_i
128
156
  name = GAMES[i][0]
129
- attr = curses.A_REVERSE if i == sel else curses.A_NORMAL
157
+ attr = ptk.A_REVERSE if i == sel else ptk.A_NORMAL
130
158
  try:
131
- stdscr.addstr(start_y + vis_i, 2, name[:w-4], curses.color_pair(curses.COLOR_CYAN) | attr)
159
+ stdscr.addstr(start_y + vis_i, 2, name[:w-4], ptk.color_pair(ptk.COLOR_CYAN) | attr)
132
160
  except Exception:
133
161
  pass
134
162
  # optional scrollbar indicator when list is long
@@ -155,15 +183,34 @@ def _menu(stdscr):
155
183
  stdscr.refresh()
156
184
 
157
185
  ch = stdscr.getch()
158
- if ch == curses.KEY_UP:
186
+ if ch == ptk.KEY_UP:
159
187
  sel = max(0, sel - 1)
160
- elif ch == curses.KEY_DOWN:
188
+ elif ch == ptk.KEY_DOWN:
161
189
  sel = min(len(GAMES) - 1, sel + 1)
162
- elif ch == curses.KEY_PPAGE: # Page Up
190
+ elif ch == ptk.KEY_PPAGE: # Page Up
163
191
  sel = max(0, sel - avail)
164
- elif ch == curses.KEY_NPAGE: # Page Down
192
+ elif ch == ptk.KEY_NPAGE: # Page Down
165
193
  sel = min(len(GAMES) - 1, sel + avail)
166
194
  elif is_enter_key(ch):
195
+ # Before leaving the menu, validate the selected game's minimum
196
+ # terminal size (if declared). If it's too small, show an
197
+ # on-screen message and keep the menu running.
198
+ try:
199
+ rel = GAMES[sel][1]
200
+ mins = GAME_MINS.get(rel)
201
+ if mins:
202
+ min_cols, min_rows = mins
203
+ if min_cols and min_rows and (w < int(min_cols) or h < int(min_rows)):
204
+ try:
205
+ msg = f"Terminal too small: {w}x{h}, need {min_cols}x{min_rows}. Resize to start."
206
+ stdscr.addstr(max(0, h-1), 2, msg[:max(0, w-4)], ptk.color_pair(ptk.COLOR_RED))
207
+ stdscr.refresh()
208
+ time.sleep(1.5)
209
+ except Exception:
210
+ pass
211
+ continue
212
+ except Exception:
213
+ pass
167
214
  return sel
168
215
  elif ch == 27:
169
216
  return None
@@ -174,7 +221,7 @@ def _menu(stdscr):
174
221
  top = sel - avail + 1
175
222
 
176
223
 
177
- def _run_game_by_index(choice):
224
+ def _run_game_by_index(choice, from_menu=False):
178
225
  """Load and run the game given by numeric index in GAMES."""
179
226
  name, relpath = GAMES[choice]
180
227
  base = os.path.dirname(__file__)
@@ -207,7 +254,29 @@ def _run_game_by_index(choice):
207
254
  pass
208
255
  if hasattr(mod, 'main'):
209
256
  try:
210
- curses.wrapper(mod.main)
257
+ # If the module exposes minimum terminal requirements, verify
258
+ # them before entering the alternate screen so messages are visible
259
+ try:
260
+ min_cols = getattr(mod, 'MIN_COLS', None)
261
+ min_rows = getattr(mod, 'MIN_ROWS', None)
262
+ if min_cols is None and hasattr(mod, 'MIN_TERMINAL'):
263
+ t = getattr(mod, 'MIN_TERMINAL')
264
+ if isinstance(t, (tuple, list)) and len(t) >= 2:
265
+ min_cols, min_rows = t[0], t[1]
266
+ if min_cols is not None and min_rows is not None:
267
+ verify_terminal_size(name, int(min_cols), int(min_rows))
268
+ except SystemExit:
269
+ return
270
+ except Exception:
271
+ pass
272
+
273
+ ptk.wrapper(mod.main)
274
+ # If launched via `clia run`, exit the process after the game ends.
275
+ if not from_menu:
276
+ try:
277
+ sys.exit(0)
278
+ except SystemExit:
279
+ raise
211
280
  except Exception as e:
212
281
  print(f" [ERROR] Error running game {name}: {e}")
213
282
  else:
@@ -389,7 +458,7 @@ def main():
389
458
  return
390
459
  # run the selected game (skip menu)
391
460
  try:
392
- _run_game_by_index(choice)
461
+ _run_game_by_index(choice, from_menu=False)
393
462
  except Exception as e:
394
463
  print(f" [ERROR] Error running game: {e}")
395
464
  return
@@ -421,47 +490,21 @@ def main():
421
490
  _reset_game_by_index(choice, yes=yes)
422
491
  return
423
492
 
424
- # run the menu under curses, then launch the chosen game's main()
425
- choice = curses.wrapper(_menu)
426
- if choice is None:
427
- return
428
- name, relpath = GAMES[choice]
429
- base = os.path.dirname(__file__)
430
- path = os.path.join(base, relpath)
431
- if not os.path.exists(path):
432
- print(f" [INFO] Game file not found: {path}")
433
- return
434
- # Ensure the game's directory is on sys.path so local imports (like `highscores`) resolve
435
- game_dir = os.path.dirname(path)
436
- spec = importlib.util.spec_from_file_location(f"cli_game_{choice}", path)
437
- mod = importlib.util.module_from_spec(spec)
438
- inserted = []
439
- try:
440
- proj_root = os.path.dirname(__file__)
441
- if game_dir and game_dir not in sys.path:
442
- sys.path.insert(0, game_dir)
443
- inserted.append(game_dir)
444
- if proj_root and proj_root not in sys.path:
445
- sys.path.insert(0, proj_root)
446
- inserted.append(proj_root)
447
- spec.loader.exec_module(mod)
448
- except Exception as e:
449
- print(f" [INFO] Failed to load game {name}: {e}")
450
- return
451
- finally:
452
- for p in inserted:
453
- try:
454
- sys.path.remove(p)
455
- except Exception:
456
- pass
457
- # call the game's main function if present
458
- if hasattr(mod, 'main'):
493
+ # Interactive menu loop: verify terminal size before showing menu each time,
494
+ # run the selected game, then return to the menu when the game exits.
495
+ while True:
459
496
  try:
460
- curses.wrapper(mod.main)
497
+ verify_terminal_size('CLI Arcade', 70, 20)
498
+ except SystemExit:
499
+ return
500
+ choice = ptk.wrapper(_menu)
501
+ if choice is None:
502
+ break
503
+ # Run the selected game (this returns when the game exits, e.g. ESC)
504
+ try:
505
+ _run_game_by_index(choice, from_menu=True)
461
506
  except Exception as e:
462
- print(f" [ERROR] Error running game {name}: {e}")
463
- else:
464
- print(f" [INFO] Game {name} has no main(stdscr) entry point.")
507
+ print(f" [ERROR] Error running game: {e}")
465
508
 
466
509
 
467
510
  if __name__ == '__main__':
@@ -1,4 +1,3 @@
1
- CHANGELOG.md
2
1
  LICENSE
3
2
  MANIFEST.in
4
3
  PYPI_README.md
@@ -10,11 +9,17 @@ game_classes/__init__.py
10
9
  game_classes/game_base.py
11
10
  game_classes/highscores.py
12
11
  game_classes/menu.py
12
+ game_classes/ptk.py
13
13
  game_classes/tools.py
14
14
  game_classes/__pycache__/__init__.cpython-313.pyc
15
15
  game_classes/__pycache__/game_base.cpython-313.pyc
16
16
  game_classes/__pycache__/highscores.cpython-313.pyc
17
17
  game_classes/__pycache__/menu.cpython-313.pyc
18
+ game_classes/__pycache__/ptk.cpython-313.pyc
19
+ game_classes/__pycache__/ptk_curses.cpython-313.pyc
20
+ game_classes/__pycache__/ptk_game_base.cpython-313.pyc
21
+ game_classes/__pycache__/ptk_menu.cpython-313.pyc
22
+ game_classes/__pycache__/ptk_tools.cpython-313.pyc
18
23
  game_classes/__pycache__/tools.cpython-313.pyc
19
24
  games/__init__.py
20
25
  games/byte_bouncer/__init__.py
@@ -1,9 +1,9 @@
1
- import curses
1
+ from game_classes import ptk
2
2
  import time
3
3
  from game_classes.tools import get_terminal_size
4
4
 
5
5
  class GameBase:
6
- def __init__(self, stdscr, player_name, tick, color=curses.COLOR_GREEN):
6
+ def __init__(self, stdscr, player_name, tick, color=ptk.COLOR_GREEN):
7
7
  self.stdscr = stdscr
8
8
  self.player_name = player_name
9
9
  self.tick = tick
@@ -65,7 +65,7 @@ class GameBase:
65
65
  return True
66
66
  if not getattr(self, 'over', False):
67
67
  # toggle pause on Backspace
68
- if ch in (curses.KEY_BACKSPACE, 127, 8):
68
+ if ch in (ptk.KEY_BACKSPACE, 127, 8):
69
69
  self.paused = not getattr(self, 'paused', False)
70
70
  # movement only when not paused
71
71
  elif not getattr(self, 'paused', False):
@@ -76,7 +76,7 @@ class GameBase:
76
76
  try:
77
77
  py = max(0, min(self.height, self.height // 2))
78
78
  px = max(0, (self.width - len(msg)) // 2)
79
- self.stdscr.addstr(py, px, msg, curses.color_pair(curses.COLOR_RED) | curses.A_BOLD)
79
+ self.stdscr.addstr(py, px, msg, ptk.color_pair(ptk.COLOR_RED) | ptk.A_BOLD)
80
80
  except Exception:
81
81
  pass
82
82
 
@@ -85,7 +85,7 @@ class GameBase:
85
85
  try:
86
86
  for i, line in enumerate(self.title):
87
87
  try:
88
- self.stdscr.addstr(i, 0, line, curses.color_pair(self.color) | curses.A_BOLD)
88
+ self.stdscr.addstr(i, 0, line, ptk.color_pair(self.color) | ptk.A_BOLD)
89
89
  except Exception:
90
90
  pass
91
91
  except Exception:
@@ -1,4 +1,4 @@
1
- import curses
1
+ from game_classes import ptk
2
2
  from game_classes.tools import is_enter_key
3
3
 
4
4
  class Menu:
@@ -19,7 +19,7 @@ class Menu:
19
19
  return name.strip() or 'Player'
20
20
  elif ch in (27,):
21
21
  return False
22
- elif ch in (curses.KEY_BACKSPACE, 127, 8):
22
+ elif ch in (ptk.KEY_BACKSPACE, 127, 8):
23
23
  name = name[:-1]
24
24
  elif 32 <= ch <= 126 and len(name) < max_len:
25
25
  name += chr(ch)
@@ -34,7 +34,7 @@ class Menu:
34
34
  title_height = len(self.game.title)
35
35
  for i, line in enumerate(self.game.title):
36
36
  try:
37
- self.game.stdscr.addstr(i, 0, line, curses.color_pair(self.game.color) | curses.A_BOLD)
37
+ self.game.stdscr.addstr(i, 0, line, ptk.color_pair(self.game.color) | ptk.A_BOLD)
38
38
  except Exception:
39
39
  pass
40
40
 
@@ -51,7 +51,7 @@ class Menu:
51
51
  self.game.stdscr.refresh()
52
52
  while True:
53
53
  ch = self.game.stdscr.getch()
54
- # if ch in (ord('s'), ord('S')) or ch == curses.KEY_DOWN:
54
+ # if ch in (ord('s'), ord('S')) or ch == ptk.KEY_DOWN:
55
55
  if is_enter_key(ch):
56
56
  # prompt for name before starting, centered over the title block
57
57
  prompt_y = title_height + 3