Stop player from playing the daily sudoku again if they have solved it already.
This commit is contained in:
parent
94b7b82bb4
commit
861015ae66
4 changed files with 22 additions and 6 deletions
|
@ -454,6 +454,10 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
//Save solved sudoku, if it happens to be a daily sudoku, to daily sudoku database
|
||||
if(gameController.getGameID() == GameController.DAILY_SUDOKU_ID) {
|
||||
gameController.saveDailySudoku(GameActivity.this);
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
editor.putBoolean("finishedForToday", true);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
//Show time hints new plus old best time
|
||||
|
|
|
@ -17,6 +17,7 @@ import android.widget.ListView;
|
|||
import android.widget.TextView;
|
||||
import android.view.View;
|
||||
import android.widget.RatingBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.secuso.privacyfriendlysudoku.controller.GameController;
|
||||
import org.secuso.privacyfriendlysudoku.controller.database.DatabaseHelper;
|
||||
|
@ -85,19 +86,23 @@ public class DailySudokuActivity<Database> extends AppCompatActivity {
|
|||
+ (currentDate.get(Calendar.MONTH) + 1) * 10000 + currentDate.get(Calendar.YEAR);
|
||||
final Intent intent = new Intent(this,GameActivity.class);
|
||||
|
||||
if (settings.getInt("lastPlayed", 0) == id) {
|
||||
intent.putExtra("loadLevel", true);
|
||||
intent.putExtra("loadLevelID", GameController.DAILY_SUDOKU_ID);
|
||||
} else {
|
||||
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());
|
||||
intent.putExtra("isDailySudoku", true);
|
||||
}
|
||||
|
||||
startActivity(intent);
|
||||
|
||||
} else if (!settings.getBoolean("finishedForToday", true)) {
|
||||
intent.putExtra("loadLevel", true);
|
||||
intent.putExtra("loadLevelID", GameController.DAILY_SUDOKU_ID);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
Toast.makeText(this, R.string.finished_daily_sudoku, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
|
|
@ -102,4 +102,7 @@
|
|||
<string name="skip">Skip</string>
|
||||
<string name="menu_tutorial">Tutorial</string>
|
||||
|
||||
<!-- ### DailySudokuActivity ###-->
|
||||
<string name="finished_daily_sudoku">Du hast das Sudoku des Tages bereits gelöst.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -152,4 +152,8 @@
|
|||
<string name="next">Next</string>
|
||||
<string name="skip">Skip</string>
|
||||
<string name="menu_tutorial">Tutorial</string>
|
||||
|
||||
<!-- ### DailySudokuActivity ###-->
|
||||
<string name="finished_daily_sudoku">You have already solved the sudoku of the day</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue