|
1 | | -# SQL_Chess |
| 1 | +# ♟ SQL Chess |
| 2 | + |
| 3 | +> Play chess — and watch every move translated into real SQL queries in real time. |
| 4 | +
|
| 5 | +[](https://github.com/Devn913/SQL_Chess/actions/workflows/deploy.yml) |
| 6 | + |
| 7 | +**Live demo:** https://devn913.github.io/SQL_Chess/ |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Features |
| 12 | + |
| 13 | +| Feature | Details | |
| 14 | +|---|---| |
| 15 | +| ♟ **Fully playable chess** | All rules enforced via [chess.js](https://github.com/jhlywa/chess.js) — en passant, castling, pawn promotion, check/checkmate/stalemate | |
| 16 | +| ⬡ **SQL Panel** | Every move generates real `INSERT`, `UPDATE`, `DELETE` SQL statements with syntax highlighting | |
| 17 | +| □ **Toggle SQL** | Hide the SQL panel to play as a traditional chess board | |
| 18 | +| 👤 **Guest mode** | No login required — just open the page and play | |
| 19 | +| ⇗ **Invite link** | Click "Invite" to generate a shareable URL that encodes the full game state — anyone who opens it continues the same game | |
| 20 | +| ⇅ **Flip board** | Swap perspective between white and black | |
| 21 | +| ↩ **Undo** | Take back the last move | |
| 22 | + |
| 23 | +## How the SQL works |
| 24 | + |
| 25 | +Each game gets its own `game_id`. Three tables are used: |
| 26 | + |
| 27 | +```sql |
| 28 | +chess_game -- one row per game (id, players, status, winner) |
| 29 | +chess_piece -- one row per piece (position updated on every move) |
| 30 | +chess_move -- one row per move (full audit log) |
| 31 | +``` |
| 32 | + |
| 33 | +Example — white pawn e2 → e4: |
| 34 | + |
| 35 | +```sql |
| 36 | +INSERT INTO chess_move (game_id, move_number, color, piece_type, from_square, to_square, san) |
| 37 | +VALUES ('a1b2-c3d4-e5f6-g7h8', 1, 'white', 'pawn', 'e2', 'e4', 'e4'); |
| 38 | + |
| 39 | +UPDATE chess_piece |
| 40 | +SET position = 'e4' |
| 41 | +WHERE game_id = 'a1b2-c3d4-e5f6-g7h8' |
| 42 | + AND position = 'e2' |
| 43 | + AND color = 'white'; |
| 44 | +``` |
| 45 | + |
| 46 | +## CI/CD |
| 47 | + |
| 48 | +The repository uses **GitHub Actions** (`.github/workflows/deploy.yml`): |
| 49 | + |
| 50 | +1. **Validate** — runs `html-validate` on every push/PR to `main` |
| 51 | +2. **Deploy** — automatically publishes the site to **GitHub Pages** on every push to `main` |
| 52 | + |
| 53 | +## Local development |
| 54 | + |
| 55 | +No build step required — it's a plain HTML/CSS/JS site. |
| 56 | + |
| 57 | +```bash |
| 58 | +# Clone and open |
| 59 | +git clone https://github.com/Devn913/SQL_Chess.git |
| 60 | +cd SQL_Chess |
| 61 | +# Open index.html in your browser, or serve with any static server: |
| 62 | +npx serve . |
| 63 | +``` |
| 64 | + |
| 65 | +## License |
| 66 | + |
| 67 | +[MIT](LICENSE) |
0 commit comments