Skip to content

Project for tic-tac-toe game with a server and 2 clients. Java 17, Spring Boot, Maven, JUnit.

Notifications You must be signed in to change notification settings

lexeldev/tic-tac-toe-with-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Tic Tac Toe Game

This project implements a Tic Tac Toe game with a client-server architecture using Java and Spring Boot. The game allows two players to play against each other by connecting to a server. The game logic, synchronization, and logging are managed by the server, while the clients handle player moves and interactions with the server.

Game Flow

  1. Both players register with the server.
  2. Players take turns to make moves.
  3. The server validates each move and updates the game state.
  4. The game continues until a player wins or the game ends in a draw.
  5. Once the game is over, both players acknowledge the game over to the server.
  6. The server shuts down automatically after both players acknowledge the game over.

Logging

Logging is implemented to track the flow of the game and debug issues. The logs include:

  • Player registration information.
  • Moves made by players.
  • Game status updates.
  • Acknowledgments from players when the game is over.
  • Server shutdown information.

Logs for the server and clients are displayed in the respective terminal windows. They provide detailed information about the game flow and any issues that may occur.

Running the Server

  1. Navigate to the server directory.

  2. Run the following command to start the server:

    mvn spring-boot:run

The server will start on port 8080.

Running the Clients

  1. Navigate to the client directory.

  2. Run the following command to start the first client:

    java -jar target/client-0.0.1-SNAPSHOT.jar --server.port=8081

  3. In a separate terminal, run the following command to start the second client:

    java -jar target/client-0.0.1-SNAPSHOT.jar --server.port=8082

The clients will connect to the server and start playing the game automatically.

Automatic Shutdown

  • The server shuts down automatically 5 seconds after both clients acknowledge the game over.
  • Each client shuts down automatically after acknowledging the game over to the server.

About

Project for tic-tac-toe game with a server and 2 clients. Java 17, Spring Boot, Maven, JUnit.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages