Merge pull request #3 from lucasnlm/fix-assistant-bug

Fix assistant bug
This commit is contained in:
Lucas Nunes 2020-02-09 10:40:01 -03:00 committed by GitHub
commit 48fed5a6a0

View file

@ -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() {