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.
Merge remote-tracking branch 'origin/develop' into fix/webapp/game
- Loading branch information
Showing
14 changed files
with
319 additions
and
78 deletions.
There are no files selected for viewing
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
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,14 @@ | ||
FROM grafana/grafana | ||
LABEL authors="dario" | ||
# Define the source and destination directories | ||
COPY_SOURCE = ./provisioning | ||
COPY_DESTINATION = /etc/grafana/provisioning | ||
|
||
# Copy the configuration files | ||
COPY ${COPY_SOURCE}/* ${COPY_DESTINATION} | ||
|
||
# Expose the default Grafana port | ||
EXPOSE 9091 | ||
|
||
# Run Grafana in the foreground | ||
CMD ["grafana-server"] |
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,14 @@ | ||
FROM prom/prometheus | ||
LABEL authors="dario" | ||
# Define the source and destination directories | ||
COPY_SOURCE = ./configuration | ||
COPY_DESTINATION = /etc/prometheus | ||
|
||
# Copy the configuration files | ||
COPY ${COPY_SOURCE}/* ${COPY_DESTINATION} | ||
|
||
# Expose the default Prometheus port | ||
EXPOSE 9090 | ||
|
||
# Run Prometheus in the foreground | ||
CMD ["prometheus"] |
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
182 changes: 125 additions & 57 deletions
182
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 |
---|---|---|
@@ -1,57 +1,125 @@ | ||
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); | ||
} | ||
} | ||
} | ||
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 lab.en2b.quizapi.questions.question.dtos.QuestionCategoryDto; | ||
|
||
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); | ||
} | ||
} | ||
|
||
public static List<QuestionCategoryDto> getQuestionCategories(String lang) { | ||
if(lang == null) | ||
lang = "en"; | ||
if(lang.equals("en")) | ||
return getQuestionCategoriesEn(); | ||
return getQuestionCategoriesEs(); | ||
} | ||
private static List<QuestionCategoryDto> getQuestionCategoriesEn(){ | ||
return List.of( | ||
QuestionCategoryDto.builder() | ||
.name("Art") | ||
.description("Are you an art expert? Prove it!") | ||
.internalRepresentation(QuestionCategory.ART) | ||
.build(), | ||
QuestionCategoryDto.builder() | ||
.name("Music") | ||
.description("Are you a music lover? Prove it!") | ||
.internalRepresentation(QuestionCategory.MUSIC) | ||
.build(), | ||
QuestionCategoryDto.builder() | ||
.name("Geography") | ||
.description("Are you a geography expert? Prove it!") | ||
.internalRepresentation(QuestionCategory.GEOGRAPHY) | ||
.build(), | ||
QuestionCategoryDto.builder() | ||
.name("Sports") | ||
.description("Are you a sports fanatic? Prove it!") | ||
.internalRepresentation(QuestionCategory.SPORTS) | ||
.build(), | ||
QuestionCategoryDto.builder() | ||
.name("Video Games") | ||
.description("Are you a gamer? Prove it!") | ||
.internalRepresentation(QuestionCategory.VIDEOGAMES) | ||
.build() | ||
); | ||
} | ||
|
||
private static List<QuestionCategoryDto> getQuestionCategoriesEs(){ | ||
return List.of( | ||
QuestionCategoryDto.builder() | ||
.name("Arte") | ||
.description("¿Eres un experto en arte? ¡Demuéstralo!") | ||
.internalRepresentation(QuestionCategory.ART) | ||
.build(), | ||
QuestionCategoryDto.builder() | ||
.name("Música") | ||
.description("¿Eres un melómano? ¡Demuéstralo!") | ||
.internalRepresentation(QuestionCategory.MUSIC) | ||
.build(), | ||
QuestionCategoryDto.builder() | ||
.name("Geografía") | ||
.description("¿Eres un experto en geografía? ¡Demuéstralo!") | ||
.internalRepresentation(QuestionCategory.GEOGRAPHY) | ||
.build(), | ||
QuestionCategoryDto.builder() | ||
.name("Deportes") | ||
.description("¿Eres un fanático de los deportes? ¡Demuéstralo!") | ||
.internalRepresentation(QuestionCategory.SPORTS) | ||
.build(), | ||
QuestionCategoryDto.builder() | ||
.name("Videojuegos") | ||
.description("¿Eres un gamer? ¡Demuéstralo!") | ||
.internalRepresentation(QuestionCategory.VIDEOGAMES) | ||
.build() | ||
); | ||
} | ||
} |
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
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
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
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
21 changes: 21 additions & 0 deletions
21
api/src/main/java/lab/en2b/quizapi/questions/question/dtos/QuestionCategoryDto.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,21 @@ | ||
package lab.en2b.quizapi.questions.question.dtos; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lab.en2b.quizapi.questions.question.QuestionCategory; | ||
import lombok.*; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
@Setter | ||
public class QuestionCategoryDto { | ||
@Schema(description = "Beautified name of the question category",example = "Sports") | ||
private String name; | ||
@Schema(description = "Description of the question category",example = "Test description of the question category") | ||
private String description; | ||
@JsonProperty("internal_representation") | ||
@Schema(description = "Internal code used for describing the question category",example = "SPORTS") | ||
private QuestionCategory internalRepresentation; | ||
} |
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
Oops, something went wrong.