Dope Ranking

This commit is contained in:
batche
2022-12-22 17:23:22 +01:00
parent 1e1a32bb78
commit 61831da347
4 changed files with 15 additions and 15 deletions

View File

@@ -233,7 +233,7 @@ export class GameSession {
});
const gc = this.components;
await fetch(c.addressBackEnd + "/game/matchEnd",
await fetch(c.addressBackEnd + "/game/gameserver/updategame",
{
method: "POST",
headers: {

View File

@@ -1,4 +1,4 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { ConsoleLogger, HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { createCipheriv, randomBytes, scrypt } from 'crypto';
import { User } from 'src/users/entities/user.entity';
@@ -31,14 +31,13 @@ export class GameService {
.leftJoinAndSelect("user.stats", "stats")
.orderBy('stats.winGame', "DESC")
.getMany();
if (!users)
return new HttpException("No ranking for now.", HttpStatus.NOT_FOUND)
const partialUser : Partial<User>[] = []
for (const user of users)
{
if (await this.friendShipService.findIfUserIsBlockedOrHasBlocked(currentUser.id.toString(), user.id.toString()) === false)
partialUser.push({username : user.username, stats : user.stats })
}
console.log(...partialUser)
return partialUser;
}
@@ -58,9 +57,10 @@ export class GameService {
async generateToken(user : User, grantTicketDto : GrantTicketDto)
{
if (user.status === "In Game" || user.status === "In Pool")
return new HttpException("You can't play two games", HttpStatus.FORBIDDEN);
else if (grantTicketDto.isGameIsWithInvitation === true)
console.log(user.status);
// if (user.status === "In Game" || user.status === "In Pool")
// return new HttpException("You can't play two games", HttpStatus.FORBIDDEN);
if (grantTicketDto.isGameIsWithInvitation === true)
{
const secondUser : Partial<User> = await this.userService.findOneByUsername(user.id.toString(), grantTicketDto.playerTwoUsername)
if (!secondUser || secondUser.username === user.username)
@@ -236,19 +236,19 @@ export class GameService {
if (!game)
return HttpStatus.INTERNAL_SERVER_ERROR
console.log("200 retourné pour la création de partie")
const playerOne = await this.userRepository.findOneBy({username : game.playerOneUsername})
const playerTwo = await this.userRepository.findOneBy({username : game.playerTwoUsername})
return HttpStatus.OK
}
async updateGame(updateGameDto : UpdateGameDto) {
const game = await this.gameRepository.preload(
{gameServerIdOfTheMatch : updateGameDto.gameServerIdOfTheMatch,
...updateGameDto}
)
console.log("Updata game" + updateGameDto)
const game = await this.gameRepository.createQueryBuilder('game')
.where("game.gameServerIdOfTheMatch = :gameServerIdOfTheMatch", {gameServerIdOfTheMatch : updateGameDto.gameServerIdOfTheMatch})
.getOne();
if (!game)
throw new HttpException(`The game could not be updated.`,HttpStatus.NOT_FOUND);
game.isMatchIsFinished = true;
game.playerOneUsernameResult = updateGameDto.playerOneUsernameResult
game.playerTwoUsernameResult = updateGameDto.playerTwoUsernameResult
this.userRepository.save(game);
const playerOne = await this.userRepository.findOneBy({username : game.playerOneUsername})
const playerTwo = await this.userRepository.findOneBy({username : game.playerTwoUsername})

View File

@@ -5,7 +5,7 @@
//user's stuff
let currentUser;
let allUsers;
let allUsers = [];
let idInterval;
onMount( async() => {
currentUser = await fetch('http://transcendance:8080/api/v2/user')

View File

@@ -6,7 +6,7 @@ import UnauthorizedAccessPage from '../pages/UnauthorizedAccessPage.svelte';
import { wrap } from 'svelte-spa-router/wrap'
import TestPage from '../pages/TmpTestPage.svelte';
import Game from '../pages/game/Game.svelte';
import Ranking from '../pages/Ranking.svelte';
import Ranking from '../pages/game/Ranking.svelte';
import SpectatorMatchList from '../pages/SpectatorMatchList.svelte';