Deferred Questions disable players for second guess.
This commit is contained in:
parent
8fed21551f
commit
0221a43a72
3 changed files with 20 additions and 9 deletions
|
@ -3,7 +3,7 @@ package components.questiondialog
|
|||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
@ -28,6 +28,7 @@ fun QuestionDialogButtons(
|
|||
secondRoundDouble: Boolean
|
||||
) {
|
||||
val fontSize = 5.em
|
||||
var questionAnswered by remember { mutableStateOf<Pair<Boolean, Player?>>(false to null) }
|
||||
|
||||
Box(
|
||||
modifier = Modifier.fillMaxHeight().fillMaxWidth()
|
||||
|
@ -53,9 +54,11 @@ fun QuestionDialogButtons(
|
|||
DeferredDoubleQuestionDialogPlayer(
|
||||
player = player,
|
||||
fontSize = fontSize,
|
||||
allowedToAnswer = !(questionAnswered.first) || player == questionAnswered.second,
|
||||
onPointsChange = onPointsChange,
|
||||
questionPoints = questionData.actualUsagePoints(secondRoundDouble).toLong(),
|
||||
onQuestionAnswered = onResolve
|
||||
onQuestionDone = onResolve,
|
||||
onQuestionAnswered = { questionAnswered = true to it }
|
||||
)
|
||||
} else {
|
||||
QuestionDialogPlayer(
|
||||
|
@ -63,11 +66,14 @@ fun QuestionDialogButtons(
|
|||
fontSize = fontSize,
|
||||
onPointsChange = onPointsChange,
|
||||
questionPoints = questionData.actualUsagePoints(secondRoundDouble).toLong(),
|
||||
onQuestionAnswered = onResolve
|
||||
onQuestionAnswered = {
|
||||
questionAnswered = true to it
|
||||
onResolve()
|
||||
}
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.height(20.dp))
|
||||
}
|
||||
Spacer(Modifier.height(20.dp))
|
||||
DismissButton(onResolve, fontSize)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ fun DeferredDoubleQuestionDialogPlayer(
|
|||
player: Player,
|
||||
fontSize: TextUnit,
|
||||
onPointsChange: (Player, Long) -> Unit,
|
||||
onQuestionAnswered: () -> Unit,
|
||||
allowedToAnswer: Boolean,
|
||||
onQuestionDone: () -> Unit,
|
||||
onQuestionAnswered: (Player) -> Unit,
|
||||
questionPoints: Long
|
||||
) {
|
||||
Row(
|
||||
|
@ -35,7 +37,7 @@ fun DeferredDoubleQuestionDialogPlayer(
|
|||
fontSize = fontSize
|
||||
)
|
||||
ButtonSpacer()
|
||||
if (hadFail) {
|
||||
if (hadFail || !allowedToAnswer) {
|
||||
DisabledButton(maxWidthFraction = 1f, fontSize = fontSize)
|
||||
} else {
|
||||
if (deferredGuess) {
|
||||
|
@ -59,6 +61,7 @@ fun DeferredDoubleQuestionDialogPlayer(
|
|||
onClick = {
|
||||
deferredGuess = true
|
||||
onPointsChange(player, questionPoints)
|
||||
onQuestionAnswered(player)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
|
@ -66,7 +69,7 @@ fun DeferredDoubleQuestionDialogPlayer(
|
|||
fontSize = fontSize,
|
||||
onClick = {
|
||||
onPointsChange(player, questionPoints)
|
||||
onQuestionAnswered()
|
||||
onQuestionDone()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -20,13 +20,14 @@ fun QuestionDialogPlayer(
|
|||
fontSize: TextUnit,
|
||||
onPointsChange: (Player, Long) -> Unit,
|
||||
questionPoints: Long,
|
||||
onQuestionAnswered: () -> Unit
|
||||
onQuestionAnswered: (Player) -> Unit
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
var hadFail by remember { mutableStateOf(false) }
|
||||
|
||||
Text(
|
||||
text = player.name,
|
||||
modifier = Modifier.fillMaxWidth(0.6f),
|
||||
|
@ -36,6 +37,7 @@ fun QuestionDialogPlayer(
|
|||
if (hadFail) {
|
||||
DisabledButton(maxWidthFraction = 1f, fontSize = fontSize)
|
||||
} else {
|
||||
// TODO: Implement "answer" view
|
||||
BadAnswerButton(
|
||||
fontSize = fontSize,
|
||||
onClick = {
|
||||
|
@ -51,7 +53,7 @@ fun QuestionDialogPlayer(
|
|||
fontSize = fontSize,
|
||||
onClick = {
|
||||
onPointsChange(player, questionPoints)
|
||||
onQuestionAnswered()
|
||||
onQuestionAnswered(player)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue