paper-dynasty-discord/CLAUDE.md
Cal Corum d2a4b27ff3
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m22s
ci: Switch to CalVer (YYYY.MM.BUILD) with auto-generated versions
Remove manual semver validation from PR checks. Versions are now
auto-generated on merge to main by counting existing monthly tags.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 16:36:53 -06:00

64 lines
2.6 KiB
Markdown

# Paper Dynasty Discord Bot
Baseball card game Discord bot. discord.py with cog-based commands, SQLModel for database ops.
## Commands
```bash
python -m pytest # Run tests
python paperdynasty.py # Start bot
pip install -r requirements.txt # Install dependencies
```
## Architecture
- **Cogs** (`cogs/`): Command modules — gameplay, economy, players, admins
- **Game engine** (`in_game/`): Turn-based simulation, AI manager, dice mechanics, WPA calculations
- **UI** (`utilities/`): Buttons, dropdowns, embeds
- **Database**: Production uses FastAPI database directly; dev may use separate PostgreSQL via SQLModel
## Key Patterns
- Cards generated from MLB statistics with complex rating calculations
- Card ratings split by handedness (`vs_hand: 'R'` or `'L'`)
- Multiple cardsets (seasons) with different priorities for gameplay
- Use factory data in testing as often as possible
## Deployment & Troubleshooting
### Production
- **Host**: `ssh sba-bots` (10.10.0.88, alias `pd-bots`)
- **Path**: `/home/cal/container-data/paper-dynasty`
- **Container**: `paper-dynasty_discord-app_1`
- **Image**: `manticorum67/paper-dynasty-discordapp`
- **Health**: `GET http://localhost:8080/health` (HTTP server in `health_server.py`)
- **Versioning**: CalVer (`YYYY.MM.BUILD`) — auto-generated on merge to `main`
### Logs
- **Container logs**: `ssh sba-bots "docker logs --since 1h paper-dynasty_discord-app_1"`
- **Log file (in container)**: `/usr/src/app/logs/discord.log` (rotating, 32MB, 5 backups)
- **Dev log mount**: `../dev-logs``/usr/src/app/logs`
### Key Env Vars
`BOT_TOKEN`, `GUILD_ID`, `API_TOKEN`, `DATABASE` (Dev/Prod), `LOG_LEVEL`, `SCOREBOARD_CHANNEL`, `TZ=America/Chicago`
### Common Issues
- Bot not responding → check `docker logs`, verify `BOT_TOKEN` and `GUILD_ID`
- API errors → verify `DATABASE` is set to `Prod` or `Dev`, check `API_TOKEN` matches the database API
- Game engine errors → check `/usr/src/app/logs/discord.log` for detailed tracebacks
- Health endpoint not responding → `health_server.py` runs on port 8080 inside the container
### CI/CD
Gitea Actions on PR to `main` — builds Docker image, auto-generates CalVer version on merge.
```bash
tea pulls create --repo cal/paper-dynasty --head <branch> --base main --title "title" --description "description"
```
### Other Containers on Same Host
`paper-dynasty_adminer_1`, `paper-dynasty_db_1`, `sba-website_sba-web_1`, `sba-ghost_sba-ghost_1`
## Development Notes
- Connect to proper docker socket when running tests
- Plans go in `./.claude/plans/` with descriptive filenames