[FIX] Ajoute les point, cependant recompose et relance une partie à chaque fois

RepositoryAndroid
Renaud BEURET 1 year ago
parent a9fd6dbe74
commit a093d38820

@ -22,22 +22,22 @@ class KahootViewModel: ViewModel() {
nbPoints = uiState.value.nbPoints,
reponseChoisie = false)
},
uiState.value.duréePartie * 1000
uiState.value.duréePartie
)
}
// NOTE : tpsReponse en ms
fun ajouterPoints(tpsReponse: Long) {
val nbPoints: Int = if(uiState.value.reponseChoisie) {
(10_000 - tpsReponse).toInt()
} else {
0
Log.d("KahootViewModel","Je reçois une réponse")
if (uiState.value.reponseChoisie) {
Log.d("KahootViewModel","Le joueur a déjà répondu")
return
}
val nbPoints: Int = (10_000 - tpsReponse).toInt()
uiState.value = KahootUIState(uiState.value.question,
duréePartie = uiState.value.duréePartie,
nbPoints = uiState.value.nbPoints + nbPoints,
reponseChoisie = false)
reponseChoisie = true)
Log.d("KahootViewModel","Le joueur à ${uiState.value.nbPoints}")
}
}
Loading…
Cancel
Save