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