Checkpoint before line-grid scrolling refactor
This commit is contained in:
Vendored
-46
@@ -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}`);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
-11
@@ -167,17 +167,6 @@ io.on('connection', (socket) => {
|
||||
}
|
||||
}
|
||||
});
|
||||
// Start a new game
|
||||
socket.on('startGame', async () => {
|
||||
try {
|
||||
console.log('Starting test game session');
|
||||
startDemoGame();
|
||||
}
|
||||
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 {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user