https://github.com/silky-x0/2chess
A full Stack Chess game-in making!
https://github.com/silky-x0/2chess
chess ejs express javascript nodejs socket-io
Last synced: 3 months ago
JSON representation
A full Stack Chess game-in making!
- Host: GitHub
- URL: https://github.com/silky-x0/2chess
- Owner: silky-x0
- Created: 2025-02-12T11:41:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-16T17:22:13.000Z (about 1 year ago)
- Last Synced: 2025-06-06T00:40:14.353Z (about 1 year ago)
- Topics: chess, ejs, express, javascript, nodejs, socket-io
- Language: JavaScript
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 2chess - Real-time Chess Game
A real-time multiplayer chess game built with Node.js, Socket.IO, and Chess.js.
## Project Structure
```
2chess/
├── views/
│ └── index.ejs # Chess game interface
├── public/
│ └── js/
│ └── chessGame.js # Client-side game logic
├── app.js # Server entry point
├── package.json
└── README.md
```
## Technology Stack
### Core
- Node.js + Express.js for server
- Socket.IO for real-time gameplay
- Chess.js for game logic
- EJS for templating
### Features
- Real-time multiplayer chess
- Drag and drop piece movement
- Role-based gameplay (white/black/spectator)
- Automatic board flipping for black player
- Unicode chess pieces
- Move validation
## Game Features
### Implemented
- [x] Two-player game support
- [x] Spectator mode
- [x] Real-time move updates
- [x] Valid move enforcement
- [x] Player turn management
- [x] Drag and drop interface
- [x] Responsive chessboard
### Socket Events
- `playerRole` - Assigns white/black role
- `spectatorRole` - Assigns spectator status
- `move` - Handles piece movements
- `boardState` - Syncs game state
- `invalid Move` - Handles invalid moves
## Setup Instructions
1. Clone the repository:
```bash
git clone https://github.com/silky-x0/2chess.git
cd 2chess
```
2. Install dependencies:
```bash
npm install
```
3. Start the server:
```bash
node app.js
```
4. Access the game:
- Open `http://localhost:3000` in your browser
- First player gets white pieces
- Second player gets black pieces
- Additional connections become spectators
## Dependencies
- express: ^5.1.0
- socket.io: ^4.8.1
- chess.js: ^1.2.0
- ejs: ^3.1.10
## Technical Details
### Client-Side
- Manages game UI and piece movement
- Handles drag and drop interactions
- Updates board visualization
- Communicates with server via Socket.IO
### Server-Side
- Manages player connections
- Validates moves using Chess.js
- Broadcasts game state updates
- Handles player roles and turns
## Contributing
1. Fork the repository
2. Create your feature branch
3. Commit your changes
4. Push to the branch
5. Open a Pull Request