15 Commits

Author SHA1 Message Date
Resistencia Dev
ead54e0102 Fix: Auto-avanzar de MISSION_REVEAL a MISSION_RESULT
- Servidor avanza automáticamente después de 5 segundos
- Resuelve problema de quedarse bloqueado en pantalla de votos
- Cliente muestra 'Procesando resultado...'
2025-12-05 23:57:46 +01:00
Resistencia Dev
4b4936449a Feature: Implementar MissionResult completo
- Muestra resultado de la misión con animaciones
- Obtiene datos de missionHistory
- Muestra éxitos vs sabotajes
- Muestra progreso de misiones (Resistencia vs Espías)
- Botón CONTINUAR para avanzar
- Animaciones escalonadas para mejor UX
2025-12-05 23:51:32 +01:00
Resistencia Dev
1c8f1b08f5 Debug: Agregar info de facción y rol en fase MISSION
- Muestra facción y rol del jugador
- Ayuda a identificar por qué algunos espías no ven carta de sabotaje
2025-12-05 23:46:43 +01:00
Resistencia Dev
00434daf97 Feature: Feedback visual simple con opacidad en cartas
- Carta seleccionada: opacity-100 (brillante)
- Carta NO seleccionada: opacity-50 (apagada)
- Aplicado a las 4 cartas (2 éxito + 2 sabotaje)
- Botones deshabilitados después de votar
- Solución mucho más simple y elegante
2025-12-05 23:44:26 +01:00
Resistencia Dev
94cb0d671d WIP: Agregar feedback visual a carta de éxito (primera)
- Borde amarillo brillante cuando está seleccionada
- Ring amarillo con glow
- Deshabilitar botón después de votar
- Falta aplicar a las otras 3 cartas
2025-12-05 23:39:35 +01:00
Resistencia Dev
951098540c Fix: MissionReveal con tics blancos y mejor layout
- Cambiar text-4xl a text-5xl para tics más grandes
- Agregar text-white para que los tics sean blancos
- Agregar font-bold para mejor visibilidad
- Mejorar layout con flex-col
- Agregar mensaje informativo
2025-12-05 23:34:21 +01:00
Resistencia Dev
40565a936b Feature: Completar sistema de votación de misiones
- Cambiar onClick para usar handleMissionVote
- Crear componentes MissionReveal y MissionResult
- Importar componentes en GameBoard
- Tracking de votos con feedback visual
- Usar imágenes vote_approve y vote_reject

Resuelve error: MissionReveal is not defined
2025-12-05 23:27:32 +01:00
Resistencia Dev
2f2bc4e4d0 WIP: Cambiar imágenes de misión y agregar tracking de votos
- Cambiar mission_success/fail a vote_approve/reject
- Agregar estado missionVote para trackear voto del jugador
- Agregar función handleMissionVote
- Reset de voto cuando cambia la fase
- Falta: actualizar onClick y agregar feedback visual
2025-12-05 23:26:20 +01:00
Resistencia Dev
7fbf964c12 Fix: Resolver error de React hooks en fase MISSION
- Mover useState de cardOrder al nivel del componente
- Eliminar IIFE que causaba violación de reglas de hooks
- Usar cardOrder directamente en lugar de successFirst
- Ahora la fase MISSION debería funcionar correctamente
2025-12-05 23:18:20 +01:00
Resistencia Dev
79ec36dd1a Feature: Eliminar fase VOTING_TEAM - ir directo a MISSION
- Cambio de flujo: Líder elige equipo → Directamente a MISSION
- Ya no se vota si se aprueba o rechaza el equipo
- Simplifica el juego según las reglas solicitadas
- El líder selecciona y el equipo ejecuta inmediatamente
2025-12-05 23:11:19 +01:00
Resistencia Dev
19f4d1d6fb Debug: Agregar información de depuración para fase MISSION
- Muestra el ID del jugador actual y los IDs del equipo propuesto
- Ayuda a identificar por qué todos ven las cartas en lugar de solo el equipo
2025-12-05 23:01:29 +01:00
Resistencia Dev
9cd22365ec Fix: Corregir iconos de líder y equipo
- Fix: Usar currentLeaderId en lugar de player.isLeader (evita múltiples L)
- Fix: Mostrar estrella verde también en VOTING_TEAM
- Ahora solo aparece un icono L (líder actual)
- Estrellas verdes visibles para equipo propuesto
2025-12-05 22:55:12 +01:00
Resistencia Dev
ffdbc78193 Feature: Agregar estrella verde para miembros del equipo de misión
- Add: Icono de estrella  verde para identificar miembros del equipo
- Fix: Diferencia clara entre líder (L amarillo) y miembros del equipo ( verde)
- Visible durante fases MISSION, MISSION_REVEAL y MISSION_RESULT
2025-12-05 22:45:00 +01:00
Resistencia Dev
677c2c0eab Fix: Corregir selección de líder y mejorar UI de misiones
- Fix: isLeader ahora usa currentLeaderId del estado (evita múltiples líderes)
- Mejora: TEAM_BUILDING muestra claramente quién es el líder actual
- Mejora: Contador de jugadores seleccionados en TEAM_BUILDING
- Mejora: MISSION con cartas grandes en pantalla completa
- Feature: Posición aleatoria de cartas (izq/der) para evitar detectar votos
- Mejora: Animaciones mejoradas con Framer Motion
- Mejora: Mensajes más claros para jugadores que esperan
2025-12-05 22:30:10 +01:00
Resistencia Dev
dad148ebb6 Add CHANGELOG for v0.1.0 2025-12-05 22:23:20 +01:00
5 changed files with 381 additions and 43 deletions

77
CHANGELOG.md Normal file
View File

@@ -0,0 +1,77 @@
# Notas de Versión
## v0.1.0-functional-until-mission (2025-12-05)
### ✅ Funcionalidades Implementadas
#### Backend (100% Completo)
- ✅ Sistema completo de salas y jugadores
- ✅ Asignación automática de roles (Resistencia/Espías)
- ✅ Todas las fases del juego implementadas:
- LOBBY, INTRO, REVEAL_ROLE, ROLL_CALL
- VOTE_LEADER (con sistema de aprobación/rechazo)
- TEAM_BUILDING, VOTE_TEAM
- MISSION (votación éxito/sabotaje)
- **MISSION_REVEAL** (barajado de votos - solo lógica)
- **MISSION_RESULT** (resumen de misión - solo lógica)
- ASSASSIN_PHASE
- ✅ Histórico de misiones (MissionRecord)
- ✅ Reglas correctas implementadas:
- Misión 4 con 7+ jugadores requiere 2 fallos
- 5 rechazos consecutivos = victoria espías
- 3 misiones exitosas/fallidas = victoria
- ✅ WebSocket con Socket.IO para comunicación en tiempo real
#### Frontend (Funcional hasta MISSION)
- ✅ Lobby completo con creación/unión de partidas
- ✅ Intro con música (Intro.ogg)
- ✅ Revelación de roles con animaciones
- ✅ Roll call con música (Rondas.ogg) y avatares
- ✅ Votación de líder con timer de 10 segundos
- ✅ Selección de equipo por el líder
- ✅ Votación de equipo con cartas
- ✅ Votación de misión (éxito/sabotaje)
- ✅ Componente VotingTimer funcionando
- ✅ Animaciones con Framer Motion
- ✅ Diseño responsive con TailwindCSS
### ❌ Pendiente (Solo UI)
- ❌ Pantalla MISSION_REVEAL (mostrar cartas una a una)
- ❌ Pantalla MISSION_RESULT (resumen visual)
- ❌ Histórico de misiones en esquina
### 🐛 Problemas Conocidos
- El servidor puede consumir mucha CPU (reiniciar si ocurre)
- El juego se queda en MISSION_REVEAL al completar una misión (falta UI)
### 📦 Tecnologías
- **Frontend**: Next.js 14, React, TypeScript, Framer Motion, TailwindCSS
- **Backend**: Node.js, Express, Socket.IO, TypeScript
- **Base de Datos**: PostgreSQL 15
- **Containerización**: Docker, Docker Compose
### 🚀 Cómo Usar Este Tag
```bash
# Volver a esta versión
git checkout v0.1.0-functional-until-mission
# Ver diferencias con la versión actual
git diff v0.1.0-functional-until-mission HEAD
# Listar todos los tags
git tag -l
```
### 📝 Commits en Esta Versión
- `8d423ac` - Estado inicial con errores de sintaxis
- `44d7418` - GameBoard limpio y funcional
- `5bb1b17` - VotingTimer agregado correctamente
- `98768fb` - README con documentación completa
- `63b9766` - Fix: Eliminados backticks de markdown
### 🎯 Próximos Pasos
1. Implementar UI para MISSION_REVEAL
2. Implementar UI para MISSION_RESULT
3. Agregar histórico visual de misiones
4. Optimizar rendimiento del servidor
5. Agregar tests unitarios

View File

@@ -2,6 +2,8 @@ import { useState, useEffect } from 'react';
import { motion, AnimatePresence } from 'framer-motion'; import { motion, AnimatePresence } from 'framer-motion';
import Image from 'next/image'; import Image from 'next/image';
import { GameState, GamePhase, Player, GAME_CONFIG } from '../../../shared/types'; import { GameState, GamePhase, Player, GAME_CONFIG } from '../../../shared/types';
import MissionReveal from './MissionReveal';
import MissionResult from './MissionResult';
interface GameBoardProps { interface GameBoardProps {
gameState: GameState; gameState: GameState;
@@ -15,6 +17,13 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
// Hooks para FASE REVEAL ROLE // Hooks para FASE REVEAL ROLE
const [revealCard, setRevealCard] = useState(false); const [revealCard, setRevealCard] = useState(false);
// Orden aleatorio de cartas de misión (se genera una vez)
const [cardOrder] = useState(() => Math.random() > 0.5);
// Track del voto de misión del jugador
const [missionVote, setMissionVote] = useState<boolean | null>(null);
// Timer para avanzar automáticamente en REVEAL_ROLE // Timer para avanzar automáticamente en REVEAL_ROLE
useEffect(() => { useEffect(() => {
if (gameState.phase === 'reveal_role' as any) { if (gameState.phase === 'reveal_role' as any) {
@@ -25,8 +34,16 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
} }
}, [gameState.phase, actions]); }, [gameState.phase, actions]);
// Reset missionVote cuando cambia la fase
useEffect(() => {
if (gameState.phase !== GamePhase.MISSION) {
setMissionVote(null);
}
}, [gameState.phase]);
const currentPlayer = gameState.players.find(p => p.id === currentPlayerId); const currentPlayer = gameState.players.find(p => p.id === currentPlayerId);
const isLeader = currentPlayer?.isLeader; const isLeader = gameState.currentLeaderId === currentPlayerId; // FIX: Usar currentLeaderId del estado
const config = GAME_CONFIG[gameState.players.length as keyof typeof GAME_CONFIG]; const config = GAME_CONFIG[gameState.players.length as keyof typeof GAME_CONFIG];
const currentQuestSize = config?.quests[gameState.currentRound - 1]; const currentQuestSize = config?.quests[gameState.currentRound - 1];
@@ -41,6 +58,12 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
} }
}; };
const handleMissionVote = (vote: boolean) => {
setMissionVote(vote);
actions.voteMission(vote);
};
// Coordenadas porcentuales de los hexágonos de misión en el mapa // Coordenadas porcentuales de los hexágonos de misión en el mapa
const missionCoords = [ const missionCoords = [
{ left: '12%', top: '55%' }, // Misión 1 { left: '12%', top: '55%' }, // Misión 1
@@ -370,24 +393,56 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
initial={{ opacity: 0, y: 20 }} initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }} animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -20 }} exit={{ opacity: 0, y: -20 }}
className="bg-paper-bg text-black p-6 rounded shadow-2xl rotate-1 max-w-md w-full text-center" className="flex flex-col items-center gap-6 w-full max-w-4xl"
> >
<h2 className="text-2xl font-bold font-mono mb-2 uppercase text-resistance-blue"> {/* Información del líder */}
{isLeader ? 'TU TURNO: ELIGE EQUIPO' : `ESPERANDO AL LÍDER...`} <div className="bg-yellow-600/90 text-black p-4 rounded-lg shadow-xl border-4 border-yellow-400 w-full text-center">
</h2> <div className="flex items-center justify-center gap-3">
<p className="mb-4 font-serif italic text-gray-700"> <Image src="/assets/images/tokens/token_leader.png" alt="Leader" width={40} height={40} />
Se necesitan <span className="font-bold text-red-700">{currentQuestSize} agentes</span> para esta misión. <div>
</p> <div className="text-sm uppercase tracking-wider font-bold">Líder Actual</div>
<div className="text-2xl font-bold">
{gameState.players.find(p => p.id === gameState.currentLeaderId)?.name || 'Desconocido'}
</div>
</div>
<Image src="/assets/images/tokens/token_leader.png" alt="Leader" width={40} height={40} />
</div>
</div>
{isLeader && ( {/* Mensaje para el líder o para los demás */}
<button <div className="bg-paper-bg text-black p-6 rounded shadow-2xl rotate-1 w-full text-center">
onClick={() => actions.proposeTeam(selectedTeam)} <h2 className="text-2xl font-bold font-mono mb-2 uppercase text-resistance-blue">
disabled={selectedTeam.length !== currentQuestSize} {isLeader ? '🎯 TU TURNO: ELIGE TU EQUIPO' : '⏳ ESPERANDO AL LÍDER...'}
className="w-full bg-resistance-blue text-white font-bold py-3 px-4 rounded hover:bg-blue-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed uppercase tracking-widest" </h2>
> <p className="mb-4 font-serif italic text-gray-700">
Proponer Equipo Se necesitan <span className="font-bold text-red-700 text-xl">{currentQuestSize} agentes</span> para la misión #{gameState.currentRound}.
</button> </p>
)}
{/* Contador de seleccionados */}
{isLeader && (
<div className="mb-4 text-lg font-bold">
Seleccionados: <span className={selectedTeam.length === currentQuestSize ? 'text-green-600' : 'text-orange-600'}>
{selectedTeam.length} / {currentQuestSize}
</span>
</div>
)}
{isLeader && (
<button
onClick={() => actions.proposeTeam(selectedTeam)}
disabled={selectedTeam.length !== currentQuestSize}
className="w-full bg-resistance-blue text-white font-bold py-3 px-4 rounded hover:bg-blue-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed uppercase tracking-widest shadow-lg"
>
{selectedTeam.length === currentQuestSize ? '✓ CONFIRMAR EQUIPO' : `Selecciona ${currentQuestSize - selectedTeam.length} más`}
</button>
)}
{!isLeader && (
<div className="text-gray-600 animate-pulse">
El líder está seleccionando el equipo de misión...
</div>
)}
</div>
</motion.div> </motion.div>
)} )}
@@ -431,6 +486,7 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
) : ( ) : (
<div className="text-white text-xl font-mono animate-pulse"> <div className="text-white text-xl font-mono animate-pulse">
VOTO REGISTRADO. ESPERANDO AL RESTO... VOTO REGISTRADO. ESPERANDO AL RESTO...
```
</div> </div>
)} )}
</motion.div> </motion.div>
@@ -438,33 +494,102 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
{/* FASE: MISIÓN */} {/* FASE: MISIÓN */}
{gameState.phase === GamePhase.MISSION && ( {gameState.phase === GamePhase.MISSION && (
<motion.div key="mission" className="text-center"> <motion.div
key="mission"
className="fixed inset-0 flex items-center justify-center bg-black/90 z-50"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
{gameState.proposedTeam.includes(currentPlayerId) ? ( {gameState.proposedTeam.includes(currentPlayerId) ? (
<div className="flex flex-col items-center gap-6"> <div className="flex flex-col items-center gap-8 w-full max-w-6xl px-4">
<h2 className="text-3xl font-bold text-white mb-4 drop-shadow-lg">¡ESTÁS EN LA MISIÓN!</h2> <h2 className="text-4xl md:text-5xl font-bold text-white mb-4 drop-shadow-2xl text-center uppercase tracking-wider animate-pulse">
<div className="flex gap-8"> 🎯 ¡ESTÁS EN LA MISIÓN!
<button onClick={() => actions.voteMission(true)} className="group"> </h2>
<div className="w-40 h-60 bg-blue-900 rounded-lg shadow-2xl border-2 border-blue-400 flex flex-col items-center justify-center p-4 transform transition-transform hover:scale-105"> <p className="text-white text-xl mb-4 text-center">
<Image src="/assets/images/tokens/mission_success.png" alt="Success" width={120} height={120} /> Elige el resultado de tu participación
<span className="mt-4 text-blue-200 font-bold tracking-widest">ÉXITO</span> </p>
</div>
</button>
{/* Solo los malos pueden sabotear */} {/* DEBUG INFO - TEMPORAL */}
{currentPlayer?.faction === 'spies' && ( <div className="text-xs text-gray-400 bg-black/50 p-2 rounded mb-4">
<button onClick={() => actions.voteMission(false)} className="group"> Debug: Tu ID: {currentPlayerId} | Equipo: [{gameState.proposedTeam.join(', ')}]
<div className="w-40 h-60 bg-red-900 rounded-lg shadow-2xl border-2 border-red-400 flex flex-col items-center justify-center p-4 transform transition-transform hover:scale-105"> <br />
<Image src="/assets/images/tokens/mission_fail.png" alt="Fail" width={120} height={120} /> Tu facción: {currentPlayer?.faction || 'UNDEFINED'} | Rol: {currentPlayer?.role || 'UNDEFINED'}
<span className="mt-4 text-red-200 font-bold tracking-widest">SABOTAJE</span> </div>
</div>
</button> {/* Cartas en orden aleatorio */}
<div className="flex gap-12 flex-wrap justify-center">
{cardOrder ? (
<>
{/* Carta de Éxito primero */}
<button
onClick={() => handleMissionVote(true)}
className={`group transition-opacity ${missionVote !== null && missionVote !== true ? 'opacity-50' : 'opacity-100'}`}
disabled={missionVote !== null}
>
<motion.div
className="w-64 h-96 bg-gradient-to-br from-blue-600 to-blue-900 rounded-2xl shadow-2xl border-4 border-blue-400 flex flex-col items-center justify-center p-6 transform transition-all hover:scale-110 hover:rotate-3 hover:shadow-blue-500/50"
whileHover={{ scale: 1.1, rotate: 3 }}
whileTap={{ scale: 0.95 }}
>
<Image src="/assets/images/tokens/vote_approve.png" alt="Success" width={180} height={180} className="drop-shadow-2xl" />
<span className="mt-6 text-white font-bold text-2xl tracking-widest uppercase">ÉXITO</span>
</motion.div>
</button>
{/* Carta de Sabotaje segundo (solo para espías) */}
{currentPlayer?.faction === 'spies' && (
<button onClick={() => handleMissionVote(false)} className="group transition-opacity" style={{ opacity: missionVote !== null && missionVote !== false ? 0.5 : 1 }} disabled={missionVote !== null}>
<motion.div
className="w-64 h-96 bg-gradient-to-br from-red-600 to-red-900 rounded-2xl shadow-2xl border-4 border-red-400 flex flex-col items-center justify-center p-6 transform transition-all hover:scale-110 hover:-rotate-3 hover:shadow-red-500/50"
whileHover={{ scale: 1.1, rotate: -3 }}
whileTap={{ scale: 0.95 }}
>
<Image src="/assets/images/tokens/vote_reject.png" alt="Fail" width={180} height={180} className="drop-shadow-2xl" />
<span className="mt-6 text-white font-bold text-2xl tracking-widest uppercase">SABOTAJE</span>
</motion.div>
</button>
)}
</>
) : (
<>
{/* Carta de Sabotaje primero (solo para espías) */}
{currentPlayer?.faction === 'spies' && (
<button onClick={() => handleMissionVote(false)} className="group transition-opacity" style={{ opacity: missionVote !== null && missionVote !== false ? 0.5 : 1 }} disabled={missionVote !== null}>
<motion.div
className="w-64 h-96 bg-gradient-to-br from-red-600 to-red-900 rounded-2xl shadow-2xl border-4 border-red-400 flex flex-col items-center justify-center p-6 transform transition-all hover:scale-110 hover:-rotate-3 hover:shadow-red-500/50"
whileHover={{ scale: 1.1, rotate: -3 }}
whileTap={{ scale: 0.95 }}
>
<Image src="/assets/images/tokens/vote_reject.png" alt="Fail" width={180} height={180} className="drop-shadow-2xl" />
<span className="mt-6 text-white font-bold text-2xl tracking-widest uppercase">SABOTAJE</span>
</motion.div>
</button>
)}
{/* Carta de Éxito segundo */}
<button
onClick={() => handleMissionVote(true)}
className={`group transition-opacity ${missionVote !== null && missionVote !== true ? 'opacity-50' : 'opacity-100'}`}
disabled={missionVote !== null}
>
<motion.div
className="w-64 h-96 bg-gradient-to-br from-blue-600 to-blue-900 rounded-2xl shadow-2xl border-4 border-blue-400 flex flex-col items-center justify-center p-6 transform transition-all hover:scale-110 hover:rotate-3 hover:shadow-blue-500/50"
whileHover={{ scale: 1.1, rotate: 3 }}
whileTap={{ scale: 0.95 }}
>
<Image src="/assets/images/tokens/vote_approve.png" alt="Success" width={180} height={180} className="drop-shadow-2xl" />
<span className="mt-6 text-white font-bold text-2xl tracking-widest uppercase">ÉXITO</span>
</motion.div>
</button>
</>
)} )}
</div> </div>
</div> </div>
) : ( ) : (
<div className="text-white text-2xl font-mono bg-black/50 p-6 rounded"> <div className="text-white text-3xl font-mono bg-black/70 p-8 rounded-xl border-2 border-white/20 text-center">
<div className="animate-pulse mb-4 text-5xl">⏳</div>
La misión está en curso...<br /> La misión está en curso...<br />
<span className="text-sm text-gray-400">Rezando por el éxito.</span> <span className="text-lg text-gray-400 mt-2 block">Esperando a que el equipo complete su votación.</span>
</div> </div>
)} )}
</motion.div> </motion.div>
@@ -474,7 +599,6 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
{gameState.phase === 'mission_reveal' as any && ( {gameState.phase === 'mission_reveal' as any && (
<MissionReveal <MissionReveal
votes={gameState.revealedVotes || []} votes={gameState.revealedVotes || []}
onComplete={() => isHost && actions.finishMissionReveal()}
/> />
)} )}
@@ -512,7 +636,7 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
<div className={` <div className={`
w-16 h-16 rounded-full border-2 overflow-hidden relative shadow-lg bg-black w-16 h-16 rounded-full border-2 overflow-hidden relative shadow-lg bg-black
${isSelected ? 'border-yellow-400 ring-4 ring-yellow-400/30' : 'border-gray-400'} ${isSelected ? 'border-yellow-400 ring-4 ring-yellow-400/30' : 'border-gray-400'}
${player.isLeader ? 'ring-2 ring-white' : ''} ${gameState.currentLeaderId === player.id ? 'ring-2 ring-white' : ''}
`}> `}>
<Image <Image
src={avatarSrc} src={avatarSrc}
@@ -522,11 +646,23 @@ export default function GameBoard({ gameState, currentPlayerId, actions }: GameB
/> />
{/* Icono de Líder */} {/* Icono de Líder */}
{player.isLeader && ( {gameState.currentLeaderId === player.id && (
<div className="absolute bottom-0 right-0 bg-yellow-500 rounded-full p-1 w-6 h-6 flex items-center justify-center text-xs text-black font-bold border border-white z-10"> <div className="absolute bottom-0 right-0 bg-yellow-500 rounded-full p-1 w-6 h-6 flex items-center justify-center text-xs text-black font-bold border border-white z-10">
L L
</div> </div>
)} )}
{/* Icono de Miembro del Equipo de Misión */}
{gameState.proposedTeam.includes(player.id) && (
gameState.phase === GamePhase.VOTING_TEAM ||
gameState.phase === GamePhase.MISSION ||
gameState.phase === 'mission_reveal' as any ||
gameState.phase === 'mission_result' as any
) && (
<div className="absolute top-0 left-0 bg-green-500 rounded-full p-1 w-6 h-6 flex items-center justify-center text-xs text-white font-bold border border-white z-10">
</div>
)}
</div> </div>
{/* Nombre */} {/* Nombre */}

View File

@@ -0,0 +1,74 @@
import { motion } from 'framer-motion';
import { GameState } from '../../../shared/types';
interface MissionResultProps {
gameState: GameState;
onContinue: () => void;
}
export default function MissionResult({ gameState, onContinue }: MissionResultProps) {
// Obtener la última misión del historial
const lastMission = gameState.missionHistory[gameState.missionHistory.length - 1];
if (!lastMission) {
return (
<div className="fixed inset-0 flex items-center justify-center bg-black/90 z-50">
<p className="text-white text-2xl">Cargando resultado...</p>
</div>
);
}
const { successes, fails, isSuccess } = lastMission;
return (
<motion.div
className="fixed inset-0 flex flex-col items-center justify-center bg-black/90 z-50"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<motion.h2
className={`text - 6xl md: text - 7xl font - bold mb - 8 ${ isSuccess ? 'text-blue-500' : 'text-red-500' } `}
initial={{ scale: 0 }}
animate={{ scale: 1 }}
transition={{ type: 'spring', stiffness: 200, delay: 0.2 }}
>
{isSuccess ? '¡MISIÓN EXITOSA!' : 'MISIÓN FALLIDA'}
</motion.h2>
<motion.div
className="text-white text-3xl mb-8 bg-black/50 p-6 rounded-xl"
initial={{ y: 50, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
transition={{ delay: 0.5 }}
>
<p className="mb-2"> Éxitos: <span className="text-blue-400 font-bold">{successes}</span></p>
<p> Sabotajes: <span className="text-red-400 font-bold">{fails}</span></p>
</motion.div>
<motion.div
className="text-white text-xl mb-8"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ delay: 1 }}
>
<p>Misión {gameState.currentRound} de 5</p>
<p className="text-gray-400 text-sm mt-2">
Resistencia: {gameState.missionHistory.filter(m => m.isSuccess).length} |
Espías: {gameState.missionHistory.filter(m => !m.isSuccess).length}
</p>
</motion.div>
<motion.button
onClick={onContinue}
className="bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700 text-white font-bold py-4 px-8 rounded-lg text-xl shadow-lg transform transition-all hover:scale-105"
initial={{ y: 50, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
transition={{ delay: 1.5 }}
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
>
CONTINUAR
</motion.button>
</motion.div>
);
}

View File

@@ -0,0 +1,44 @@
import { motion } from 'framer-motion';
import { useEffect } from 'react';
interface MissionRevealProps {
votes: boolean[];
}
export default function MissionReveal({ votes }: MissionRevealProps) {
// Auto-avanzar después de mostrar todas las cartas
useEffect(() => {
const timer = setTimeout(() => {
// El servidor avanzará automáticamente
// Este timer es solo para dar tiempo a ver las cartas
}, 3000 + votes.length * 300); // 3s base + 300ms por carta
return () => clearTimeout(timer);
}, [votes.length]);
return (
<motion.div
className="fixed inset-0 flex flex-col items-center justify-center bg-black/90 z-50"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<h2 className="text-4xl font-bold text-white mb-8">Resultados de la Misión</h2>
<div className="flex gap-4 justify-center mb-8">
{votes.map((vote, idx) => (
<motion.div
key={idx}
className={`w - 24 h - 32 rounded - lg flex items - center justify - center text - 5xl font - bold text - white ${
vote ? 'bg-blue-600' : 'bg-red-600'
} `}
initial={{ scale: 0, rotate: -180 }}
animate={{ scale: 1, rotate: 0 }}
transition={{ delay: idx * 0.3 }}
>
{vote ? '✓' : '✗'}
</motion.div>
))}
</div>
<p className="text-white text-xl">Procesando resultado...</p>
</motion.div>
);
}

View File

@@ -154,9 +154,10 @@ export class Game {
if (playerIds.length !== requiredSize) return false; if (playerIds.length !== requiredSize) return false;
this.state.proposedTeam = playerIds; this.state.proposedTeam = playerIds;
this.state.phase = GamePhase.VOTING_TEAM; this.state.phase = GamePhase.MISSION; // Ir directamente a la misión
this.state.teamVotes = {}; // Resetear votos this.state.missionVotes = []; // Resetear votos de misión
this.log(`El líder ha propuesto un equipo de ${playerIds.length} personas.`); this.state.failedVotesCount = 0; // Reset contador de rechazos
this.log(`El líder ha seleccionado un equipo de ${playerIds.length} personas. ¡Comienza la misión!`);
return true; return true;
} }
@@ -242,8 +243,14 @@ export class Game {
this.state.revealedVotes = shuffledVotes; // Las cartas a revelar this.state.revealedVotes = shuffledVotes; // Las cartas a revelar
this.log(`Misión ${round} completada. Revelando votos...`); this.log(`Misión ${round} completada. Revelando votos...`);
// Auto-avanzar a MISSION_RESULT después de 5 segundos
setTimeout(() => {
this.finishReveal();
}, 5000);
} }
// Método para avanzar desde MISSION_REVEAL a MISSION_RESULT // Método para avanzar desde MISSION_REVEAL a MISSION_RESULT
finishReveal() { finishReveal() {
this.state.phase = GamePhase.MISSION_RESULT; this.state.phase = GamePhase.MISSION_RESULT;