diff --git a/server/src/app.module.ts b/server/src/app.module.ts index 99923db..5cee3ed 100644 --- a/server/src/app.module.ts +++ b/server/src/app.module.ts @@ -9,9 +9,10 @@ import { ChallengeActionsModule } from './challenge-actions/challenge-actions.mo import { TrainsModule } from './trains/trains.module' import { MoneyUpdatesModule } from './money-updates/money-updates.module' import { GameModule } from './game/game.module' +import { RunsModule } from './runs/runs.module' @Module({ - imports: [PrismaModule, AuthModule, PlayersModule, GameModule, GeolocationsModule, ChallengesModule, ChallengeActionsModule, TrainsModule, MoneyUpdatesModule], + imports: [PrismaModule, AuthModule, PlayersModule, GameModule, RunsModule, GeolocationsModule, ChallengesModule, ChallengeActionsModule, TrainsModule, MoneyUpdatesModule], providers: [PrismaService], }) export class AppModule {} diff --git a/server/src/challenge-actions/challenge-actions.service.ts b/server/src/challenge-actions/challenge-actions.service.ts index fa49230..c5db157 100644 --- a/server/src/challenge-actions/challenge-actions.service.ts +++ b/server/src/challenge-actions/challenge-actions.service.ts @@ -87,7 +87,7 @@ export class ChallengeActionsService { active: false, end: now, penaltyStart: now, - penaltyEnd: new Date(now.getTime() + 45 * 60 * 1000), + penaltyEnd: new Date(now.getTime() + 30 * 60 * 1000), } } return await this.prisma.challengeAction.update({ diff --git a/server/src/game/game.service.ts b/server/src/game/game.service.ts index 45b8ddc..e83330e 100644 --- a/server/src/game/game.service.ts +++ b/server/src/game/game.service.ts @@ -37,7 +37,10 @@ export class GameService { }) } else { - run = game.currentRun + run = await this.prisma.playerRun.update({ + where: { id: game.currentRunId }, + data: { end: null }, + }) } return await this.prisma.game.update({ where: { id: 1 }, @@ -66,6 +69,11 @@ export class GameService { }, }) + await this.prisma.playerRun.update({ + where: { id: game.currentRunId }, + data: { end: new Date() }, + }) + const newRunnerId = game.currentRun.runnerId == 1 ? 2 : 1 const firstRun = await this.prisma.playerRun.findFirst({ where: { runnerId: newRunnerId } }) !== null const newRun = await this.prisma.playerRun.create({ @@ -95,11 +103,13 @@ export class GameService { const game = await this.find() if (!game.started) throw new ConflictException("La partie n'a pas encore démarré.") + await this.prisma.playerRun.update({ + where: { id: game.currentRunId }, + data: { end: new Date() }, + }) return await this.prisma.game.update({ where: { id: 1 }, - data: { - started: false, - }, + data: { started: false }, }) }