generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: moved game mode logic to utils
- Loading branch information
1 parent
5523540
commit 871dddd
Showing
2 changed files
with
62 additions
and
47 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package lab.en2b.quizapi.commons.utils; | ||
|
||
import lab.en2b.quizapi.game.Game; | ||
import lab.en2b.quizapi.game.GameMode; | ||
import lab.en2b.quizapi.questions.question.QuestionCategory; | ||
|
||
import java.util.List; | ||
|
||
import static lab.en2b.quizapi.game.GameMode.KIWI_QUEST; | ||
|
||
public class GameModeUtils { | ||
public static List<QuestionCategory> getQuestionCategoriesForGamemode(GameMode gamemode, List<QuestionCategory> questionCategoriesForCustom){ | ||
if(gamemode == null){ | ||
gamemode = KIWI_QUEST; | ||
} | ||
return switch (gamemode) { | ||
case KIWI_QUEST -> List.of(QuestionCategory.ART, QuestionCategory.MUSIC, QuestionCategory.GEOGRAPHY); | ||
case FOOTBALL_SHOWDOWN -> List.of(QuestionCategory.SPORTS); | ||
case GEO_GENIUS -> List.of(QuestionCategory.GEOGRAPHY); | ||
case VIDEOGAME_ADVENTURE -> List.of(QuestionCategory.VIDEOGAMES); | ||
case ANCIENT_ODYSSEY -> List.of(QuestionCategory.MUSIC,QuestionCategory.ART); | ||
case RANDOM -> List.of(QuestionCategory.values()); | ||
case CUSTOM -> questionCategoriesForCustom; | ||
}; | ||
} | ||
public static void setGamemodeParams(Game game){ | ||
switch(game.getGamemode()){ | ||
case KIWI_QUEST: | ||
game.setRounds(9L); | ||
game.setRoundDuration(30); | ||
break; | ||
case FOOTBALL_SHOWDOWN: | ||
game.setRounds(9L); | ||
game.setRoundDuration(30); | ||
break; | ||
case GEO_GENIUS: | ||
game.setRounds(9L); | ||
game.setRoundDuration(30); | ||
break; | ||
case VIDEOGAME_ADVENTURE: | ||
game.setRounds(9L); | ||
game.setRoundDuration(30); | ||
break; | ||
case ANCIENT_ODYSSEY: | ||
game.setRounds(9L); | ||
game.setRoundDuration(30); | ||
break; | ||
case RANDOM: | ||
game.setRounds(9L); | ||
game.setRoundDuration(30); | ||
break; | ||
default: | ||
game.setRounds(9L); | ||
game.setRoundDuration(30); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters