Make sure you’ve completed the Installation steps before proceeding.
Starting the Backend Server
Verify Environment Configuration
Ensure your
.env file is properly configured. For quick local play:The backend will default to port 3001 if PORT is not specified in server.js:13
Starting the Frontend Client
Start the Development Server
Launch the Vite development server:You should see output like:
The
--host flag in the dev script (Frontend/package.json:8) allows access from other devices on your network.Creating Your First Game
Register or Login
When you first open the game, you’ll need to create an account or login:
- Register: POST to
/api/auth/registerwith username, email, and password - Login: POST to
/api/auth/loginwith email and password
Authentication is handled via JWT tokens. Your session will persist across browser refreshes.
Create a Room (Host Player)
Click “Crear Sala” (Create Room).The backend will:
- Generate a unique 6-digit room code (e.g.,
123 456) - Create a Socket.io room
- Display the code on your screen
Share this 6-digit code with the player who wants to join your game.
Join a Room (Guest Player)
The second player should:
- Open their browser to
http://[HOST_IP]:5173- Example:
http://192.168.1.100:5173
- Example:
- Login or register
- Navigate to “Juego en Red (LAN)”
- Enter the 6-digit room code
- Click “Unirse a Sala” (Join Room)
Game Starts Automatically
Once both players are connected:
- The game will start automatically
- The host player always goes first
- Each player has 12 seconds per turn
- Actions are synchronized in real-time via Socket.io
Game events are transmitted using the
game_event socket event (Backend/README.md:24), which forwards actions to the other player in the room.Quick Reference
Port Configuration
| Service | Default Port | Configuration |
|---|---|---|
| Backend | 3001 | Backend/server.js:13 |
| Frontend | 5173 | Vite default |
Terminal Commands Cheat Sheet
Socket.io Events
| Event | Direction | Purpose |
|---|---|---|
create_room | Client → Server | Create a new game room |
join_room | Client → Server | Join existing room with code |
game_event | Client ↔ Server | Synchronize game actions |
Game Controls
Once in a match:- Left Click: Select a card
- Drag card to slot: Play card from hand
- Click field card + click enemy card: Attack
- Click two owned field cards: Fusion (same type and level)
Troubleshooting
Backend Not Starting
Frontend Can’t Connect to Backend
- Verify backend is running:
http://localhost:3001/ping - Check that both services use the same network
- Ensure firewall allows connections on ports 3001 and 5173
- Verify the backend’s network IP matches what the frontend is connecting to
Room Not Found Error
- Verify the 6-digit code is correct
- Ensure the host created the room before the guest tries to join
- Check that both players are connected to the same backend server
- Room codes are stored in memory (Backend/README.md:39) and cleared when the server restarts
Actions Not Syncing
- Open browser console (F12) and check for Socket.io errors
- Verify stable network connection
- Restart both the backend and clients
- Check that both clients are in the same room
Next Steps
Now that you have a game running:- Learn about Game Architecture to understand the codebase
- Explore Socket.io Events for real-time communication
- Read about Game Mechanics for detailed rules
- Check out LAN Setup for advanced configuration
For more detailed troubleshooting and LAN play configuration, see the complete LAN Setup Guide and Troubleshooting.