Skip to content

Commit

Permalink
ordago y resetear puntuación al ganar
Browse files Browse the repository at this point in the history
  • Loading branch information
RodAlc24 committed Jun 2, 2024
1 parent 4be51e2 commit 6e77366
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions app/src/main/java/com/rodalc/amarracos/mus/PantallaMus.kt
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,42 @@ fun PantallaConfiguracion(
@Composable
fun PlantillaMus() {
val viewModel = MusViewModel()
val buenos by viewModel.buenos.collectAsState()
val malos by viewModel.malos.collectAsState()
val puntos by viewModel.puntos.collectAsState()

var rondaEnvites by rememberSaveable { mutableStateOf(true) }

val finRonda = { gannBuenos: Boolean ->
rondaEnvites = true
viewModel.updateEnvites(Envites())
if (gannBuenos) {
viewModel.updateBuenos(buenos.copy(puntos = 0, victorias = buenos.victorias + 1))
viewModel.updateMalos(malos.copy(puntos = 0))
} else {
viewModel.updateMalos(malos.copy(puntos = 0, victorias = malos.victorias + 1))
viewModel.updateBuenos(buenos.copy(puntos = 0))
}
}

if (buenos.puntos >= puntos) {
finRonda(true)
} else if (malos.puntos >= puntos) {
finRonda(false)
}

// TODO: If landscape ... else ...
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxSize()
) {
Spacer(modifier = Modifier.weight(1f))
ColumnaParejaLandscape(buenos = true, viewModel) { rondaEnvites = !rondaEnvites }
ColumnaParejaLandscape(buenos = true, viewModel) { finRonda(true) }
Spacer(modifier = Modifier.weight(1f))
ColumnaEnvites(viewModel, rondaEnvites) { rondaEnvites = !rondaEnvites }
Spacer(modifier = Modifier.weight(1f))
ColumnaParejaLandscape(buenos = false, viewModel) { rondaEnvites = !rondaEnvites }
ColumnaParejaLandscape(buenos = false, viewModel) { finRonda(false) }
Spacer(modifier = Modifier.weight(1f))
}
}
Expand Down Expand Up @@ -194,7 +216,9 @@ fun ColumnaParejaLandscape(buenos: Boolean, viewModel: MusViewModel, onOrdago: (
}
}
Spacer(modifier = Modifier.weight(1f))
Button(onClick = { /*TODO*/ }) {
Button(onClick = {
onOrdago()
}) {
Text("Órdago")
}
Spacer(modifier = Modifier.weight(5f))
Expand Down

0 comments on commit 6e77366

Please sign in to comment.