Compare commits
	
		
			2 Commits
		
	
	
		
			4c157ff67f
			...
			23081e0220
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 23081e0220 | |||
| 3eea3a7409 | 
| @@ -94,7 +94,7 @@ export class ChallengesController { | ||||
|    *  | ||||
|    * @throws {401} Non authentifié⋅e | ||||
|    * @throws {404} Plus aucun défi n'est disponible | ||||
|    * @throws {409} Un défi est déjà en cours d'accomplissement | ||||
|    * @throws {409} Un défi est déjà en cours d'accomplissement, ou bien vous n'êtes pas en course | ||||
|    */ | ||||
|   @Post('/draw-random') | ||||
|   @UseGuards(JwtAuthGuard) | ||||
|   | ||||
| @@ -61,6 +61,9 @@ export class ChallengesService { | ||||
|   } | ||||
|  | ||||
|   async drawRandom(player: Player): Promise<ChallengeEntity> { | ||||
|     const game = await this.prisma.game.findUnique({ where: { id: 1 } }) | ||||
|     if (game.currentRunnerId != player.id) | ||||
|       throw new ConflictException("Vous n'êtes pas en course, ce n'est pas à vous de tirer un défi.") | ||||
|     const currentChallengeAction = await this.prisma.challengeAction.findFirst({ | ||||
|       where: { | ||||
|         playerId: player.id, | ||||
|   | ||||
| @@ -35,6 +35,18 @@ export class GameController { | ||||
|     return new GameEntity(await this.gameService.start()) | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Change de joueur⋅se en course après une capture | ||||
|    *  | ||||
|    * @throws {401} Non authentifié⋅e | ||||
|    */ | ||||
|   @Post('/switch-running-player') | ||||
|   @UseGuards(JwtAuthGuard) | ||||
|   @ApiBearerAuth() | ||||
|   async switchRunningPlayer(): Promise<GameEntity> { | ||||
|     return new GameEntity(await this.gameService.switchRunningPlayer()) | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Arrêter le jeu | ||||
|    * @remarks Arrête le jeu (si déjà lancé), à n'utiliser qu'en fin de partie. | ||||
|   | ||||
| @@ -38,6 +38,22 @@ export class GameService { | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   async switchRunningPlayer(): Promise<Game> { | ||||
|     const game = await this.find() | ||||
|     const newRunnerId = game.currentRunnerId == 1 ? 2 : 1 | ||||
|     await this.prisma.moneyUpdate.create({ | ||||
|       data: { | ||||
|         playerId: newRunnerId, | ||||
|         amount: 300, | ||||
|         reason: MoneyUpdateType.START, | ||||
|       } | ||||
|     }) | ||||
|     return await this.prisma.game.update({ | ||||
|       where: { id: game.id }, | ||||
|       data: { currentRunnerId: newRunnerId }, | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   async stop(): Promise<Game> { | ||||
|     const game = await this.find() | ||||
|     if (!game.started) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user