Skip to content

Commit

Permalink
Merge pull request #42 from ElectroAAC/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
WalistonBelles authored May 29, 2022
2 parents 587a4ff + 4af46de commit 243a1f8
Show file tree
Hide file tree
Showing 115 changed files with 1,709 additions and 447 deletions.
3 changes: 2 additions & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ MYSQL_DB_NAME=YOUR_DATABASE_GAME

CACHE_VIEWS=false

SMTP_HOST=localhost # String. Example: localhost
SMTP_HOST='localhost' # String. Example: localhost
SMTP_PORT=YOUR_SMTP_PORT # Number. Example: 587
SMTP_USERNAME=<username> # String. Example: electro123
SMTP_PASSWORD=<password> # String. Example: electro123

SERVER_PATH=PATH_YOUR_PROJECT # String. Example: /home/electro/
CHARACTERS_PER_ACCOUNT=MAX_CHARACTERS_PER_ACCOUNT # Number. Example: CHARACTERS_PER_ACCOUNT=10
CHANGE_NAME=ALLOW_NAME_CHANGE # Boolean. Example: CHANGE_NAME=true
POINTS_TO_CHANGE_NAME=PRICE_TO_CHANGE_NAME # Number. Example: POINTS_TO_CHANGE_NAME=10
233 changes: 126 additions & 107 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# BACK-END

<h2> 🍸 Build Setup </h2>

```bash
Expand Down Expand Up @@ -27,162 +28,180 @@ $ npm run build
$ npm run start
```

## 🕵🏾‍♂️ Routes Authorization (Login/Logout)
## 🕵🏾‍♂️ Routes Authorization (Login/Logout)

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------- | :---------- |
| POST | /auth | Login |
| DELETE | /auth | Logout |

<br>

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------- | :------------------------------------ |
| POST | /auth | Login |
| DELETE | /auth | Logout |
## 🕵🏾‍♂️ Routes News

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :---------------------- | :---------- |
| GET | /news/list/:page/:limit | Get news |

<br>

## 🕵🏾‍♂️ Routes News
## 🕵🏾‍♂️ Routes Account

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :-------------------------------| :------------------------------------ |
| GET | /news/list/:page/:limit | Get news |
| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :----------------------------- | :------------------------------ |
| POST | /accounts/register | Register new account |
| POST | /accounts/forgot-password | Generate code and sent to email |
| GET | /accounts/forgot-password/:key | Validate Code |
| PUT | /accounts/forgot-password | Update Password |
| GET | /accounts/characters/:id | Get characters to account |
| POST | /accounts/create-character | Create new character |

<br>

## 🕵🏾‍♂️ Routes Account
## 🕵🏾‍♂️ Routes Players

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :-------------------------------| :------------------------------------ |
| POST | /accounts/register | Register new account |
| POST | /accounts/forgot-password | Generate code and sent to email |
| GET | /accounts/forgot-password/:key | Validate Code |
| PUT | /accounts/forgot-password | Update Password |
| GET | /accounts/characters/:id | Get characters to account |
| POST | /accounts/create-character | Create new character |
| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :----------------------- | :------------------------- |
| GET | /player/:name | Get Player Infos |
| GET | /player/:id/skills | Get Player Skills |
| POST | /player/:id/deaths | Get Player Last 10 Deaths |
| GET | /player/:id/items | Get Player Items equipment |
| GET | /player/:id/storage/:key | Get Player Storage |
| GET | /player/:id/storages | Get Player Storages |
| GET | /player/change-name | Status system |
| POST | /player/change-name | Change character name |
| POST | /player/delete | Delete character |

<br>

## 🕵🏾‍♂️ Routes Players
## 🕵🏾‍♂️ Routes Highscores

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------- | :------------------------------------ |
| GET | /player/:name | Get Player Infos |
| GET | /player/:id/skills | Get Player Skills |
| GET | /player/:id/storage/:key | Get Player Storage |
| POST | /player/:id/deaths | Get Player Last 10 Deaths |
| GET | /player/:id/items | Get Player Items equipment |
| GET | /player/change-name | Status system |
| POST | /player/change-name | Change character name |
| POST | /player/delete | Delete character |
| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :----------------------------- | :---------------- |
| GET | /highscores | Get Top 5 Players |
| POST | /highscores/:page/:limit/:type | Ranking Players |

<br>

## 🕵🏾‍♂️ Routes Highscores
## 🕵🏾‍♂️ Routes Online

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------------- | :------------------------------------ |
| GET | /highscores | Get Top 5 Players |
| POST | /highscores/:page/:limit/:type | Ranking Players |
| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------- | :----------------- |
| GET | /online | Get Players Online |

<br>

## 🕵🏾‍♂️ Routes Online
## 🕵🏾‍♂️ Routes Lastkills

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------- | :------------------------------------ |
| GET | /online | Get Players Online |
| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :---------------------- | :------------- |
| POST | /lastkills/:page/:limit | Get last kills |

<br>

## 🕵🏾‍♂️ Routes Lastkills
## 🕵🏾‍♂️ Routes Guilds

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :--------------------------- | :---------------------- |
| GET | /guilds/:page/:limit | Get all guilds |
| GET | /guild/view/:name | Get guild info |
| GET | /guild/players-without-guild | Get guild info |
| POST | /guild/create-guild | Create Guild |
| POST | /guild/invite | Invite character |
| POST | /guild/invites | Get all invites |
| POST | /guild/accept-invite | Accept invite character |
| POST | /guild/cancel-invite | Cancel invite character |
| POST | /guild/leave | Leave guild |
| POST | /guild/pass-leadership | Pass Leadership |
| POST | /guild/change-motd | Change Motd |
| POST | /guild/change-rank | Change Rank of Member |
| POST | /guild/change-description | Change Description |
| POST | /guild/delete | Delete Guild |

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------- | :------------------------------------ |
| POST | /lastkills/:page/:limit | Get last kills |
<br>

## 🕵🏾‍♂️ Routes Creatures

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :---------------------- | :---------------- |
| GET | /creatures/:page/:limit | Get All Creatures |
| GET | /creatures/xml | Loading Creatures |

<br>

## 🕵🏾‍♂️ Routes Guilds

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :----------------------------| :------------------------------------ |
| GET | /guilds/:page/:limit | Get all guilds |
| GET | /guild/view/:name | Get guild info |
| GET | /guild/players-without-guild | Get guild info |
| POST | /guild/create-guild | Create Guild |
| POST | /guild/invite | Invite character |
| POST | /guild/invites | Get all invites |
| POST | /guild/accept-invite | Accept invite character |
| POST | /guild/cancel-invite | Cancel invite character |
| POST | /guild/leave | Leave guild |
| POST | /guild/pass-leadership | Pass Leadership |
| POST | /guild/change-motd | Change Motd |
| POST | /guild/change-rank | Change Rank of Member |
| POST | /guild/change-description | Change Description |
| POST | /guild/delete | Delete Guild |
## 🕵🏾‍♂️ Routes Items

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :----------- | :------------ |
| GET | /items/xml | Loading Items |
| GET | /items/:type | Get Items |

<br>

## 🕵🏾‍♂️ Routes Shop
## 🕵🏾‍♂️ Routes Shop

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :-------------------------------| :------------------------------------ |
| GET | /shop/offers/:categorie | Get offers |
| GET | /shop/categories/:page/:limit | Get categories |
| POST | /shop/purchase | Purchase Items |
| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :---------------------------- | :------------- |
| GET | /shop/offers/:categorie | Get offers |
| GET | /shop/categories/:page/:limit | Get categories |
| POST | /shop/purchase | Purchase Items |

<br>

## 🕵🏾‍♂️ Routes Dashboard
## 🕵🏾‍♂️ Routes Dashboard

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------- | :-----------------------------------------|
| GET | /dashboard/accounts | Get Total Accounts |
| GET | /dashboard/players | Get Total PLayers |
| GET | /dashboard/guilds | Get Total Guilds |
| GET | /dashboard/premium-points | Get accounts with the most premium points |
| GET | /dashboard/vocation | Get all vocations by id |
| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------ | :---------------------------------------- |
| GET | /dashboard/accounts | Get Total Accounts |
| GET | /dashboard/players | Get Total PLayers |
| GET | /dashboard/guilds | Get Total Guilds |
| GET | /dashboard/premium-points | Get accounts with the most premium points |
| GET | /dashboard/vocation | Get all vocations by id |

<br>

## 🕵🏾‍♂️ Routes Dashboard - Accounts
## 🕵🏾‍♂️ Routes Dashboard - Accounts

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------- | :-----------------------------------------|
| GET | /dashboard/account/:name | Find account |
| POST | /dashboard/account | Update account |
| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :----------------------- | :------------- |
| GET | /dashboard/account/:name | Find account |
| POST | /dashboard/account | Update account |

<br>

## 🕵🏾‍♂️ Routes Dashboard - Characters
## 🕵🏾‍♂️ Routes Dashboard - Characters

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :-------------------------------| :-----------------------------------------|
| GET | /dashboard/character/:name | Find character |
| GET | /dashboard/character-skills/:id | Find character |
| POST | /dashboard/character | Update character |
| POST | /dashboard/character-skills | Update characterSkills |
| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------------ | :--------------------- |
| GET | /dashboard/character/:name | Find character |
| GET | /dashboard/character-skills/:id | Find character |
| POST | /dashboard/character | Update character |
| POST | /dashboard/character-skills | Update characterSkills |

<br>

## 🕵🏾‍♂️ Routes Dashboard - News
## 🕵🏾‍♂️ Routes Dashboard - News

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :-------------------------------| :------------------------------------ |
| GET | /news/listDashboard/:page/:limit| Get news to Dashboard |
| POST | /news/create | Create new post |
| GET | /news/find/:id | Find post |
| PATCH | /news/edit | Update post |
| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------------- | :-------------------- |
| GET | /news/listDashboard/:page/:limit | Get news to Dashboard |
| POST | /news/create | Create new post |
| GET | /news/find/:id | Find post |
| PATCH | /news/edit | Update post |

<br>

## 🕵🏾‍♂️ Routes Dashboard - Shop

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :-------------------------------| :------------------------------------ |
| GET | /shop/category/list | Get all categories |
| POST | /shop/category/create | Create new category |
| GET | /shop/category/find:id | Find category |
| PUT | /shop/category/update | Update category |
| DELETE | /shop/category/destroy/:id | Delete category |
| GET | /shop/item/list | Get all items |
| POST | /shop/item/create | Create new offer item |
| GET | /shop/item/find:id | Find offer item |
| PUT | /shop/item/update | Update offer item |
| DELETE | /shop/item/destroy/:id | Delete offer item |
## 🕵🏾‍♂️ Routes Dashboard - Shop

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------- | :-------------------- |
| GET | /shop/category/list | Get all categories |
| POST | /shop/category/create | Create new category |
| GET | /shop/category/find:id | Find category |
| PUT | /shop/category/update | Update category |
| DELETE | /shop/category/destroy/:id | Delete category |
| GET | /shop/item/list | Get all items |
| POST | /shop/item/create | Create new offer item |
| GET | /shop/item/find:id | Find offer item |
| PUT | /shop/item/update | Update offer item |
| DELETE | /shop/item/destroy/:id | Delete offer item |
62 changes: 62 additions & 0 deletions backend/app/Controllers/Creature/Main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import {
Creature,
CreatureRepository,
CreatureView
} from 'App/Services'

export default class PlayerSkillController {
public creature: Creature = new Creature();
public creatureRepository: CreatureRepository = new CreatureRepository();
public creatureView: CreatureView = new CreatureView();

public async loadXml(ctx: HttpContextContract) {
try {
await ctx.bouncer.with('DashboardPolicy').authorize('admin');

const creatures = await this.creature.loadMonstersXml();

if (creatures.errno) {
throw new Error('Error: Cannot load monsters.xml. File not found.')
}

for (let monster of creatures.monster) {
const result = await this.creature.loadCreatureXml(monster.file[0]);

const loots = result.monster.loot && result.monster.loot[0] && result.monster.loot[0].item ? result.monster.loot[0].item.map((item) => {
return {
id: item.id[0],
countmax: item.countmax[0],
chance: item.chance[0],
}
}) : "";

await this.creatureRepository.create({
hidden: 0,
name: result.monster.name[0],
mana: result.monster.manacost[0],
health: result.monster.health[0].max[0],
experience: result.monster.experience[0],
look_type: result.monster.look[0].type[0],
loot: JSON.stringify(loots)
})
}

return ctx.response.status(200).send({ data: 'Monsters table updated successfully.' });
} catch(err) {
console.log('Error loadCreatureXml: ', err);
return ctx.response.status(400).send({ message: 'An error occurred, check the api console.'})
}
}

public async show(ctx: HttpContextContract) {
try {
const creatures = await this.creatureView.getCreatures(ctx.request.param('page'), ctx.request.param('limit'));

return ctx.response.status(200).send({ status: 200, data: creatures });
} catch(err) {
console.log('Error getCreatures Query: ', err);
return ctx.response.status(400).send({ error: 'An error occurred, check the api console.'});
}
}
}
Loading

0 comments on commit 243a1f8

Please sign in to comment.