mirror of
https://github.com/johrpan/christmas_cats.git
synced 2025-10-28 19:27:25 +01:00
Reset storage values in case of error
This commit is contained in:
parent
b267459114
commit
07046d8c05
1 changed files with 5 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ class Storage {
|
|||
try {
|
||||
return shPref?.getInt('highScore1') ?? 0;
|
||||
} on TypeError {
|
||||
shPref.setInt('highScore1', 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +21,7 @@ class Storage {
|
|||
try {
|
||||
return shPref?.getInt('highScore2') ?? 0;
|
||||
} on TypeError {
|
||||
shPref.setInt('highScore2', 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -28,6 +30,7 @@ class Storage {
|
|||
try {
|
||||
return shPref?.getInt('highScore3') ?? 0;
|
||||
} on TypeError {
|
||||
shPref.setInt('highScore3', 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +42,8 @@ class Storage {
|
|||
try {
|
||||
coins.add(shPref.getInt('coins') ?? 0);
|
||||
} on TypeError {
|
||||
// Nothing to do
|
||||
shPref.setInt('coins', 0);
|
||||
// The stream already has a value of 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue