Search in sources :

Example 1 with IfPuzzle

use of com.faendir.zachtronics.bot.inf.model.IfPuzzle in project zachtronics-leaderboard-bot by F43nd1r.

the class IfController method getRecord.

@GetMapping(path = "/puzzle/{puzzleId}/category/{categoryId}/record", produces = MediaType.APPLICATION_JSON_VALUE)
public IfRecordDTO getRecord(@PathVariable String puzzleId, @PathVariable String categoryId) {
    IfPuzzle puzzle = findPuzzle(puzzleId);
    IfCategory category = findCategory(categoryId);
    IfRecord record = repository.find(puzzle, category);
    if (record != null)
        return IfRecordDTO.fromCategoryRecord(new CategoryRecord<>(record, EnumSet.of(category)));
    else
        return null;
}
Also used : IfRecord(com.faendir.zachtronics.bot.inf.model.IfRecord) IfPuzzle(com.faendir.zachtronics.bot.inf.model.IfPuzzle) IfCategory(com.faendir.zachtronics.bot.inf.model.IfCategory) CategoryRecord(com.faendir.zachtronics.bot.repository.CategoryRecord)

Example 2 with IfPuzzle

use of com.faendir.zachtronics.bot.inf.model.IfPuzzle in project zachtronics-leaderboard-bot by F43nd1r.

the class IfShowCommand method findPuzzleAndCategory.

@NotNull
@Override
public Pair<IfPuzzle, IfCategory> findPuzzleAndCategory(@NotNull ShowData parameters) {
    IfPuzzle puzzle = parameters.puzzle;
    IfCategory category = parameters.category;
    if (!parameters.puzzle.getSupportedCategories().contains(category))
        throw new IllegalArgumentException("Category " + category.getDisplayName() + " does not support " + puzzle.getDisplayName());
    return new Pair<>(puzzle, category);
}
Also used : IfPuzzle(com.faendir.zachtronics.bot.inf.model.IfPuzzle) IfCategory(com.faendir.zachtronics.bot.inf.model.IfCategory) Pair(kotlin.Pair) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

IfCategory (com.faendir.zachtronics.bot.inf.model.IfCategory)2 IfPuzzle (com.faendir.zachtronics.bot.inf.model.IfPuzzle)2 IfRecord (com.faendir.zachtronics.bot.inf.model.IfRecord)1 CategoryRecord (com.faendir.zachtronics.bot.repository.CategoryRecord)1 Pair (kotlin.Pair)1 NotNull (org.jetbrains.annotations.NotNull)1