From b0eb3bd63733a522f0befd09cc48d725a58cd935 Mon Sep 17 00:00:00 2001 From: Resistencia Dev Date: Mon, 22 Dec 2025 23:46:06 +0100 Subject: [PATCH] feat: shuffle mission reveal cards randomly on each client --- client/src/components/MissionReveal.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/client/src/components/MissionReveal.tsx b/client/src/components/MissionReveal.tsx index 3509e17..b19905d 100644 --- a/client/src/components/MissionReveal.tsx +++ b/client/src/components/MissionReveal.tsx @@ -1,5 +1,5 @@ import { motion } from 'framer-motion'; -import { useEffect } from 'react'; +import { useEffect, useMemo } from 'react'; import Image from 'next/image'; interface MissionRevealProps { @@ -8,6 +8,16 @@ interface MissionRevealProps { } export default function MissionReveal({ votes, onFinished }: MissionRevealProps) { + // Barajar votos de forma aleatoria en cada cliente (orden diferente para cada jugador) + const shuffledVotes = useMemo(() => { + const shuffled = [...votes]; + for (let i = shuffled.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]]; + } + return shuffled; + }, [votes]); + // Timer de seguridad: 5 segundos y avanza useEffect(() => { const timer = setTimeout(() => { @@ -28,7 +38,7 @@ export default function MissionReveal({ votes, onFinished }: MissionRevealProps)
- {votes.map((vote, idx) => ( + {shuffledVotes.map((vote, idx) => ( Analizando resultado estratégico...