From 460e92bee22a32496c32685d011d76d6263d574b Mon Sep 17 00:00:00 2001 From: Lucas Lima Date: Fri, 1 Jan 2021 12:36:36 -0300 Subject: [PATCH] Avoid haptic feedback on complete game overs --- app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt | 6 +++--- .../antimine/common/level/viewmodel/GameViewModel.kt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt b/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt index 951f591f..df61c4af 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt @@ -804,13 +804,13 @@ class GameActivity : ThematicActivity(R.layout.activity_game), DialogInterface.O gameViewModel.stopClock() if (!isResuming) { + val isGameCompleted = gameViewModel.isCompletedWithMistakes() cloudSaveManager.uploadSave() lifecycleScope.launch { - gameViewModel.gameOver(isResuming) + gameViewModel.gameOver(isResuming, !isGameCompleted) gameViewModel.saveGame() waitAndShowEndGameAlert( - gameResult = if (gameViewModel.isCompletedWithMistakes()) - GameResult.Completed else GameResult.GameOver, + gameResult = if (isGameCompleted) GameResult.Completed else GameResult.GameOver, await = true, canContinue = gameViewModel.hasUnknownMines(), ) diff --git a/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt b/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt index 92db63bd..13174295 100644 --- a/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt +++ b/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt @@ -428,11 +428,11 @@ open class GameViewModel( } } - suspend fun gameOver(fromResumeGame: Boolean) { + suspend fun gameOver(fromResumeGame: Boolean, useGameOverFeedback: Boolean) { gameController.run { analyticsManager.sentEvent(Analytics.GameOver(clock.time(), getScore())) - if (!fromResumeGame) { + if (!fromResumeGame && useGameOverFeedback) { if (preferencesRepository.useHapticFeedback()) { hapticFeedbackManager.explosionFeedback() }