|
@@ -384,22 +384,24 @@ class GameStartScreen extends React.Component<PropsType> {
|
384
|
384
|
recoverGameScore() {
|
385
|
385
|
const {route} = this.props;
|
386
|
386
|
this.gameStats = route.params;
|
387
|
|
- this.isHighScore =
|
388
|
|
- this.scores.length === 0 || this.gameStats.score > this.scores[0];
|
389
|
|
- for (let i = 0; i < 3; i += 1) {
|
390
|
|
- if (this.scores.length > i && this.gameStats.score > this.scores[i]) {
|
391
|
|
- this.scores.splice(i, 0, this.gameStats.score);
|
392
|
|
- break;
|
393
|
|
- } else if (this.scores.length <= i) {
|
394
|
|
- this.scores.push(this.gameStats.score);
|
395
|
|
- break;
|
|
387
|
+ if (this.gameStats.score != null) {
|
|
388
|
+ this.isHighScore =
|
|
389
|
+ this.scores.length === 0 || this.gameStats.score > this.scores[0];
|
|
390
|
+ for (let i = 0; i < 3; i += 1) {
|
|
391
|
+ if (this.scores.length > i && this.gameStats.score > this.scores[i]) {
|
|
392
|
+ this.scores.splice(i, 0, this.gameStats.score);
|
|
393
|
+ break;
|
|
394
|
+ } else if (this.scores.length <= i) {
|
|
395
|
+ this.scores.push(this.gameStats.score);
|
|
396
|
+ break;
|
|
397
|
+ }
|
396
|
398
|
}
|
|
399
|
+ if (this.scores.length > 3) this.scores.splice(3, 1);
|
|
400
|
+ AsyncStorageManager.set(
|
|
401
|
+ AsyncStorageManager.PREFERENCES.gameScores.key,
|
|
402
|
+ this.scores,
|
|
403
|
+ );
|
397
|
404
|
}
|
398
|
|
- if (this.scores.length > 3) this.scores.splice(3, 1);
|
399
|
|
- AsyncStorageManager.set(
|
400
|
|
- AsyncStorageManager.PREFERENCES.gameScores.key,
|
401
|
|
- this.scores,
|
402
|
|
- );
|
403
|
405
|
}
|
404
|
406
|
|
405
|
407
|
render(): React.Node {
|