Checkpoint before line-grid scrolling refactor

This commit is contained in:
2026-05-16 13:44:03 +02:00
parent 42582352d6
commit fe33e4f0ab
25 changed files with 1989 additions and 840 deletions
-46
View File
@@ -188,16 +188,6 @@ io.on('connection', (socket) => {
}
}
});
// Start a new game
socket.on('startGame', async () => {
try {
await handleGameApi(socket, 'newGame', []);
}
catch (error) {
console.error('Error starting game:', error);
socket.emit('error', { message: 'Failed to start game. Please try again.' });
}
});
// Process player command
socket.on('playerCommand', async (data) => {
try {
@@ -218,42 +208,6 @@ io.on('connection', (socket) => {
socket.emit('error', { message: 'Failed to process command. Please try again.' });
}
});
// Save game state
socket.on('saveGame', () => {
try {
const gameRunner = gameSessions.get(socket.id);
if (!gameRunner) {
socket.emit('error', { message: 'Game session not found. Please start a new game.' });
return;
}
socket.data.saveGames.set(1, gameRunner.getGameState());
socket.emit('gameSaved');
}
catch (error) {
console.error('Error saving game:', error);
socket.emit('error', { message: 'Failed to save game. Please try again.' });
}
});
// Load game state
socket.on('loadGame', async () => {
try {
const gameRunner = gameSessions.get(socket.id);
if (!gameRunner) {
socket.emit('error', { message: 'Game session not found. Please start a new game.' });
return;
}
// Check if there's a saved game
if (!socket.data.saveGames?.has(1)) {
socket.emit('error', { message: 'No saved game found.' });
return;
}
await handleGameApi(socket, 'loadGame', [1]);
}
catch (error) {
console.error('Error loading game:', error);
socket.emit('error', { message: 'Failed to load game. Please try again.' });
}
});
// Handle disconnection
socket.on('disconnect', () => {
console.log(`Client disconnected: ${socket.id}`);