feat: shuffle mission reveal cards randomly on each client
Some checks failed
CI/CD - Francia Ocupada (La Resistencia) / build-and-deploy (push) Failing after 6s
Some checks failed
CI/CD - Francia Ocupada (La Resistencia) / build-and-deploy (push) Failing after 6s
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { useEffect } from 'react';
|
import { useEffect, useMemo } from 'react';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
|
|
||||||
interface MissionRevealProps {
|
interface MissionRevealProps {
|
||||||
@@ -8,6 +8,16 @@ interface MissionRevealProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function MissionReveal({ votes, onFinished }: 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
|
// Timer de seguridad: 5 segundos y avanza
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
@@ -28,7 +38,7 @@ export default function MissionReveal({ votes, onFinished }: MissionRevealProps)
|
|||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div className="flex gap-4 justify-center mb-12 flex-wrap max-w-[90vw]">
|
<div className="flex gap-4 justify-center mb-12 flex-wrap max-w-[90vw]">
|
||||||
{votes.map((vote, idx) => (
|
{shuffledVotes.map((vote, idx) => (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={idx}
|
key={idx}
|
||||||
className="w-32 h-48 rounded-xl flex items-center justify-center shadow-2xl relative overflow-hidden"
|
className="w-32 h-48 rounded-xl flex items-center justify-center shadow-2xl relative overflow-hidden"
|
||||||
@@ -55,7 +65,7 @@ export default function MissionReveal({ votes, onFinished }: MissionRevealProps)
|
|||||||
className="text-white text-xl font-mono mt-8 text-center"
|
className="text-white text-xl font-mono mt-8 text-center"
|
||||||
initial={{ opacity: 0 }}
|
initial={{ opacity: 0 }}
|
||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
transition={{ delay: votes.length * 0.3 + 0.5 }}
|
transition={{ delay: shuffledVotes.length * 0.3 + 0.5 }}
|
||||||
>
|
>
|
||||||
<span className="animate-pulse">Analizando resultado estratégico...</span>
|
<span className="animate-pulse">Analizando resultado estratégico...</span>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|||||||
Reference in New Issue
Block a user