diff --git a/api/src/main/java/lab/en2b/quizapi/game/GameService.java b/api/src/main/java/lab/en2b/quizapi/game/GameService.java index 36e10efd..5491fb04 100644 --- a/api/src/main/java/lab/en2b/quizapi/game/GameService.java +++ b/api/src/main/java/lab/en2b/quizapi/game/GameService.java @@ -71,7 +71,11 @@ public GameResponseDto startRound(Long id, Authentication authentication) { private Question generateQuestionForGame(Game game){ Optional question = questionService.findRandomQuestion(game.getLanguage(),game.getQuestionCategoriesForGamemode()); if(question.isPresent()){ - return question.get(); + Question q = question.get(); + if (game.getQuestions().contains(q)){ + return generateQuestionForGame(game); + } + return q; } else { game.setGameOver(true); gameRepository.save(game);