Skip to content

Provide text-based UI option #239

@dmccoystephenson

Description

@dmccoystephenson

Summary

Add an optional text-based UI (TUI) mode as an alternative to the standard pygame UI, selectable at launch.

Background

Roam currently depends entirely on pygame for rendering. A TUI mode would allow the game to run in environments where a display is unavailable (e.g. SSH sessions, headless servers) and makes the game more accessible. The TUI should be a thin rendering layer over the existing game logic — no business logic should move into the UI layer.

Requirements

Launch Flag

  • Add a --tui command-line argument to src/roam.py (via argparse) that switches the active UI mode to TUI
  • The default (no flag) retains the existing pygame behaviour unchanged

Abstraction Layer

  • Introduce a UI interface (e.g. src/ui/baseUI.py) that both the pygame renderer and the TUI renderer implement, covering at minimum:
    • draw(room, player, stats) — render the current game state
    • getInput() — return the next player action
    • showMessage(text) — display a status message
  • Register the active UI implementation in the DI container (src/bootstrap.py) based on the launch flag, so game logic resolves BaseUI without knowing which renderer is active

TUI Renderer

  • Implement src/ui/tuiRenderer.py using Python's stdlib curses module (no third-party TUI libraries)
  • Render the current room as an ASCII grid — one character per entity (e.g. G = Grass, T = Tree, @ = Player, B = Bear, C = Chicken, . = empty)
  • Display player energy, selected hotbar slot, room coordinates, and status messages in a sidebar or header
  • Support the same keybindings defined in KeyBindings (src/config/keyBindings.py) for movement, inventory, and other actions

Screens

  • TUI equivalents are required for: world view, inventory screen, stats screen, main menu
  • Save selection and options screens may display a simplified text-only fallback

Persistence

  • No changes to save/load logic — TUI mode reads and writes the same JSON files as pygame mode

Platform Support

  • curses is stdlib on macOS/Linux; on Windows use the windows-curses package (add to requirements.txt with a platform marker: windows-curses; sys_platform == "win32")

Acceptance Criteria

  • python src/roam.py --tui launches the game in TUI mode without requiring a display
  • python src/roam.py launches the game in pygame mode unchanged
  • The TUI renders the current room as an ASCII grid with entity legend
  • Player movement, inventory, and stats screens are accessible in TUI mode
  • Save files written in TUI mode are loadable in pygame mode and vice versa
  • All existing pygame tests pass unmodified
  • New tests cover the TUI renderer and the UI abstraction layer

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions