Skip to content

Joaodss/Graveyard-Builder-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graveyard Builder Game

The final project for Ironhack Web Dev Bootcamp.

Summary

Table Of Contents

About The Project

This project was created as the final project for the Ironhack Web Dev Bootcamp. It's a web application game based on one of my first java group projects and inspired by games like pokemon and RPG games with some roguelike elements.

The project is divided into multiple microservices and a client application:

Project Requirements

Your project must meet all of the requirements below:

  • Include a microservices Java/Spring Boot backend and an Angular frontend.
  • Include at least 2 SQL database tables.
  • Include at least 4 services plus at least 1 edge service.
  • Include at least 1 GET, POST, PUT/PATCH, and DELETE route.
  • Include adequate and complete documentation.

The game

Graveyard Builder Game consists of a single-player browser game. The players must build their party of warriors, archers, and mages, defeat other players, gain gold, and level up. Each character type has its unique stats and abilities. When characters die, they will be moved to the graveyard. To add them back to the party, the player must revive them with gold.

The game is temporarily available at http://graveyardbuildergame.site

Features

  • 3 classes of characters: Warrior, Archer, Mage
  • Automatic opponent generation
  • Random option on character creation
  • Customizable characters and user pictures
  • Battle other players' teams
  • Help page
  • Mobile-friendly interface
  • JWT authentication

Built With

Technologies used in this project:

Getting Started

The project contains separate microservices for the backend and a client frontend part. To locally run the web application all parts must be operational.

Setup - Frontend Application

Setup - Backend Microservices

CREATE DATABASE GraveyardBuilder;

CREATE USER 'ironhacker'@'localhost' IDENTIFIED BY '1r0n-H4ck3r';
GRANT ALL PRIVILEGES ON GraveyardBuilder.* TO 'ironhacker'@'localhost';
FLUSH PRIVILEGES;
  • Run the following command to start each spring application: mvn spring-boot:run, or by using an IDE like IntelliJ IDEA
  • The application will be available by using the gateway service at http://localhost:8000/

Frontend Application

Home page Home page mobile
Main page Main page mobile
Menu page Menu page mobile
Menu page Menu page mobile
Party page Party page mobile grid Party page mobile details
Party page Party page mobile1 Party page mobile1
Graveyard page Graveyard page mobile
Main page Main page mobile
Battle selection page Battle selection page mobile
Main page Main page mobile
Battle page Battle page mobile
Main page Main page mobile

Backend API

Security

There is an admin pre-generated profile that can be used for managing the users and fixing possible user problems.

Admin:

username: admin;
password: ironhack - admin;

This project implements a JWT authentication mechanism. The JWT is generated by the backend and sent to the frontend. The frontend uses the JWT to authenticate the user and retrieve information.

To authenticate the user/admin manually (with Postman or another tool) you must follow these steps:

  • To log in with the pretended profile send a post request to the login page: http://localhost:8000/login;

  • In the body of the request add the x-www-form-urlencoded format and add the following values:

    key value
    username <username here>
    password <password here>
  • The response will contain a JWT token and an expiration date.

  • To access the protected routes you must add the JWT token to the Authorization header of the request with the following format:

    key value
    Authorization Bearer <token here>

Routes

All routes available are managed by the Gateway Service on port 8000. For more information on the specific microservices routes, please refer to the documentation of the microservice.

Public Access

SignIn service:

Route Type Route Description
POST /api/v1/signIn/validate/username Registers a new user, returns UserDTO. Requires body: RegisterUserDTO
POST /api/v1/signIn/validate/email Checks if username is valid (does not exist), returns boolean. Requires body: UsernameDTO
POST /api/v1/signIn/register Checks if email is valid (does not exist), returns boolean. Requires body: EmailDTO

Auth service:

Route Type Route Description
POST /login User login. Check Security for more information.

Registered User Access

Profile service:

Route Type Route Description
GET /api/v1/profiles/user Returns UserDTO of authenticated user.
GET /api/v1/profiles/experience Returns ExperienceDTO of authenticated user.
GET /api/v1/profiles/gold Returns GoldDTO of authenticated user.
POST /api/v1/profiles/update/all Updates user information of authenticated user, returns UserDTO. Requires body: UserDTO.
POST /api/v1/profiles/update/password Updates user password of authenticated user. Requires body: PasswordChangeDTO.

Party Manager service:

Route Type Route Description
GET /api/v1/party-manager/party Returns party (CharacterDTO[]) of authenticated user.
GET /api/v1/party-manager/graveyard Returns graveyard (CharacterDTO[]) of authenticated user.
GET /api/v1/party-manager/id/{{id}} Returns CharacterDTO of authenticated user by character id. Requires id: long.
POST /api/v1/party-manager/create Creates new character for authenticated user, returns CharacterDTO. Requires body: NewCharacterDTO.
PUT /api/v1/party-manager/level-up Levels up a character, returns CharacterDTO. Requires body: LevelUpDTO.
PUT /api/v1/party-manager/heal/{{id}} Heals a character of authenticated user by character id, returns CharacterDTO. Requires id: long. Request parameters: healAmount: int.
PUT /api/v1/party-manager/revive/{{id}} Revives a character of authenticated user by character id, returns CharacterDTO. Requires id: long.
DELETE /api/v1/party-manager/delete/{{id}} Deletes a character of authenticated user by character id. Requires id: long.

Battle service:

Route Type Route Description
GET /api/v1/battle/opponents Retrieves an opponent team to battle, returns OpponentDTO.
PUT /api/v1/battle/updateHealth/{{id}} Update character health by id, returns CharacterDTO. Requires id: long. Request parameters: health: int.
PUT /api/v1/battle/addExperience/{{id}} Add experience to character by id, returns CharacterDTO. Requires id: long. Request parameters: experience: long.
PUT /api/v1/battle/addUserExperienceAndGold Add experience and gold to the authenticated user, returns UserDTO. Request parameters: experience(optional): long, gold(optional): long.

Admin Access

User Model service:

Route Type Route Description
GET /api/v1/users/all Returns all users' details UserDTO.
GET /api/v1/users/id/{{id}} Returns UserDTO by id. Requires id: long.
GET /api/v1/users/auth/{{username}} Returns UserAuthDTO by username. Requires username: string.
GET /api/v1/users/username/{{username}} Returns UserDTO by username. Requires username: string.
GET /api/v1/users/email/{{email}} Returns UserDTO by email. Requires email: string.
GET /api/v1/users/partyLevel Returns list of usernames between min and max party level. Request parameters: min(optional): int, max(optional): int.
POST /api/v1/users/register Registers new user, returns UserDTO. Requires body: RegisterUserDTO.
PUT /api/v1/users/update/{{username}} Updates user information by username, returns UserDTO. Requires username: string. Requires body: UserDTO.
PUT /api/v1/users/update/{{username}}/password Updates user password by username. Requires username: string. Requires body: NewPasswordDTO .
DELETE /api/v1/users/delete/{{username}} Deletes user by username. Requires username: string.

Character Model service:

Route Type Route Description
GET /api/v1/characters/all Return all characters (CharacterDTO[]).
GET /api/v1/characters/id/{{id}} Return character by id. Requires id: long.
GET /api/v1/characters/party/{{username}} Return party (CharacterDTO[]) by user username. Requires username: string.
GET /api/v1/characters/graveyard/{{username}} Return graveyard (CharacterDTO[]) by user username. Requires username: string.
POST /api/v1/characters/create Creates new character, returns CharacterDTO. Requires body: NewCharacterDTO.
PUT /api/v1/characters/update Updates a character information, returns CharacterDTO. Requires body: CharacterDTO.
PUT /api/v1/characters/update/levelUp Levels up a character, returns CharacterDTO. Requires body: LevelUpDTO.
DELETE /api/v1/characters/delete/{{id}} Deletes a character by id. Requires id: long.

Opponent Selection service:

Route Type Route Description
GET /api/v1/opponent/random/{level} Retrieves an opponent team of a given level, returns CharacterDTO[]. Request parameters: partyLevel: int.

Payloads

RegisterUserDTO

{
  "username": string,
  "email": string,
  "password": string
}

UsernameDTO

{
  "username": string,
}

EmailDTO

{
  "email": string,
}

UserDTO

{
  "username": string,
  "email": string,
  "roles": string[],
  "profilePictureUrl": string,
  "experience": long,
  "gold": long,
  "partyLevel": int
}

UserAuthDTO

{
  "username": string,
  "password": string,
  "roles": string[]
}

ExperienceDTO

{
  "experience": long,
}

GoldDTO

{
  "gold": long,
}

PasswordChangeDTO

{
  "oldPassword": string,
  "newPassword": string
}

NewPasswordDTO

{
  "newPassword": string
}

NewCharacterDTO

{
  "userUsername": string,
  "type": string,
  "name": string,
  "pictureURL": string
}

CharacterDTO

{
  "id": long,
  "userUsername": string,
  "type": string,
  "isAlive": boolean,
  "deathTime": string,
  "name": string,
  "pictureURL": string,
  "level": int,
  "experience": long,
  "maxHealth": int,
  "currentHealth": int,
  "passiveChance": double,
  "maxStamina": int,
  "currentStamina": int,
  "strength": int,
  "accuracy": int,
  "maxMana": int,
  "currentMana": int,
  "intelligence": int
}

LevelUpDTO

{
  "id": long,
  "healthPoints": int,
  "energyPoints": int,
  "attackPoints": int
}

OpponentDTO

{
  "username": string,
  "profilePictureUrl": string,
  "opponents": CharacterDTO[]
}

Project Diagrams

UML Class Diagram

UML Microservices Diagram

Microservices Endpoints

Road Map

  • Complete backend testing;
  • Refactor JWT security in microservices;
  • Optimize opponent AI actions;
  • Animate battle;
  • Enhance design;
  • Deploy to AWS;
  • Add Facebook login and friends integration;
  • Online P2P battles

Contacts

About

Final project for Ironhack Web Dev Bootcamp.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published