Feat: Hybrid Architecture Phase 1

- Implemented Game Server (game-server.js) with Socket.io
- Added JSON Schemas for Campaigns and Missions
- Updated Docker configurations for multi-service setup
- Refactored main.js to allow local network connections
- Removed legacy code (main_old.js)
- Updated dependencies
This commit is contained in:
2025-12-28 20:44:40 +01:00
parent 57f6312a5a
commit b6ca14dfa2
10 changed files with 2309 additions and 721 deletions

View File

@@ -1,6 +1,50 @@
import './style.css';
import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import { io } from "socket.io-client";
// --- NETWORK SETUP ---
// Dynamic connection to support playing from mobile on the same network
const socketUrl = `http://${window.location.hostname}:3001`;
const socket = io(socketUrl);
let lobbyCode = null;
socket.on("connect", () => {
console.log("Connected to Game Server!", socket.id);
socket.emit("HOST_GAME");
});
socket.on("LOBBY_CREATED", ({ code }) => {
console.log("GAME HOSTED. LOBBY CODE:", code);
lobbyCode = code;
// Temporary UI for Lobby Code
const codeDisplay = document.createElement('div');
codeDisplay.style.position = 'absolute';
codeDisplay.style.top = '10px';
codeDisplay.style.right = '10px';
codeDisplay.style.color = 'gold';
codeDisplay.style.fontFamily = 'monospace';
codeDisplay.style.fontSize = '24px';
codeDisplay.style.fontWeight = 'bold';
codeDisplay.style.background = 'rgba(0,0,0,0.5)';
codeDisplay.style.padding = '10px';
codeDisplay.innerText = `LOBBY: ${code}`;
document.body.appendChild(codeDisplay);
});
socket.on("PLAYER_JOINED", ({ name }) => {
console.log(`Player ${name} has joined!`);
// TODO: Show notification
});
socket.on("PLAYER_ACTION", ({ playerId, action, data }) => {
console.log(`Action received from ${playerId}: ${action}`, data);
// Placeholder interaction
if (action === 'MOVE') {
// Example: data = { x: 1, y: 0 }
// Implement logic here
}
});
// --- CONFIGURACIÓN DE LA ESCENA ---
const CONFIG = {