Skip to content

Commit

Permalink
Merge pull request #39 from teogor/enhance/gametype-model-check-diffi…
Browse files Browse the repository at this point in the history
…culty

Add `supportsDifficulty` function for GameType compatibility
  • Loading branch information
teogor authored Feb 8, 2024
2 parents d50e196 + dd03b8b commit df1d147
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sudoklify/api/sudoklify.api
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public final class dev/teogor/sudoklify/model/GameType : java/lang/Enum {
public static fun values ()[Ldev/teogor/sudoklify/model/GameType;
}

public final class dev/teogor/sudoklify/model/GameTypeKt {
public static final fun supportsDifficulty (Ldev/teogor/sudoklify/model/GameType;Ldev/teogor/sudoklify/model/Difficulty;)Z
}

public final class dev/teogor/sudoklify/model/Sudoku {
public fun <init> ([[Ljava/lang/String;[[Ljava/lang/String;Ldev/teogor/sudoklify/model/Difficulty;Ldev/teogor/sudoklify/model/GameType;)V
public final fun component1 ()[[Ljava/lang/String;
Expand Down
14 changes: 14 additions & 0 deletions sudoklify/src/main/kotlin/dev/teogor/sudoklify/model/GameType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package dev.teogor.sudoklify.model

import dev.teogor.sudoklify.SEEDS

// TODO get box size and row/col size

/**
Expand Down Expand Up @@ -122,3 +124,15 @@ enum class GameType(
return "${cells}x$cells"
}
}

/**
* Checks if this game type supports the specified difficulty level.
*
* @param difficulty The difficulty level to check for.
* @return True if the game type supports the given difficulty,
* false otherwise.
*/
fun GameType.supportsDifficulty(difficulty: Difficulty) =
SEEDS.any {
it.gameType == this && it.difficulty == difficulty
}

0 comments on commit df1d147

Please sign in to comment.