Search in sources :

Example 1 with SzPuzzle

use of com.faendir.zachtronics.bot.sz.model.SzPuzzle in project zachtronics-leaderboard-bot by F43nd1r.

the class SzController method getRecord.

@Override
public SzRecordDTO getRecord(@NotNull String puzzleId, @NotNull String categoryId) {
    SzPuzzle puzzle = findPuzzle(puzzleId);
    SzCategory category = findCategory(categoryId);
    SzRecord record = repository.find(puzzle, category);
    if (record != null)
        return SzRecordDTO.fromCategoryRecord(new CategoryRecord<>(record, EnumSet.of(category)));
    else
        return null;
}
Also used : SzPuzzle(com.faendir.zachtronics.bot.sz.model.SzPuzzle) CategoryRecord(com.faendir.zachtronics.bot.repository.CategoryRecord) SzCategory(com.faendir.zachtronics.bot.sz.model.SzCategory) SzRecord(com.faendir.zachtronics.bot.sz.model.SzRecord)

Example 2 with SzPuzzle

use of com.faendir.zachtronics.bot.sz.model.SzPuzzle in project zachtronics-leaderboard-bot by F43nd1r.

the class SzShowCommand method findPuzzleAndCategory.

@NotNull
@Override
public Pair<SzPuzzle, SzCategory> findPuzzleAndCategory(@NotNull ShowData parameters) {
    SzPuzzle puzzle = parameters.puzzle;
    SzCategory 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 : SzPuzzle(com.faendir.zachtronics.bot.sz.model.SzPuzzle) SzCategory(com.faendir.zachtronics.bot.sz.model.SzCategory) Pair(kotlin.Pair) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SzCategory (com.faendir.zachtronics.bot.sz.model.SzCategory)2 SzPuzzle (com.faendir.zachtronics.bot.sz.model.SzPuzzle)2 CategoryRecord (com.faendir.zachtronics.bot.repository.CategoryRecord)1 SzRecord (com.faendir.zachtronics.bot.sz.model.SzRecord)1 Pair (kotlin.Pair)1 NotNull (org.jetbrains.annotations.NotNull)1