From bced5e09884a3825cee20ab51ce477e02e83f7f2 Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Thu, 10 Nov 2022 21:12:51 -0800 Subject: [PATCH] Modify hint button to fill in all notes --- .../controller/GameController.java | 42 +++++++++++++++++++ .../ui/view/SudokuSpecialButtonLayout.java | 15 +------ 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java index ed0d54d..0ed572f 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java @@ -40,8 +40,10 @@ import org.secuso.privacyfriendlysudoku.game.listener.IModelChangedListener; import org.secuso.privacyfriendlysudoku.game.listener.ITimerListener; import org.secuso.privacyfriendlysudoku.ui.GameActivity; +import java.util.Arrays; import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Timer; @@ -218,6 +220,7 @@ public class GameController implements IModelChangedListener, Parcelable { }*/ public void hint(){ + /* if(!isValidCellSelected()) { return; } @@ -233,7 +236,46 @@ public class GameController implements IModelChangedListener, Parcelable { usedHints++; notifyHintListener(); + notifyHighlightChangedListeners();*/ + + final GameCell[][] field = gameBoard.getField(); + for(int row_id=0; row_id < field.length; row_id++) { + final GameCell[] row_field = field[row_id]; + for(int column_id=0; column_id < row_field.length; column_id++) { + final GameCell cell = row_field[column_id]; + + if(cell.hasValue()){ + continue; + } + + final boolean[] notes = new boolean[gameBoard.getSize()]; + Arrays.fill(notes, true); + + removeFixedValues(notes, gameBoard.getRow(row_id)); + removeFixedValues(notes, gameBoard.getColumn(column_id)); + removeFixedValues(notes, gameBoard.getSection(row_id, column_id)); + + cell.deleteNotes(); + for(int i=0; i section) { + for(GameCell neighbour_cell : section) { + if(neighbour_cell.isFixed()){ + notes[neighbour_cell.getValue() - 1] = false; + } + } } private void setGameType(GameType type) { diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java index 06316ec..d63afd0 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuSpecialButtonLayout.java @@ -88,20 +88,7 @@ public class SudokuSpecialButtonLayout extends LinearLayout implements IHighligh gameController.UnDo(); break; case Hint: - if(gameController.isValidCellSelected()) { - if(gameController.getUsedHints() == 0 && !gameController.gameIsCustom()) { - // are you sure you want to use a hint? - HintConfirmationDialog hintDialog = new HintConfirmationDialog(); - hintDialog.show(fragmentManager, "HintDialogFragment"); - - } else { - gameController.hint(); - } - } else { - // Display a Toast that explains how to use the Hint function. - Toast t = Toast.makeText(getContext(), R.string.hint_usage, Toast.LENGTH_SHORT); - t.show(); - } + gameController.hint(); break; default: break;