-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from SBD1/feat/bd
Feat/bd
- Loading branch information
Showing
53 changed files
with
4,823 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
build: | ||
docker-compose -f game/docker-compose.yml up -d | ||
stop: | ||
docker-compose -f game/docker-compose.yml stop | ||
down: | ||
docker-compose -f game/docker-compose.yml down | ||
start: | ||
docker-compose -f game/docker-compose.yml start | ||
restart: | ||
docker-compose -f game/docker-compose.yml stop | ||
docker-compose -f game/docker-compose.yml up -d | ||
prune: | ||
docker system prune && docker volume prune | ||
clean: | ||
docker-compose -f game/docker-compose.yml stop | ||
docker system prune -a --volumes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use the official Node.js image as the base image | ||
FROM node:14-alpine | ||
|
||
# Set the working directory in the container | ||
WORKDIR /usr/src/app | ||
|
||
# Copy package.json and package-lock.json to the working directory | ||
COPY package*.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy the application code to the container | ||
COPY . . | ||
|
||
# Expose the port on which the application will run | ||
EXPOSE 3333 | ||
|
||
# Command to run the application | ||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// import express from 'express'; | ||
// import { getItems } from "./Services/firstServicesDB.js" | ||
// import pkg from 'pg'; | ||
// const { Pool } = pkg; | ||
|
||
// const app = express(); | ||
// const port = 3000; | ||
|
||
// app.get('/', async (req, res) => { | ||
// try { | ||
// const result = await getItems(); | ||
// res.json(result); | ||
// } catch (error) { | ||
// console.error('Error executing query', error); | ||
// res.status(500).send('Internal Server Error'); | ||
// } | ||
// }); | ||
|
||
// app.listen(port, () => { | ||
// console.log(`Server is running on http://localhost:${port}`); | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "backend", | ||
"version": "1.0.0", | ||
"description": "", | ||
"type": "module", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "nodemon src/server.js" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"axios": "^1.6.2", | ||
"cors": "^2.8.5", | ||
"express": "^4.18.2", | ||
"pg": "^8.11.3" | ||
}, | ||
"devDependencies": { | ||
"nodemon": "^3.0.1", | ||
"sucrase": "^3.34.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM postgres:alpine | ||
|
||
ADD /postgres/migrations/1_schema.sql /docker-entrypoint-initdb.d | ||
ADD /postgres/migrations/2_data.sql /docker-entrypoint-initdb.d | ||
|
||
RUN chmod a+r /docker-entrypoint-initdb.d/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
-- Tabela Local | ||
CREATE TABLE Local ( | ||
idLocal SERIAL PRIMARY KEY | ||
); | ||
|
||
-- Tabela Personagem | ||
CREATE TABLE Personagem ( | ||
idPersonagem SERIAL PRIMARY KEY, | ||
alma INT DEFAULT 0, | ||
local INT UNIQUE, | ||
tipoP INT NOT NULL | ||
); | ||
|
||
-- Tabela Inventario | ||
CREATE TABLE Inventario ( | ||
idInventario SERIAL PRIMARY KEY, | ||
idPersonagem INT REFERENCES Personagem (idPersonagem) | ||
); | ||
|
||
-- Tabela Lojista | ||
CREATE TABLE Lojista ( | ||
idLojista SERIAL PRIMARY KEY, | ||
idInventario INT REFERENCES Inventario (idInventario), | ||
agilidade INT DEFAULT 0, | ||
defesaMagica INT DEFAULT 0, | ||
defesa INT DEFAULT 0, | ||
ataque INT DEFAULT 0, | ||
nome VARCHAR(255) NOT NULL | ||
); | ||
|
||
-- Tabela Item | ||
CREATE TABLE Item ( | ||
idItem SERIAL PRIMARY KEY, | ||
tipo VARCHAR(255) NOT NULL, | ||
idInventario INT REFERENCES Inventario (idInventario), | ||
lojista INT REFERENCES Lojista (idLojista) | ||
); | ||
|
||
-- Tabela Loot | ||
CREATE TABLE Loot ( | ||
local INT REFERENCES Local (idLocal), | ||
item INT REFERENCES Item (idItem) | ||
); | ||
|
||
-- Tabela Personagem Jogável | ||
CREATE TABLE PersonagemJogavel ( | ||
corpo INT NOT NULL, | ||
mente INT NOT NULL, | ||
defesa INT NOT NULL, | ||
agilidade INT NOT NULL, | ||
ataque INT NOT NULL, | ||
nome VARCHAR(255) NOT NULL, | ||
defesaMagica INT NOT NULL, | ||
idPersonagem INT PRIMARY KEY REFERENCES Personagem (idPersonagem), | ||
acessorio1 INT REFERENCES Item (idItem), | ||
acessorio2 INT REFERENCES Item (idItem), | ||
Arma INT REFERENCES Item (idItem), | ||
Armadura INT REFERENCES Item (idItem) | ||
); | ||
|
||
-- Tabela Alma | ||
CREATE TABLE Alma ( | ||
nome VARCHAR(255) PRIMARY KEY, | ||
personagem INT REFERENCES Personagem (idPersonagem) | ||
); | ||
|
||
-- Tabela Coletadas | ||
CREATE TABLE Coletadas ( | ||
personagem INT REFERENCES PersonagemJogavel (idPersonagem), | ||
alma VARCHAR(255) REFERENCES Alma (nome) | ||
); | ||
|
||
-- Tabela Habilidade | ||
CREATE TABLE Habilidade ( | ||
idHabilidade SERIAL PRIMARY KEY, | ||
custo INT NOT NULL, | ||
alma VARCHAR(255) REFERENCES Alma (nome) | ||
); | ||
|
||
-- Tabela Ataque | ||
CREATE TABLE Ataque ( | ||
idAtaque SERIAL PRIMARY KEY, | ||
tipoAtaque INT NOT NULL, | ||
descricao VARCHAR(255) DEFAULT '', | ||
idHabilidade INT REFERENCES Habilidade (idHabilidade), | ||
danoFisico INT DEFAULT 0, | ||
danoMagico INT DEFAULT 0 | ||
); | ||
|
||
-- Tabela Armadura | ||
CREATE TABLE Armadura ( | ||
idItem INT PRIMARY KEY REFERENCES Item (idItem), | ||
defesa INT DEFAULT 0, | ||
defesaMagica INT DEFAULT 0, | ||
agilidade INT DEFAULT 0, | ||
descricao VARCHAR(255) DEFAULT '', | ||
valor INT DEFAULT 0, | ||
nome VARCHAR(255) NOT NULL | ||
); | ||
|
||
|
||
|
||
-- Tabela Estoque | ||
CREATE TABLE Estoque ( | ||
idLojista INT REFERENCES Lojista (idLojista), | ||
idItem INT REFERENCES Item (idItem) | ||
); | ||
|
||
-- Tabela Arma | ||
CREATE TABLE Arma ( | ||
idItem INT PRIMARY KEY REFERENCES Item (idItem), | ||
ataqueFisico INT DEFAULT 0, | ||
ataqueMagico INT DEFAULT 0, | ||
descricao VARCHAR(255) DEFAULT '', | ||
valor INT DEFAULT 0, | ||
nome VARCHAR(255) NOT NULL | ||
); | ||
|
||
-- Tabela Acessorio | ||
CREATE TABLE Acessorio ( | ||
idItem INT PRIMARY KEY REFERENCES Item (idItem), | ||
defesa INT DEFAULT 0, | ||
defesaMagica INT DEFAULT 0, | ||
agilidade INT DEFAULT 0, | ||
ataqueFisico INT DEFAULT 0, | ||
ataqueMagico INT DEFAULT 0, | ||
descricao VARCHAR(255) DEFAULT '', | ||
valor INT DEFAULT 0, | ||
nome VARCHAR(255) NOT NULL | ||
); | ||
|
||
-- Tabela Personagem Não Jogável | ||
CREATE TABLE PNJ ( | ||
idPersonagem INT PRIMARY KEY REFERENCES Personagem (idPersonagem), | ||
tipoPnj INT NOT NULL | ||
); | ||
|
||
-- Tabela Inimigo | ||
CREATE TABLE Inimigo ( | ||
idPersonagem SERIAL PRIMARY KEY, | ||
defesa INT DEFAULT 0, | ||
agilidade INT DEFAULT 0, | ||
ataque INT DEFAULT 0, | ||
nome VARCHAR(255) NOT NULL, | ||
defesaMagica INT DEFAULT 0 | ||
); | ||
|
||
-- Tabela Legivel | ||
CREATE TABLE Legivel ( | ||
idItem INT PRIMARY KEY, | ||
conteudo VARCHAR(255) DEFAULT '', | ||
valor INT DEFAULT 0, | ||
descricao VARCHAR(255) DEFAULT '', | ||
nome VARCHAR(255) NOT NULL | ||
); | ||
|
||
-- Tabela Consumivel | ||
CREATE TABLE Consumivel ( | ||
idItem INT PRIMARY KEY, | ||
adHp INT NOT NULL, | ||
adMente INT NOT NULL, | ||
descricao VARCHAR(255) DEFAULT '', | ||
valor INT DEFAULT 0, | ||
nome VARCHAR(255) NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
INSERT INTO Personagem(alma, local, tipoP) VALUES (1, 1002, 2); | ||
|
||
INSERT INTO Personagem(alma, local, tipoP) VALUES (2, 1003, 2); | ||
|
||
INSERT INTO Personagem(alma, local, tipoP) VALUES (3, 1004, 2); | ||
|
||
INSERT INTO Personagem(alma, local, tipoP) VALUES (4, 1005, 2); | ||
|
||
-- Entidade Personagem Não Jogável: | ||
|
||
INSERT INTO PNJ (idPersonagem, tipoPnj) VALUES (1, 1); | ||
|
||
INSERT INTO PNJ (idPersonagem, tipoPnj) VALUES (2, 2); | ||
|
||
INSERT INTO PNJ (idPersonagem, tipoPnj) VALUES (3, 3); | ||
|
||
|
||
INSERT INTO PersonagemJogavel | ||
(corpo, mente, defesa, agilidade, ataque, nome, defesaMagica, idPersonagem, acessorio1, acessorio2, Arma, Armadura) | ||
VALUES | ||
(1, 1, 1, 1, 1, 'Nome do Personagem', 1, 4, NULL, NULL, NULL, NULL); | ||
|
||
-- Entidade Inventário | ||
|
||
INSERT INTO Inventario(idPersonagem) VALUES (1); | ||
|
||
INSERT INTO Inventario(idPersonagem) VALUES (2); | ||
|
||
INSERT INTO Inventario(idPersonagem) VALUES (3); | ||
|
||
-- Entidade Lojista: | ||
|
||
INSERT INTO Lojista(idInventario, agilidade, defesaMagica, defesa, ataque, nome) VALUES (1, 10, 5, 20, 15, 'Sinistro'); | ||
|
||
-- Entidade Inimigo: | ||
|
||
INSERT INTO Inimigo(idPersonagem, defesa, ataque, nome, defesaMagica, agilidade) | ||
VALUES (1, 15, 25, 'Ghoul', 11, 0); | ||
|
||
INSERT INTO Inimigo(idPersonagem, defesa, ataque, nome, defesaMagica, agilidade) | ||
VALUES (2, 10, 10, 'Chamuscado', 11, 0); | ||
|
||
INSERT INTO Inimigo(idPersonagem, defesa, ataque, nome, defesaMagica, agilidade) | ||
VALUES (3, 20, 35, 'Padre Decrépto', 11, 0); | ||
|
||
INSERT INTO Inimigo(idPersonagem, defesa, ataque, nome, defesaMagica, agilidade) | ||
VALUES (4, 25, 40, 'Zelador', 14, 0); | ||
|
||
INSERT INTO Inimigo(idPersonagem, defesa, ataque, nome, defesaMagica, agilidade) | ||
VALUES (5, 20, 35, 'Cão', 11, 0); | ||
|
||
INSERT INTO Inimigo(idPersonagem, defesa, ataque, nome, defesaMagica, agilidade) | ||
VALUES (6, 40, 45, 'Palhaço', 15, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import getDBConnection from "./getDBConnection.js" | ||
|
||
export const getItemInimigo = async () => { | ||
const query = 'SELECT * FROM Inimigo' | ||
return await getDBConnection(query); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import getDBConnection from "./getDBConnection.js" | ||
|
||
export const getItemInventario = async () => { | ||
const query = 'SELECT * FROM Inventario' | ||
return await getDBConnection(query); | ||
} | ||
|
||
|
||
|
Oops, something went wrong.