Fable will fix it! Pt 2

This commit is contained in:
2026-06-11 21:32:00 -07:00
parent a7cab7bcb6
commit a074ff77b1
44 changed files with 1547 additions and 4505 deletions

View File

@@ -1,8 +1,8 @@
# Rats with Gats Remote Play (`pirats`)
A web-based remote play companion app for the tabletop roleplaying game **Rats with Gats** (where players roleplay as space-faring pirate rats, or "Pi-Rats"). The application manages lobbies, character creation, card mechanics, scene phases, obstacles, challenges, and player voting.
A web-based remote play companion app for the tabletop roleplaying game **Rats with Gats** (where players roleplay as gunslinging pirate rats, or "Pi-Rats", in the magical land of Yeld). The application manages lobbies, character creation, card mechanics, scene phases, obstacles, challenges, and player voting. See [RULEBOOK.md](RULEBOOK.md) for the game rules.
It is built with **FastAPI**, **SQLModel** (SQLite database), **Jinja2 templates**, and **HTMX** for dynamic, real-time page updates.
It is built with a **FastAPI** + **SQLModel** (SQLite) backend and a **Svelte 5** single-page frontend (in `frontend/`), which polls the backend's JSON state endpoint for near-real-time updates.
---
@@ -125,16 +125,30 @@ nix develop --command pytest
```
pirats/
├── pyproject.toml # Python package metadata and dependencies
├── flake.nix # Nix package, dev shell, and NixOS service module
├── tests/ # Unit and integration tests
│ └── test_game.py # Game logic and CRUD database test suites
├── pyproject.toml # Python package metadata and dependencies
├── flake.nix # Nix package (incl. frontend build), dev shell, NixOS service module
├── tests/
│ └── test_game.py # Game logic and CRUD test suite (pure-crud, no HTTP for most)
├── frontend/ # Svelte 5 + Vite SPA
│ └── src/
│ ├── pages/ # Routes: Home, Join, Dashboard (game UI), Admin
│ ├── components/ # One component per game phase, Card.svelte, and scene/ (ScenePhase sub-panels)
│ └── lib/ # api.js (fetch wrapper), cards.js (card display helpers), suggestions.js (Suggest-button pools)
└── src/
└── pirats/ # Core Python package
├── main.py # FastAPI routes, HTTP endpoints, CLI entrypoint
├── crud.py # Core database CRUD, game mechanics, and transitions
├── models.py # SQLModel database tables (Game, Player, Obstacle, Challenge, Vote)
├── cards.py # Playing card parser, deck setups, and obstacle definitions
├── templates/ # Jinja2 HTML pages and HTMX snippets
── static/ # CSS styles and frontend assets
└── pirats/ # FastAPI backend package
├── main.py # App setup, /api/game create/join/state endpoints, CLI entrypoint
├── models.py # SQLModel tables (Game, Player, Obstacle, Challenge, Vote, GameEvent)
├── cards.py # Card parsing, deck building, obstacle table from the rulebook
├── crud.py # Facade re-exporting all crud_* modules
├── crud_*.py # Game logic by phase: base (deck/hands/rank), character, scene, challenge, upkeep
── routes_*.py # Thin API routers by phase, mounted under /api
└── static/ # Built frontend lands here (gitignored; populated by the Nix build)
```
### Frontend Development
Run the backend (`pirats --reload`) and the Vite dev server side by side; Vite proxies `/api` to port 8000:
```bash
cd frontend && npm install && npm run dev
```