gui: difficulties
All checks were successful
Linux arm64 / Build (push) Successful in 1m20s

This commit is contained in:
2025-01-29 11:56:32 +01:00
parent 4190bf15d8
commit 9213a10c17
2 changed files with 21 additions and 5 deletions

View File

@@ -9,6 +9,10 @@ import sudoku.structure.SudokuFactory;
public class SoloMenu extends BaseView {
private final ImInt sudokuType = new ImInt(0);
private final ImInt difficulty = new ImInt(Difficulty.Medium.ordinal());
private final String[] difficulties;
private static final String[] sudokuTypes = { "Carré", "Rectangle", "Multidoku" };
private static final int SQUARE = 0, RECTANGLE = 1, MULTIDOKU = 2;
@@ -19,12 +23,17 @@ public class SoloMenu extends BaseView {
public SoloMenu(StateMachine stateMachine) {
super(stateMachine);
Difficulty[] diffs = Difficulty.values();
difficulties = new String[diffs.length];
for (int i = 0; i < diffs.length; i++) {
difficulties[i] = diffs[i].getDisplayName();
}
}
private void pushSudokuState(MultiDoku doku, boolean empty) {
if (!empty) {
try {
SudokuFactory.fillDoku(doku, Difficulty.Easy);
SudokuFactory.fillDoku(doku, Difficulty.values()[difficulty.get()]);
} catch (Exception e) {
e.printStackTrace();
}
@@ -36,6 +45,7 @@ public class SoloMenu extends BaseView {
public void render() {
ImGui.text("Solo");
ImGui.combo("Type de Sudoku", sudokuType, sudokuTypes);
ImGui.combo("Difficulté", difficulty, difficulties);
switch (sudokuType.get()) {
case SQUARE:
ImGui.inputInt("Taille", sudokuSize);

View File

@@ -3,12 +3,18 @@ package sudoku.structure;
//TODO: melvyn va passer par là
public enum Difficulty {
VeryEasy(0.1), Easy(0.25), Medium(0.5), Hard(0.75);
double factor;
VeryEasy("Très facile", 0.1), Easy("Facile", 0.25), Medium("Moyen", 0.5), Hard("Difficile", 0.75);
Difficulty(double factor) {
double factor;
String displayName;
Difficulty(String displayName, double factor) {
this.factor = factor;
this.displayName = displayName;
}
public String getDisplayName() {
return displayName;
}
public double getFactor() {