Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b68f4e9ff5 | ||
|
|
800db837bb | ||
|
|
69e1f35886 |
20
.env.example
20
.env.example
@@ -1,13 +1,25 @@
|
||||
# ===========================================
|
||||
# Archivo de ejemplo de configuración
|
||||
# Copia este archivo a .env y modifica los valores
|
||||
# ===========================================
|
||||
|
||||
# Configuración de red local
|
||||
# Cambia esta IP a la IP de tu PC en la red local
|
||||
HOST_IP=192.168.1.131
|
||||
HOST_IP=192.168.1.XXX
|
||||
|
||||
# URLs para desarrollo local
|
||||
NEXT_PUBLIC_API_URL=http://192.168.1.131:4000
|
||||
CORS_ORIGIN=http://192.168.1.131:3000
|
||||
NEXT_PUBLIC_API_URL=http://192.168.1.XXX:4000
|
||||
CORS_ORIGIN=http://192.168.1.XXX:3000
|
||||
|
||||
# URLs para producción (descomentar y ajustar)
|
||||
# NEXT_PUBLIC_API_URL=https://api.tudominio.com
|
||||
# CORS_ORIGIN=https://tudominio.com
|
||||
|
||||
# Configuración de base de datos
|
||||
DATABASE_URL=postgresql://postgres:password@db:5432/resistencia
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=password
|
||||
POSTGRES_PASSWORD=cambia_esta_contraseña
|
||||
POSTGRES_DB=resistencia
|
||||
|
||||
# Contraseña del dashboard de administración
|
||||
NEXT_PUBLIC_ADMIN_PASSWORD=cambia_esta_contraseña
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
FROM node:20-alpine
|
||||
|
||||
# Build argument for API URL
|
||||
# Build arguments
|
||||
ARG NEXT_PUBLIC_API_URL=http://localhost:4000
|
||||
ARG NEXT_PUBLIC_ADMIN_PASSWORD=admin123
|
||||
|
||||
# Make args available as env vars during build
|
||||
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
||||
ENV NEXT_PUBLIC_ADMIN_PASSWORD=$NEXT_PUBLIC_ADMIN_PASSWORD
|
||||
|
||||
# Create app directory
|
||||
WORKDIR /app
|
||||
|
||||
@@ -5,7 +5,7 @@ import { motion, AnimatePresence } from 'framer-motion';
|
||||
import { useSocket } from '../../hooks/useSocket';
|
||||
import { Shield, Users, Gamepad2, LogOut, Clock, History, UserMinus, Key, ChevronDown } from 'lucide-react';
|
||||
|
||||
const ADMIN_PASSWORD = "admin123";
|
||||
const ADMIN_PASSWORD = process.env.NEXT_PUBLIC_ADMIN_PASSWORD || "admin123";
|
||||
|
||||
export default function Dashboard() {
|
||||
const { socket, isConnected } = useSocket();
|
||||
|
||||
@@ -7,6 +7,7 @@ services:
|
||||
dockerfile: client/Dockerfile
|
||||
args:
|
||||
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-https://api.franciaocupada.martivich.es}
|
||||
- NEXT_PUBLIC_ADMIN_PASSWORD=${NEXT_PUBLIC_ADMIN_PASSWORD:-admin123}
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
@@ -15,6 +16,7 @@ services:
|
||||
- /app/client/node_modules
|
||||
environment:
|
||||
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-https://api.franciaocupada.martivich.es}
|
||||
- NEXT_PUBLIC_ADMIN_PASSWORD=${NEXT_PUBLIC_ADMIN_PASSWORD:-admin123}
|
||||
depends_on:
|
||||
- server
|
||||
networks:
|
||||
|
||||
@@ -405,8 +405,8 @@ io.on('connection', (socket) => {
|
||||
const existingPlayer = game.state.players.find(p => p.name === playerName);
|
||||
|
||||
if (existingPlayer) {
|
||||
// Actualizar el socket ID del jugador
|
||||
existingPlayer.id = socket.id;
|
||||
// Actualizar el socket ID del jugador y referencias
|
||||
game.updatePlayerSocket(existingPlayer.id, socket.id);
|
||||
|
||||
// Unir al socket a la sala
|
||||
socket.join(roomId);
|
||||
|
||||
@@ -415,4 +415,44 @@ export class Game {
|
||||
// Mantener solo los últimos 50 mensajes
|
||||
if (this.state.history.length > 50) this.state.history.shift();
|
||||
}
|
||||
|
||||
updatePlayerSocket(oldId: string, newId: string) {
|
||||
const player = this.state.players.find(p => p.id === oldId);
|
||||
if (!player) return;
|
||||
|
||||
// Actualizar ID del jugador
|
||||
player.id = newId;
|
||||
|
||||
// Actualizar referencias en el estado
|
||||
|
||||
// 1. Host
|
||||
if (this.hostId === oldId) {
|
||||
this.hostId = newId;
|
||||
this.state.hostId = newId;
|
||||
}
|
||||
|
||||
// 2. Líder actual
|
||||
if (this.state.currentLeaderId === oldId) {
|
||||
this.state.currentLeaderId = newId;
|
||||
}
|
||||
|
||||
// 3. Votos de Líder (leaderVotes)
|
||||
if (this.state.leaderVotes && this.state.leaderVotes[oldId] !== undefined) {
|
||||
this.state.leaderVotes[newId] = this.state.leaderVotes[oldId];
|
||||
delete this.state.leaderVotes[oldId];
|
||||
}
|
||||
|
||||
// 4. Votos de Equipo (teamVotes)
|
||||
if (this.state.teamVotes && this.state.teamVotes[oldId] !== undefined) {
|
||||
this.state.teamVotes[newId] = this.state.teamVotes[oldId];
|
||||
delete this.state.teamVotes[oldId];
|
||||
}
|
||||
|
||||
// 5. Equipo Propuesto (proposedTeam)
|
||||
if (this.state.proposedTeam && this.state.proposedTeam.includes(oldId)) {
|
||||
this.state.proposedTeam = this.state.proposedTeam.map(id => id === oldId ? newId : id);
|
||||
}
|
||||
|
||||
this.log(`Jugador ${player.name} reconectado. ID actualizado.`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user