changements pour l'env (encore) + corrections de quelques bugs dans game_server
This commit is contained in:
@@ -2,46 +2,8 @@ FROM node:alpine AS development
|
||||
|
||||
WORKDIR /usr/app
|
||||
|
||||
ARG NODE_ENV
|
||||
ARG WEBSITE_HOST
|
||||
ARG WEBSITE_PORT
|
||||
ARG POSTGRES_USER
|
||||
ARG POSTGRES_PASSWORD
|
||||
ARG POSTGRES_DB
|
||||
ARG POSTGRES_HOST
|
||||
ARG POSTGRES_PORT
|
||||
|
||||
COPY ./api_back ./
|
||||
COPY ./api_back/src/uploads/avatars/default.png ./uploads/avatars/default.png
|
||||
COPY ./api_back/.env ./.env
|
||||
#RUN sed -i "s/\$NODE_ENV/${NODE_ENV}/g" ./.env && \
|
||||
# sed -i "s/\$WEBSITE_HOST/${WEBSITE_HOST}/g" ./.env && \
|
||||
# sed -i "s/\$WEBSITE_PORT/${WEBSITE_PORT}/g" ./.env && \
|
||||
# sed -i "s/\$POSTGRES_USER/${POSTGRES_USER}/g" ./.env && \
|
||||
# sed -i "s/\$POSTGRES_PASSWORD/${POSTGRES_PASSWORD}/g" ./.env && \
|
||||
# sed -i "s/\$POSTGRES_DB/${POSTGRES_DB}/g" ./.env && \
|
||||
# sed -i "s/\$POSTGRES_HOST/${POSTGRES_HOST}/g" ./.env && \
|
||||
# sed -i "s/\$POSTGRES_PORT/${POSTGRES_PORT}/g" ./.env
|
||||
|
||||
RUN sed -i "s/\$NODE_ENV/${NODE_ENV}/g" ./.env
|
||||
RUN sed -i "s/\$WEBSITE_HOST/${WEBSITE_HOST}/g" ./.env
|
||||
RUN sed -i "s/\$WEBSITE_PORT/${WEBSITE_PORT}/g" ./.env
|
||||
RUN sed -i "s/\$POSTGRES_USER/${POSTGRES_USER}/g" ./.env
|
||||
|
||||
RUN echo ["$POSTGRESS_PASSWORD"] && \
|
||||
echo ["$POSTGRESS_PASSWORD"] && \
|
||||
echo ["$POSTGRESS_PASSWORD"] && \
|
||||
echo ["$POSTGRESS_PASSWORD"] && \
|
||||
echo ["$POSTGRESS_PASSWORD"] && \
|
||||
echo ["$POSTGRESS_PASSWORD"] && \
|
||||
echo ["$POSTGRESS_PASSWORD"] && \
|
||||
sed -i "s/\$POSTGRES_PASSWORD/'${POSTGRESS_PASSWORD}'/g" ./.env
|
||||
|
||||
RUN sed -i "s/\$POSTGRES_DB/${POSTGRES_DB}/g" ./.env
|
||||
RUN sed -i "s/\$POSTGRES_HOST/${POSTGRES_HOST}/g" ./.env
|
||||
RUN sed -i "s/\$POSTGRES_PORT/${POSTGRES_PORT}/g" ./.env
|
||||
|
||||
RUN npm install
|
||||
RUN npm ci
|
||||
|
||||
CMD [ "npm", "run", "start:dev" ]
|
||||
|
||||
@@ -17,6 +17,9 @@ export class Game {
|
||||
@Column({default : 0, nullable : true})
|
||||
playerTwoUsernameResult : number
|
||||
|
||||
@Column({default : 0})
|
||||
gameOptions: number
|
||||
|
||||
@Column({unique : true})
|
||||
gameServerIdOfTheMatch: string
|
||||
|
||||
|
||||
@@ -13,6 +13,14 @@ export class GameController {
|
||||
constructor (private readonly gameService : GameService) { }
|
||||
|
||||
|
||||
@Get('match/all')
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
async getMatchesForSpectator()
|
||||
{
|
||||
return this.gameService.getMatchesForSpectator();
|
||||
}
|
||||
|
||||
@Get('ranking')
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
|
||||
@@ -28,6 +28,21 @@ export class GameService {
|
||||
private readonly friendShipService : FriendshipService
|
||||
) { }
|
||||
|
||||
async getMatchesForSpectator() {
|
||||
const games = await this.gameRepository.createQueryBuilder("game")
|
||||
.where('game.isMatchIsFinished = :isMatchIsFinished', {isMatchIsFinished : false})
|
||||
.getMany();
|
||||
const gamesToReturn : Partial<Game>[] = []
|
||||
for (const game of games)
|
||||
{
|
||||
gamesToReturn.push({gameServerIdOfTheMatch : game.gameServerIdOfTheMatch,
|
||||
gameOptions : game.gameOptions, playerOneUsername : game.playerOneUsername,
|
||||
playerTwoUsername : game.playerTwoUsername})
|
||||
console.log("Is match is finished : " + game.isMatchIsFinished)
|
||||
}
|
||||
return gamesToReturn;
|
||||
}
|
||||
|
||||
async getRankingForAllUsers(currentUser : User) {
|
||||
const users = await this.userRepository.createQueryBuilder("user")
|
||||
.leftJoinAndSelect("user.stats", "stats")
|
||||
@@ -255,6 +270,8 @@ export class GameService {
|
||||
game.playerOneUsernameResult = updateGameDto.playerOneUsernameResult
|
||||
game.playerTwoUsernameResult = updateGameDto.playerTwoUsernameResult
|
||||
this.gameRepository.save(game);
|
||||
console.log("On a sauvegardé la partie. Game :")
|
||||
console.log(game)
|
||||
const playerOne = await this.userRepository.findOneBy({username : game.playerOneUsername})
|
||||
const playerTwo = await this.userRepository.findOneBy({username : game.playerTwoUsername})
|
||||
if (!playerOne || !playerTwo)
|
||||
|
||||
Reference in New Issue
Block a user