Skip to content

A Network-based Tic-Tac-Toe application, that has used a JavaFx to make a nice looking UI, with an MVC Design pattern and use of server sockets and MS-SQL-Server as database

AymanxMohamed/Tick-Tac-Toe-Game

Repository files navigation

Tick-Tac-Toe-Game

Build Status

Description:

A NetWork-based Tic-Tac-Toe application that consists mainly of two applications server and a client. The Game has nice-looking user interfaces. The Application is done mainly using JavaFX the server has an MS-SQL-SERVER database that stores all the information about the players. and The games they are played. The application was designed using the MVC pattern. The communication between the server and the client in this game is done using JSON objects to make it easy to send and receive requests and responses.

main features

  • Nice looking User Interface

  • Register to the game

  • server side validation

  • play with ai computer

  • updated list with full information about the registered players

  • The ability to Chat with any player in the list

  • The ability to play with any player in the list

  • Updated list of the whole single and multi mode game history

  • The ability to replay any previous game from the history list

  • in Server Application you have the same players list with the ability to toggle server tatus

Application Features details

  • Sign up and Sign in as a first time player

  • Every player have a bonus points he gain after wining any game or lose if when he lose the game

  • players are classifed according to the bonus points to several ranks bronze, silver, gold, platinum, Diamond, Master, Grand Master,Challenger

  • the way that the players gain and lose the points differ in each rank.

  • player can play in single mode game with ai

  • Every player will have an updated list of the whole players in the server database this with the information of their name, bonus points, rank, status[online, offline], in Game or not, in chat or not

  • The player can click on any player in the list and play or chat with him only if this player is online and if the player is not in game or in chat.

  • The server handle all most of the possible senarios that can happen in the appication during the game or because of any issue.

  • The player can replay any game from the history.

Designs

Database ERD

Build Status

Application Design

  • in this game the client is actualy nothing
  • The Server is the big boss her :)

Client Application

The client application consists mainly of 4 packages

  • controllers: This pacakage is Responsible for dealing with the game views

  • models: This package is for storing the data of the entities that send from the server

    • player
    • singleModeHistory
    • multiModeHistory
  • netwok:` This package is the responsable for every thing it has the classes That responsable for dealiing with the server

    • Client this object is the responsable for open a socket with the server
      • it has an acceptResponse method that have a runnable object that keep reading the buffer to accept a response from t he server
      • once it read a request it pass it to the next object to handle it ResponseHandler
      • The client also has a sendRequest function that sends a request to the server as a json string so the server can parse it and send a response after it.
    • ResponseHandler This object has a function handleResponse that takes a response from the server and do a certin action according to this response.
    • RequestCreator this is a utility class that is responsable for creating the json objects and return a string to be send to the server.

Server Application

The big boss in this app The server is the responsable for every thing

  • validating player data
  • connecting with the database
  • stablish the conection between players
  • reciving the message from player and send it to the other one etc...

The server has mainly 4 packages

  • database This package is the responsable for dealing with the database and it has mainly utility class DatabaseManager that do every thing

    • DatabaseManager this class is the responsable for managing any CRUD operatin throw the application life cycle
  • network same as the client this package it the responsable for dealing with all the clients in connected to the server. it has mainly 4 objects to do this.

    • Server this calss is the responsable for accepting new clients socket then passing it to the next object playerHandler
    • playerHandler each client has a playerHandler for him to acceptReqeust and send a response from him this object has 2 main methods to do thi
      • AcceptReqeust it's the opposite of the AcceptRespoonse of the client this method takes a request as a json from the client and pass it to the next Object RequestHandler to handle this request and return immediatelty a certain response to send it back to the client.
    • RequestHandler This object is a class that have handleRequest method that takes the user request and sends an approbriate response to the player with the help of the next object.
    • ResponseCreator it's a utility class that create a response as a json object to be send to the player
  • gameLogic this package has 3 classes that mainly control the game and chat process

    • singleModeGameHandler
    • multiModeGameHandler
    • chatRoomHandler

IN Game Process

In Server Side

Server must be oppendd first because without oppening the server the client won't be able to go to his login screen and he will get an error

Build Status

After opening the server you will have the whole players list with the status of each player

Build Status

Login & Register process

indexView

this is the first view in the client app and it won't go to the login view if the server isn's oppend if the player tried to login when server is down he will get an error message

Build Status

Build Status

register

if the player is new to the game he can register first

Build Status

if the password dosn't match he will got an error

Build Status

login

If the server is opened so the player will go to the authontication stage

Build Status

if the player name is wrong he will get an error from server

Build Status

and if the password is wrong he will also get an error

Build Status

after the player login successfuly he will get the welcome screen and informed with the information with his current rank and bonus points

Build Status

player can play with the computer and specify the difficulty

final.single.mode.view.mp4

player can navigate to the online home view to see the players list and if their is player online he can send a private chat invitation or game invitation to him

Build Status

send chat invitation process

chat.video.mp4

send game invitation process

gameTest3.mp4

player also can navigate to his histry to start see his previous game with the ability to click on any game and play it

history.video.mp4

Build Status

Build Status

How to play

  • First Clone The Project
  • Create the database schema
    • you have to use Microsoft sql server
    • go to the /'00 Project Materials'/'00 Database'/'02 Database quires' and open 'new Database Schema.sql' file in your database management studio
    • after creating the data base you have to add user to the database
      • username: ayman
      • password: @01208538504@
      • databaename: TicTacToe
      • or simbly create new database but in this case you have to change the configuration in DatabaseManager.openDatabaseConnection Method

Build Status

  • After creating the database you can now build and run the server project using netbeans or intellij idea as a maven project
  • you can lunch the Client App using the executable jar file or using netbeans or intellij idea
  • You can download the jar file from this link: https://drive.google.com/drive/folders/1kxtF2Oac1KPSkNlT367PQZKnHkjNJ6Zg?usp=sharing
  • if you have any problems in running the game feel free to contact us
  • note that the server is runing by default on port 9000 you can change this in the Server class
  • note: you will never be able to try the game without the server you have to open the server first

Contributors

Ayman kheirEldeen Ahmed ElShopaky
Reem Adel Dina Reda Mai Emad

About

A Network-based Tic-Tac-Toe application, that has used a JavaFx to make a nice looking UI, with an MVC Design pattern and use of server sockets and MS-SQL-Server as database

Topics

Resources

Stars

Watchers

Forks