Store question answers for review
This commit is contained in:
parent
fe7d40c4f0
commit
5a5f0e16a4
5 changed files with 10 additions and 4 deletions
|
@ -17,6 +17,7 @@ fun GameBoard(
|
|||
reviewModeActive: Boolean,
|
||||
secondRoundDouble: Boolean,
|
||||
playerPointMap: Map<Player, Long>,
|
||||
questionsResolved: Map<QuestionData, QuestionResolution>,
|
||||
onDisableReviewMode: () -> Unit,
|
||||
onPointsChange: (Player, Long) -> Unit,
|
||||
onQuestionDone: (QuestionData, QuestionResolution) -> Unit,
|
||||
|
@ -43,6 +44,7 @@ fun GameBoard(
|
|||
QuestionGrid(
|
||||
game,
|
||||
secondRoundDouble,
|
||||
questionsResolved,
|
||||
onResolveQuestion = onQuestionDone,
|
||||
onPointsChange = onPointsChange
|
||||
)
|
||||
|
|
|
@ -137,6 +137,7 @@ fun main() = application {
|
|||
reviewModeActive,
|
||||
secondRoundDouble,
|
||||
playerPointMap,
|
||||
questionsResolved,
|
||||
onDisableReviewMode = { reviewModeActive = false },
|
||||
onPointsChange = { player, points ->
|
||||
playerPointMap[player] = playerPointMap[player]?.plus(points) ?: 0
|
||||
|
|
|
@ -29,23 +29,23 @@ fun Question(
|
|||
secondRoundDouble: Boolean,
|
||||
players: List<Player>,
|
||||
topic: Topic,
|
||||
questionResolved: QuestionResolution,
|
||||
heightFraction: Float,
|
||||
color: Color,
|
||||
onPointsChange: (Player, Long) -> Unit,
|
||||
onResolve: (QuestionData, QuestionResolution) -> Unit
|
||||
) {
|
||||
var questionVisible by remember { mutableStateOf(false) }
|
||||
var questionResolution by remember { mutableStateOf(QuestionResolution(false, null)) }
|
||||
var pointsButtonActive by remember { mutableStateOf(false) }
|
||||
|
||||
if (questionResolution.answered) {
|
||||
if (questionResolved.answered) {
|
||||
Surface(
|
||||
shape = MaterialTheme.shapes.small,
|
||||
modifier = Modifier
|
||||
.setButtonSize(heightFraction),
|
||||
color = Color.LightGray,
|
||||
) {
|
||||
val player = questionResolution.player
|
||||
val player = questionResolved.player
|
||||
if (player != null) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
|
@ -90,7 +90,6 @@ fun Question(
|
|||
players = players,
|
||||
secondRoundDouble = secondRoundDouble,
|
||||
onResolve = {
|
||||
questionResolution = it
|
||||
questionVisible = false
|
||||
onResolve(questionData, it)
|
||||
},
|
||||
|
|
|
@ -11,6 +11,7 @@ import data.QuestionData
|
|||
fun QuestionGrid(
|
||||
game: Game,
|
||||
secondRoundDouble: Boolean,
|
||||
questionResolved: Map<QuestionData, QuestionResolution>,
|
||||
onPointsChange: (player: Player, points: Long) -> Unit,
|
||||
onResolveQuestion: (QuestionData, QuestionResolution) -> Unit
|
||||
) {
|
||||
|
@ -25,6 +26,7 @@ fun QuestionGrid(
|
|||
secondRoundDouble = secondRoundDouble,
|
||||
users = users,
|
||||
columnFraction = maxColumnFraction,
|
||||
questionsResolved = questionResolved,
|
||||
onPointsChange = onPointsChange,
|
||||
onResolveQuestion = onResolveQuestion
|
||||
)
|
||||
|
|
|
@ -21,6 +21,7 @@ fun TopicRow(
|
|||
secondRoundDouble: Boolean,
|
||||
users: List<Player>,
|
||||
columnFraction: Float,
|
||||
questionsResolved: Map<QuestionData, QuestionResolution>,
|
||||
onPointsChange: (Player, Long) -> Unit,
|
||||
onResolveQuestion: (QuestionData, QuestionResolution) -> Unit
|
||||
) {
|
||||
|
@ -52,6 +53,7 @@ fun TopicRow(
|
|||
topic = topic,
|
||||
secondRoundDouble = secondRoundDouble,
|
||||
players = users,
|
||||
questionResolved = questionsResolved[question] ?: error("No resolution found for question ${question.hint}"),
|
||||
heightFraction = buttonHeightFraction,
|
||||
color = topicColor,
|
||||
onPointsChange = onPointsChange,
|
||||
|
|
Loading…
Reference in a new issue