- Created by Aritro Saha (21BLC1174)
- Created as a part of placement task in Hitwicket
This project implements a turn-based, chess-like game with a server-client architecture. It features real-time gameplay using WebSocket communication and a web-based user interface.
- Navigate to the server directory:
cd server
- Install dependencies:
npm install
- Start the server:
The server will start running on
npm run dev
http://localhost:3000
.
- Navigate to the client directory:
cd client
- Install dependencies:
npm install
- Start the development server:
npm run dev
The frontend will be accessible at http://localhost:5173
.
If you prefer to run the project using Docker, follow these steps:
- Docker
- Docker Compose
-
Ensure Docker is installed and running on your machine.
-
Navigate to the root directory of your project where the docker-compose.yml file is located.
-
Build and start the services:
docker-compose up --build
This will start both the backend and frontend services in development mode.
-
Access the frontend at
http://localhost:5173
and the backend athttp://localhost:3000
.
To stop the running containers, use:
docker-compose down
- Open two browser windows and navigate to
http://localhost:5173
in each. - In one window, click "Create Game" to start a new game.
- Copy the generated Game ID.
- In the second window, paste the Game ID and click "Join Game".
- Once both players have joined, set up your teams.
- The game will start once both teams are set up.
- 5x5 grid board
- Two players
- Each player controls a team of 5 characters
- Pawn (P):
- Moves one block in any direction (Left, Right, Forward, or Backward)
- Hero1 (H1):
- Moves two blocks straight in any direction
- Eliminates any opponent's character in its path
- Hero2 (H2):
- Moves two blocks diagonally in any direction
- Eliminates any opponent's character in its path
- Turn-based moves
- Players can select their character and choose from available moves
- Characters can eliminate opponent's pieces by moving to their position
- The game ends when all of one player's characters are eliminated
- Interactive game board
- Team setup interface
- Move selection for characters
- Real-time game state updates
main-directory/
├── server/
│ ├── src/
│ │ ├── server.js
│ │ ├── game.js
│ │ └── characters/
│ │ ├── Pawn.js
│ │ ├── Hero1.js
│ │ └── Hero2.js
│ └── package.json
├── client/
│ ├── src/
│ │ ├── App.jsx
│ │ ├── components/
│ │ │ ├── Board.jsx
│ │ │ ├── Cell.jsx
│ │ │ ├── Controls.jsx
│ │ │ └── MoveOptions.jsx
│ │ ├── hooks/
│ │ │ └── useSocket.js
│ │ └── main.jsx
│ ├── index.html
│ ├── package.json
│ └── vite.config.js
└── README.md
server.js
: Main server file, handles WebSocket connections and game eventsgame.js
: Implements game logic and state management- Character classes: Define movement and attack patterns for each character type
App.jsx
: Main React component, manages game state and UIBoard.jsx
: Renders the game boardControls.jsx
: Provides game control interface (create, join, setup)MoveOptions.jsx
: Displays available moves for selected characters
createGame
: Create a new gamejoinGame
: Join an existing gamesetupTeam
: Set up a player's teammove
: Make a move in the gamegameUpdate
: Update game state (sent from server to clients)gameOver
: Notify game end and winner
- Add more character types with unique abilities
- Implement a spectator mode
- Add a chat feature for players
- Create an AI opponent for single-player mode
- Implement a ranking system for competitive play
- Ensure both the backend and frontend servers are running
- Check console logs for any error messages
- Verify that the WebSocket connection is established successfully
For more detailed information, refer to the backend and frontend documentation sections.