Prevent winning dialog on game selected with sufficient points.
All checks were successful
Build Android / build (push) Successful in 8m36s

This commit is contained in:
2023-09-27 18:53:05 +02:00
parent fa9786de04
commit 45ae61584d
2 changed files with 4 additions and 4 deletions

View File

@@ -169,6 +169,7 @@ class CounterViewModel @Inject constructor(
get() = totalScoreA >= settings.victoryPoints.value || totalScoreB >= settings.victoryPoints.value
private var lastRoundCount: Int = 0
init {
viewModelScope.launch {
gameRepository.getActiveGameFlow().collect {
@@ -191,6 +192,7 @@ class CounterViewModel @Inject constructor(
}
lastGame = it.game
lastRoundCount = it.rounds.size
return@collect
}
// Game winning condition
@@ -201,9 +203,8 @@ class CounterViewModel @Inject constructor(
}
// Undo game winning if rounds were removed
if(lastRoundCount > it.rounds.size)
{
if(!gameWon){
if (lastRoundCount > it.rounds.size) {
if (!gameWon) {
settings.gameFinished.value = false
}
}

View File

@@ -53,7 +53,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import me.zobrist.tichucounter.R