Prevent winning dialog on game selected with sufficient points.
All checks were successful
Build Android / build (push) Successful in 8m36s
All checks were successful
Build Android / build (push) Successful in 8m36s
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user