This project is a real-time, server-based chess game designed for friends to play online. The game utilizes WebSockets for communication, allowing players to make moves and interact in real time.
- Real-time gameplay for two players.
- Validates player moves and ensures turn-based play.
- Detects game-over scenarios, including checkmate and stalemate.
- Error handling for invalid moves or actions outside a player's turn.
- Responsive UI with a chessboard component for intuitive gameplay.
- Visually appealing UI: Includes animations and transitions for a smooth user experience.
- CSS Animations: Different animations enhance interactivity, such as smooth piece movements, glowing effects for valid moves, and transitions for board updates.
- Frontend: React.js, CSS
- Backend: Node.js, WebSockets
- Logic: Chess.js for game mechanics
-
Clone the Repository:
git clone <repository-url> cd BackEnd1
-
Install Dependencies:
npm install
-
Start the Server:
node src/index.js
-
Run the Client: Navigate to the
FrontEnd
directory and start the React app:cd FrontEnd npm start
- GameManager.js: Handles user connections, game initialization, and communication between players.
- Game.js: Implements the game logic, including move validation, turn management, and game-over detection.
- Game.jsx: The main React component for the game UI. It manages WebSocket connections, board state, and game controls.
-
Addressing Opponent Moves:
- Ensuring that moves made by one player were accurately transmitted and updated on the opponent's board.
-
Managing Turn-Based Play:
- Handling turn logic to ensure only the appropriate player could make a move at a given time.processing a move.
-
Error Handling for Invalid Actions:
- Preventing invalid moves and providing meaningful feedback to users.
-
Creating an Engaging UI:
- Incorporating CSS animations to enhance the user experience.
- Open the application and wait for an opponent to connect.
- Click "Start Game" to begin once both players are connected.
- Take turns making moves. The game ends when a player wins, draws, or the game is stalemated.
- If an error occurs (e.g., making a move out of turn), a message will be displayed.
- Add a chat feature for players to communicate.
- Implement a matchmaking system for random opponents.
- Save game history and allow players to review moves.
- Add support for timers to enforce time limits per move.
- Further refine animations for enhanced gameplay experiences.
Feel free to fork the repository and submit pull requests. Contributions to enhance the game are always welcome!