This project is a Trivia Game designed for the IDC course at Ben-Gurion University. It establishes a TCP connection between a server and multiple clients, facilitating a multiplayer trivia game with timed responses.
The goal of this project is to enable a trivia game where a server sends questions to clients over a TCP connection. Each client has 10 seconds to answer. If a client answers incorrectly or fails to respond in time, the next question is sent until one client wins. Upon winning, the server restarts and looks for new client connections, allowing continuous play.
- Multiplayer Support: Connects multiple clients to a single server for group trivia play.
- Timed Responses: Each client has a 10-second window to answer each question.
- Automatic Restart: Server resets to allow new players to join after a game ends.
- Trivia Pool: Over 30 unique trivia questions with true/false answers.
-
Clone the Repository:
git clone https://github.com/shvants/IDC-Trivia-Project.git cd IDC-Trivia-Project -
Dependencies:
- Ensure you have Python installed (preferably Python 3.6+).
- Install the necessary libraries:
pip install colorama scapy
-
Running the Server:
- In one terminal window, start the server:
python server.py
- In one terminal window, start the server:
-
Running the Client:
- In separate terminal windows, start each client instance:
python client.py
- In separate terminal windows, start each client instance:
- Start the server, which will broadcast a UDP message to identify clients.
- Each client listens for the server’s broadcast and connects to it.
- Once connected, the server sends trivia questions, and each client answers.
- If a client wins by correctly answering a question, the game ends, and the server resets.
client.py: Contains theClientclass, responsible for connecting to the server, receiving trivia questions, and sending answers.server.py: Contains theServerclass, which handles broadcasting, accepting client connections, and managing game rounds.style.py: Defines text styles (colors and formats) for terminal output, enhancing user experience.trivia_generator.py: Defines theTriviaGeneratorclass, managing the trivia question pool and ensuring each question is unique per session.README.md: Documentation for project setup, usage, and features.