A web-based implementation of the 6-player, 4-deck variant of the popular Chinese card game "Shengji" (Upgrades), specifically the "Gunzi" (滚子) ruleset.
This project consists of a Python FastAPI backend and a React/Vite frontend.
backend/: FastAPI application handling game logic, state management, and rules enforcement.frontend/: React application using Vite, TailwindCSS, and WebSockets for real-time game interaction.
- Python: 3.8+
- Node.js: 16+
- Package Manager:
pip(for Python) andpnpm(or npm/yarn) for Node.js.
Open a terminal and navigate to the backend directory:
cd backendCreate a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtRun the server:
uvicorn app.main:app --reloadThe backend API will run at http://127.0.0.1:8000.
Open a new terminal window and navigate to the frontend directory:
cd frontendInstall dependencies:
# If you don't have pnpm installed: npm install -g pnpm
pnpm installRun the development server:
pnpm devThe frontend will open at http://localhost:5173 (or similar).
Since this game requires 6 players, the project includes a "God Mode" for easier testing and development.
- Open the frontend URL (
http://localhost:5173). - Enter a Room Name (e.g.,
test) and your Player Name. - Click "Create & Join".
- In the game room header, click the green "+ 5 Bots (Debug)" button. This will simulate 5 additional players joining the room.
- Click "Start Game" to begin dealing cards.
- Multi-View: You can switch between any of the 6 players by clicking their name tabs at the top of the screen.
- Drawing Phase: New cards appear automatically. Select cards and click "Declare Main" to call the main suit (Liang Zhu).
- Exchange Phase: If you are the Dealer, switch to your tab. You will receive the bottom cards and must select 6 cards to discard.
- Playing Phase:
- Select cards from your hand and click "Play Selected".
- The system enforces detailed rules (Suit Following, Dead Stick Rule). Illegal moves will trigger an alert.
- The table view shows played cards in a 2x3 grid, always rotating so "Me" is at the bottom center.
- **4 Decks **: 216 cards total.
- Dead Stick (死棒): The backend and frontend enforce strict structure following rules (e.g., if a Pair is led, you must follow with a Pair if you have one).
- Scoring: Real-time tracking of Dealer Team vs. Catching Teams scores.
- Kou Di (抠底): Automatic calculation of bottom card points multiplier at the end of the game.