Content of this repository represents source code of the SeaBattle game: https://seabattleakvelon.herokuapp.com
According to design task, see "Task" folder, application consists of two parts: backend and frontend.
Backend part was designed using C# language and ASP.NET Core framework. By means of special algorithm, backend generates random ships positions and store them in database. On HTTP request it can change positions or provide them to the frontend part. Backend also gets information about current user from frontend, store this information in database and by means of differents HTTP requests performs some actions and returns result back to the frontend.
Backend API description.
Actions with information about ships:
- GET hostadress/api/shiptypes -- Returns information about ships positions and their initial health state;
- PUT hostadress/api/shiptypes -- Makes backend generate and store new ships positions in database;
Actions with information about users:
- GET hostadress/api/users -- Returns a list of users in shots-ascending order;
- GET hostadress/api/users/top -- Returns a list of users with number of shots higher or equal than 17 in shot-ascending order;
- POST hostadress/api/users -- Initializes a new user by his name and number of shots {"Name" : "Ivan", "NumShots" : 0 };
- PUT hostadress/api/users -- Updates the number of shots of the specific user. There is a need to request in a way {"Id" : 1, "Name" : "Ivan", "NumShots" : NEW NUMBER };
- PUT hostadress/api/users/clear -- Optional Deletes information about all users.
How to test backend part?
If you want to test backend API you can send HTTP requests to https://battleshipsmumutoje.azurewebsites.net or if you want to run backend application locally you need:
- Clone repository: git clone https://github.com/mumutoje/SeaBattle.git
- Install MS Visual Studio
- Open Battleships_Game.sln in SeaBattle_backend folder using MS Visual Studio
- Start debugging
- Send requests to http://localhost:6811 by means of Postman or alike software
Frontend part was designed using JS language and React library. Frontend part consists of React components which creates the logic of application, Assets like images of ships, signs of hits or misses and CSS file which helps to make UI adaptive and responsive and gives ability to use application on different devices.
How to test frontend part?
If you want to test frontend part you can visit hosted application here: https://seabattleakvelon.herokuapp.com or run application locally in development environment. To do that:
- Run backend part locally according to instruction above;
- Install a recent version of Node.JS: https://nodejs.org/en/
- Using console and command
cd
, go to SeaBattle_frontend folder and executenpm install
, to install node_modules; - Execute
npm start
; - Go to http://localhost:3000