Calculate difficulty of daily sudoku after sudoku has been generated instead of assigning a difficulty pre-generation
This commit is contained in:
parent
861015ae66
commit
a015bd5597
3 changed files with 16 additions and 8 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
}
|
||||
}
|
||||
if (isDailySudoku) {
|
||||
gameController.loadNewDailySudokuLevel(gameDifficulty);
|
||||
gameController.loadNewDailySudokuLevel();
|
||||
} else {
|
||||
|
||||
List<GameInfoContainer> loadableGames = GameStateManager.getLoadableGameList();
|
||||
|
|
|
@ -77,22 +77,23 @@ public class DailySudokuActivity<Database> 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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue