From a1b5fccc986dd44523d14b40f4a2ab9aa3de568e Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sun, 8 Dec 2024 19:31:54 +0100 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9dit=20automatique=20de=20points=20lorsq?= =?UTF-8?q?u'un=20d=C3=A9fi=20a=20=C3=A9t=C3=A9=20r=C3=A9ussi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../challenge-actions.service.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/server/src/challenge-actions/challenge-actions.service.ts b/server/src/challenge-actions/challenge-actions.service.ts index fecceb7..04b032d 100644 --- a/server/src/challenge-actions/challenge-actions.service.ts +++ b/server/src/challenge-actions/challenge-actions.service.ts @@ -1,7 +1,7 @@ -import { BadRequestException, Injectable, NotFoundException, UnprocessableEntityException } from '@nestjs/common' +import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common' import { CreateChallengeActionDto } from './dto/create-challenge-action.dto' import { UpdateChallengeActionDto } from './dto/update-challenge-action.dto' -import { ChallengeAction, Player } from '@prisma/client' +import { ChallengeAction, MoneyUpdateType, Player } from '@prisma/client' import { PrismaService } from 'src/prisma/prisma.service' import { QueryPaginationDto } from 'src/common/dto/pagination-query.dto' import { paginate } from 'src/common/utils/pagination.utils' @@ -68,6 +68,17 @@ export class ChallengeActionsService { active: false, end: now, } + + // Crédit du nombre de points remportés grâce au défi + const challenge = await this.prisma.challenge.findUnique({ where: { id: challengeAction.challengeId } }) + await this.prisma.moneyUpdate.create({ + data: { + playerId: player.id, + amount: challenge.reward, + reason: MoneyUpdateType.WIN_CHALLENGE, + actionId: challengeAction.id, + } + }) } else { data = {