4IT353 (Klient/Server v Jave) - První semestrální úloha
This project is an online implementation of the board game “Cards Against Humanity” written in pure Java, featuring a server and client using JavaFX. The communication between the client and server is managed through sockets with CompletableFuture and polling, utilizing multiple threads.
Nikita (Nick) Korotov, Mykhailo Bubnov
- Basic Description
- Game Flow
- Unresolved Issues
- Running the Server
- Running the Client
- Technical Details
- Dependencies
- Contributing
- License
The client application provides a user interface where players can see their cards, the cards on the table, the active " black card," and other game information. It allows players to interact with the game, including selecting cards and submitting responses. The client connects to the server via sockets, establishing a connection to send messages (via the GUI) such as selecting cards or responding to the "black card," and to receive messages from the server like game state updates and new cards.
The server manages the game flow, including when cards are played and who wins each round. It maintains the game state, including the list of players, their cards, and the current cards on the table. Upon receiving a message from a client, the server responds according to the game rules and updates the game state. The server features “lobbies” that players can create and join.
A player connects to the server by entering the IP address and port of a server, then provides a username. The player can then create a new lobby or join an existing one. Once a sufficient number of participants join, the game starts automatically. The game flow is the same for all participants:
- Players are randomly assigned several white cards (with text to fill in the black cards) that are displayed to them.
- The server starts the first round by displaying a black card with a prompt and a blank space.
- Participants have unlimited time to choose the funniest response from their white cards.
- Once all participants have selected their cards, all choices are displayed for everyone to see, and each player can vote for the best response.
- The response with the most votes wins the round, and points are awarded to the player who submitted it.
The rounds continue until the end of the game, with the player having the most points declared the winner.
- Password protection for lobbies
- Timer for player responses
- Restriction on voting for one's own card
- Unification of the polling mechanism on both server and client sides, as well as between commands
To start the server, execute the following command:
java -jar haj-server-1.0.jar
You will be prompted to enter port (e.g., 8080) or press Enter to use the default values. The server will then start, waiting for clients to connect.
To start the client, execute the following command:
java -jar haj-client-1.0.jar
You will be prompted to enter the host (e.g., 127.0.0.1) and port (e.g., 8080) or press Enter to use the default values. The application will then launch, allowing you to enter a username, create or join a lobby, and start playing.
- Written in pure Java
- Uses sockets for communication
- Manages multiple clients using multiple threads
- Game logic and state management
- Uses CompletableFuture for asynchronous tasks
- Written in pure Java
- Uses JavaFX for the graphical user interface
- Connects to the server via sockets
- Displays game state and allows user interaction
- Java SE Development Kit 11 or higher
- JavaFX SDK
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a new branch
git checkout -b feature-branch
- Commit your changes
git commit -m 'Add new feature'
- Push to the branch
git push origin feature-branch
- Open a pull request
This project is licensed under the MIT License. See the LICENSE file for more details.