Fix: Ahora no se paraliza el minijuego al generar una nueva combinacion de estratagema
Some checks failed
Build Android APK / build (push) Has been cancelled

This commit is contained in:
2026-04-16 17:45:06 +02:00
parent 79a7829a24
commit 0be1ae97ff
3 changed files with 61 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
@@ -194,6 +195,8 @@ private static final String[] NAMES = {
private LinearLayout sequenceContainer;
private ImageButton btnUp, btnDown, btnLeft, btnRight;
private android.widget.Button btnVolver;
private ProgressBar progressBar;
private ImageView ivFailure;
private int[] sequence;
private int playerIndex = 0;
@@ -201,6 +204,7 @@ private static final String[] NAMES = {
private boolean esperando = false;
private boolean juegoActivo = true;
private int currentStratagemIndex = 0;
private boolean bloqueado = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -218,6 +222,8 @@ private static final String[] NAMES = {
btnLeft = findViewById(R.id.btn_left);
btnRight = findViewById(R.id.btn_right);
btnVolver = findViewById(R.id.btn_volver);
progressBar = findViewById(R.id.progress_bar);
ivFailure = findViewById(R.id.iv_failure);
btnVolver.setOnClickListener(v -> finish());
@@ -245,6 +251,10 @@ private static final String[] NAMES = {
currentStratagemIndex = idx;
playerIndex = 0;
juegoActivo = true;
bloqueado = false;
if (progressBar != null) progressBar.setVisibility(View.GONE);
if (ivFailure != null) ivFailure.setVisibility(View.GONE);
if (ivStratagemIcon != null) {
try {
@@ -258,7 +268,7 @@ private static final String[] NAMES = {
secuenciaMostrar();
handler.removeCallbacksAndMessages(null);
handler.postDelayed(() -> { esperando = true; }, 1200);
esperando = true;
}
private static final String ARROW_CHARS = "\u2191\u2193\u2190\u2192";
@@ -293,7 +303,8 @@ private static final String[] NAMES = {
}
private void onInput(int dir) {
if (!juegoActivo || !esperando) return;
if (!juegoActivo || !esperando || bloqueado) return;
bloqueado = true;
if (dir == sequence[playerIndex]) {
playerIndex++;
@@ -313,13 +324,22 @@ private static final String[] NAMES = {
completadas++;
if (tvCounter != null) tvCounter.setText(String.valueOf(completadas));
esperando = false;
handler.postDelayed(this::nuevaRonda, 1200);
if (progressBar != null) {
progressBar.setVisibility(View.VISIBLE);
handler.postDelayed(() -> {
if (progressBar != null) progressBar.setVisibility(View.GONE);
}, 300);
}
handler.postDelayed(this::nuevaRonda, 300);
} else {
bloqueado = false;
}
} else {
if (soundManager != null) {
try { soundManager.playFailure(); } catch (Exception e) {}
}
juegoActivo = false;
if (ivFailure != null) ivFailure.setVisibility(View.VISIBLE);
handler.postDelayed(this::nuevaRonda, 1500);
}
}

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="150dp"
android:height="150dp"
android:viewportWidth="150"
android:viewportHeight="150">
<!-- Red circle background -->
<path
android:fillColor="#CC0000"
android:pathData="M75,75m-60,0a60,60 0,1 1,120 0a60,60 0,1 1,-120 0"/>
<!-- X mark -->
<path
android:strokeWidth="10"
android:strokeColor="#FFFFFF"
android:pathData="M45,45L105,105"/>
<path
android:strokeWidth="10"
android:strokeColor="#FFFFFF"
android:pathData="M105,45L45,105"/>
</vector>

View File

@@ -205,4 +205,22 @@
android:scaleType="fitCenter"
android:src="@drawable/stratagemas_icon" />
<!-- Loading Spinner -->
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerInParent="true"
android:indeterminateTint="#FFD700"
android:visibility="gone" />
<!-- Failure Indicator (X) -->
<ImageView
android:id="@+id/iv_failure"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_failure"
android:visibility="gone" />
</RelativeLayout>