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 e58ddd3..1a0fbbc 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java @@ -9,6 +9,7 @@ import android.os.Parcelable; import org.secuso.privacyfriendlysudoku.controller.database.DatabaseHelper; import org.secuso.privacyfriendlysudoku.controller.database.model.DailySudoku; import org.secuso.privacyfriendlysudoku.controller.helper.GameInfoContainer; +import org.secuso.privacyfriendlysudoku.controller.qqwing.QQWing; import org.secuso.privacyfriendlysudoku.game.CellConflict; import org.secuso.privacyfriendlysudoku.game.CellConflictList; import org.secuso.privacyfriendlysudoku.game.GameBoard; @@ -111,12 +112,18 @@ public class GameController implements IModelChangedListener, Parcelable { newLevelManager.checkAndRestock(); } - public void loadNewDailySudokuLevel(GameDifficulty gameDifficulty) { + public void loadNewDailySudokuLevel() { NewLevelManager newLevelManager = NewLevelManager.getInstance(context, settings); int[] level = newLevelManager.loadDailySudoku(); - loadLevel(new GameInfoContainer(DAILY_SUDOKU_ID, gameDifficulty, GameType.Default_9x9, level, null, null)); + QQWing difficultyCheck = new QQWing(GameType.Default_9x9, GameDifficulty.Unspecified); + difficultyCheck.setRecordHistory(true); + difficultyCheck.setPuzzle(level); + difficultyCheck.solve(); + + loadLevel(new GameInfoContainer(DAILY_SUDOKU_ID, difficultyCheck.getDifficulty(), + GameType.Default_9x9, level, null, null)); newLevelManager.checkAndRestock(); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java index 9512ce5..3837b42 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java @@ -169,7 +169,7 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig } } if (isDailySudoku) { - gameController.loadNewDailySudokuLevel(gameDifficulty); + gameController.loadNewDailySudokuLevel(); } else { List loadableGames = GameStateManager.getLoadableGameList(); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DailySudokuActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DailySudokuActivity.java index e5197fe..6534d59 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DailySudokuActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/DailySudokuActivity.java @@ -77,22 +77,23 @@ public class DailySudokuActivity extends AppCompatActivity { public void onClick(View view) { - int index = difficultyBar.getProgress()-1; - GameDifficulty gameDifficulty = GameDifficulty.getValidDifficultyList().get(index < 0 ? 0 : index); - - //send everything to game activity + // Calculate the current date as an int id Calendar currentDate = Calendar.getInstance(); int id = currentDate.get(Calendar.DAY_OF_MONTH) * 1000000 + (currentDate.get(Calendar.MONTH) + 1) * 10000 + currentDate.get(Calendar.YEAR); final Intent intent = new Intent(this,GameActivity.class); + /* + If the 'lastPlayed' key does not return the calculated id, then the player has not played + the sudoku of the day yet, meaning it has yet to be generated + */ if (settings.getInt("lastPlayed", 0) != id) { SharedPreferences.Editor editor = settings.edit(); editor.putInt("lastPlayed", id); editor.putBoolean("finishedForToday", false); editor.apply(); - intent.putExtra("gameDifficulty", gameDifficulty.name()); + //send everything to game activity intent.putExtra("isDailySudoku", true); startActivity(intent);