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 4b5d04c2..f8caeb18 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 @@ -150,16 +150,13 @@ class GameViewModel( analyticsManager.sentEvent(Event.LongPressArea(index)) } else { levelFacade.openNeighbors(index) - refreshGameStatus() analyticsManager.sentEvent(Event.LongPressMultipleArea(index)) } field.postValue(levelFacade.field.toList()) - if (levelFacade.hasMines) { - mineCount.postValue(levelFacade.remainingMines()) - } + refreshGameStatus() } fun onClickArea(index: Int) { @@ -186,14 +183,11 @@ class GameViewModel( private fun refreshMineCount() = mineCount.postValue(levelFacade.remainingMines()) private fun refreshGameStatus() { - refreshMineCount() - when { levelFacade.hasAnyMineExploded() -> { hapticFeedbackInteractor.explosionFeedback() eventObserver.postValue(GameEvent.GameOver) } - levelFacade.checkVictory() -> eventObserver.postValue(GameEvent.Victory) else -> { if (preferencesRepository.useFlagAssistant()){ levelFacade.runFlagAssistant() @@ -201,6 +195,12 @@ class GameViewModel( eventObserver.postValue(GameEvent.Running) } } + + refreshMineCount() + + if (levelFacade.checkVictory()) { + eventObserver.postValue(GameEvent.Victory) + } } fun runClock() {