Modification BDD stockage défi actif

This commit is contained in:
2024-12-12 21:03:42 +01:00
parent db8a8b4b7b
commit 9d0b5cb254
9 changed files with 78 additions and 61 deletions

View File

@ -58,17 +58,17 @@ export class GameService {
throw new ConflictException("La partie n'a pas encore démarré.")
// Clôture de l'éventuel défi en cours, qui n'a alors pas été réussi
await this.prisma.challengeAction.updateMany({
where: {
playerId: game.currentRun.runnerId,
runId: game.currentRunId,
active: true,
},
data: {
active: false,
success: false,
},
})
const currentRunner = await this.prisma.player.findUnique({ where: { id: game.currentRun.runnerId } })
if (currentRunner.activeChallengeId) {
await this.prisma.challengeAction.update({
where: { id: currentRunner.activeChallengeId },
data: { success: false },
})
await this.prisma.player.update({
where: { id: currentRunner.id },
data: { activeChallengeId: null },
})
}
await this.prisma.playerRun.update({
where: { id: game.currentRunId },
@ -173,7 +173,7 @@ export class GameService {
const orpanChallengeMoneyUpdates = await this.prisma.moneyUpdate.findMany({ where: { reason: MoneyUpdateType.WIN_CHALLENGE, actionId: null } })
await this.prisma.moneyUpdate.deleteMany({ where: { reason: MoneyUpdateType.WIN_CHALLENGE, actionId: null } })
deleted.push(...orpanTrainMoneyUpdates)
deleted.push(...orpanChallengeMoneyUpdates)
return { added: added, deleted: deleted }
}