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 = {