Gestion des heures de fin des tentatives
This commit is contained in:
parent
50a9f3369c
commit
33689d9c76
@ -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 {}
|
||||
|
@ -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({
|
||||
|
@ -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 },
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user