mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-11-14 02:53:53 +01:00
ok game is working-ish
This commit is contained in:
@@ -1,181 +0,0 @@
|
||||
# Wowngeon Code Architecture
|
||||
|
||||
## Overview
|
||||
The Wowngeon roguelike game has been refactored into a modular architecture with clear separation of concerns between frontend and backend components. Recent major improvements include fixing critical movement bugs, implementing auto-start functionality, and resolving duplicate event handler issues.
|
||||
|
||||
## Recent Major Bug Fixes and Improvements
|
||||
|
||||
### 🎯 Movement System Overhaul
|
||||
**Problem**: Players were skipping over tiles when moving through hallways, especially when approaching from certain directions.
|
||||
|
||||
**Root Cause**: Double event handler registration caused duplicate keydown events, leading to rapid-fire movement commands.
|
||||
|
||||
**Solution**:
|
||||
- Added `_initialized` flags to prevent multiple initializations of InputHandler and SocketHandlers
|
||||
- Implemented 100ms movement throttling on both client and server sides
|
||||
- Enhanced movement validation and debugging with comprehensive logging
|
||||
- Fixed module initialization order in `index.html`
|
||||
|
||||
**Result**: Players now move exactly one tile per keypress with no skipping.
|
||||
|
||||
### 🚀 Auto-Start System Implementation
|
||||
**Problem**: Game was hanging on "waiting for server..." screen instead of starting immediately for testing.
|
||||
|
||||
**Root Cause**: Missing `SocketHandlers.init()` call in `index.html` meant client couldn't receive `game_start` events.
|
||||
|
||||
**Solution**:
|
||||
- Added proper SocketHandlers initialization to HTML document ready function
|
||||
- Implemented auto-start that sends "enter" command 500ms after connection
|
||||
- Enhanced server-side auto-start to immediately begin games in DEBUG_MODE
|
||||
- Improved error handling and connection flow
|
||||
|
||||
**Result**: Games now start instantly for faster development and testing.
|
||||
|
||||
### 🔧 Code Architecture Improvements
|
||||
**Problem**: Monolithic code structure made debugging and maintenance difficult.
|
||||
|
||||
**Solution**:
|
||||
- Split frontend JavaScript into focused modules (ui.js, socketHandlers.js, inputHandler.js)
|
||||
- Added initialization protection to prevent duplicate module setup
|
||||
- Enhanced logging with emojis and timing information for easier debugging
|
||||
- Maintained backward compatibility while improving code organization
|
||||
|
||||
**Result**: Much cleaner, more maintainable codebase with improved debugging capabilities.
|
||||
|
||||
## Backend Architecture
|
||||
|
||||
### Core Classes
|
||||
|
||||
#### `Player` (/player.js)
|
||||
- Manages player state and position
|
||||
- Methods: `moveTo()`, `isAt()`, `getState()`, `setState()`, `reset()`
|
||||
- Properties: x, y, hasKey, hasTreasure
|
||||
|
||||
#### `Monster` (/monster.js)
|
||||
- Manages monster state and AI behavior
|
||||
- Methods: `moveTowardPlayer()`, `hasCaughtPlayer()`, `getState()`, `setState()`
|
||||
- AI Features: Smart pathfinding toward player, collision detection
|
||||
|
||||
#### `DungeonGenerator` (/dungeon.js)
|
||||
- Handles procedural dungeon generation using ROT.js
|
||||
- Methods: `generate()`, `getRandomRoomCenter()`, `isFloorTile()`, `isWallTile()`
|
||||
- Features: Room placement, entrance/exit/treasure positioning
|
||||
|
||||
#### `Game` (/game.js)
|
||||
- Main game logic coordinator
|
||||
- Uses Player, Monster, and DungeonGenerator classes
|
||||
- Manages game state, FOV calculation, and entity interactions
|
||||
- Methods: `movePlayer()`, `moveMonster()`, `getState()`, `updateFOV()`
|
||||
|
||||
### Supporting Files *(ENHANCED)*
|
||||
- `user.js` - User management and game instantiation with improved socket ID mapping
|
||||
- `index.js` - Server entry point with movement throttling, auto-start, and enhanced debugging
|
||||
- `dbcalls.js` - Database operations
|
||||
- `rpccalls.js` - Wownero blockchain integration
|
||||
|
||||
## Frontend Architecture
|
||||
|
||||
### Modular JavaScript Components
|
||||
|
||||
#### `ui.js`
|
||||
- UI utilities and visual helpers
|
||||
- Functions: `scrollChat()`, `updateBlockHeight()`, `updateFocusIndicator()`
|
||||
- Manages teletype animations and browser detection
|
||||
|
||||
#### `socketHandlers.js` *(MAJOR UPDATES)*
|
||||
- All WebSocket event handlers with initialization protection
|
||||
- Events: connect, game_start, game_update, game_over, etc.
|
||||
- **NEW**: Auto-start functionality for testing (sends "enter" after 500ms)
|
||||
- **NEW**: `_initialized` flag prevents duplicate handler registration
|
||||
- **FIXED**: Proper initialization order ensures events are received
|
||||
- Clean separation of network communication logic
|
||||
|
||||
#### `inputHandler.js` *(MAJOR UPDATES)*
|
||||
- Keyboard and form input management with movement throttling
|
||||
- **NEW**: 100ms movement cooldown prevents rapid-fire commands
|
||||
- **NEW**: `_pendingMove` system prevents movement overlap
|
||||
- **FIXED**: Duplicate event handler prevention
|
||||
- Handles WASD/arrow key movement, chat input, focus management
|
||||
- Enhanced debugging with movement timing logs
|
||||
|
||||
#### `ui.js`
|
||||
- UI utilities and visual helpers
|
||||
- Functions: `scrollChat()`, `updateBlockHeight()`, `updateFocusIndicator()`
|
||||
- Manages teletype animations and browser detection
|
||||
|
||||
#### `game.js` (frontend)
|
||||
- Core game rendering and client-side state management
|
||||
- ROT.js display integration, FOV rendering, entity drawing
|
||||
- Maintained original structure for compatibility
|
||||
|
||||
### HTML Structure *(UPDATED)*
|
||||
- `index.html` - Streamlined main page with proper module initialization order
|
||||
- **FIXED**: Added missing `SocketHandlers.init()` call to prevent auto-start hanging
|
||||
- **IMPROVED**: Clean document ready structure ensures proper initialization sequence
|
||||
- `index_original.html` - Backup of original monolithic structure
|
||||
|
||||
## Key Improvements
|
||||
|
||||
### Backend Benefits
|
||||
1. **Modularity**: Clear separation of Player, Monster, and Dungeon logic
|
||||
2. **Maintainability**: Each class has single responsibility
|
||||
3. **Testability**: Individual components can be unit tested
|
||||
4. **Extensibility**: Easy to add new entity types or game mechanics
|
||||
5. **Movement Validation**: Server-side throttling and validation prevents cheating
|
||||
6. **Debug Capabilities**: Comprehensive logging for troubleshooting
|
||||
|
||||
### Frontend Benefits
|
||||
1. **Reduced Complexity**: 471-line index.html reduced to ~80 lines
|
||||
2. **Code Organization**: Related functionality grouped into logical modules
|
||||
3. **Reusability**: UI and input handlers can be reused/extended
|
||||
4. **Debugging**: Easier to locate and fix issues in specific modules
|
||||
5. **Movement Reliability**: Throttling prevents duplicate commands and tile skipping
|
||||
6. **Auto-Start Testing**: Instant game start for development and testing
|
||||
|
||||
## File Structure
|
||||
```
|
||||
/wowngeon/
|
||||
├── Backend Classes
|
||||
│ ├── player.js # Player entity and state
|
||||
│ ├── monster.js # Monster AI and behavior
|
||||
│ ├── dungeon.js # Procedural generation
|
||||
│ └── game.js # Main game coordinator
|
||||
├── Backend Support
|
||||
│ ├── index.js # Server and socket handling
|
||||
│ ├── user.js # User management
|
||||
│ └── ...other files
|
||||
└── Frontend
|
||||
├── index.html # Clean modular HTML
|
||||
└── js/
|
||||
├── game.js # Core game rendering
|
||||
├── ui.js # UI utilities
|
||||
├── socketHandlers.js # Network communication
|
||||
├── inputHandler.js # Input management
|
||||
└── ...libraries
|
||||
```
|
||||
|
||||
## Migration Summary *(UPDATED)*
|
||||
- ✅ Backend modularized into Player, Monster, DungeonGenerator classes
|
||||
- ✅ Frontend split into logical modules (UI, Socket, Input handlers)
|
||||
- ✅ **CRITICAL BUG FIXES**: Movement skipping and auto-start hanging resolved
|
||||
- ✅ **MOVEMENT SYSTEM**: Added throttling and duplicate prevention
|
||||
- ✅ **INITIALIZATION**: Fixed module loading order and event handler registration
|
||||
- ✅ **DEBUGGING**: Enhanced logging with emojis and timing information
|
||||
- ✅ Removed unused files and maintained full compatibility
|
||||
- ✅ All game mechanics verified working (movement, FOV, collision, treasure)
|
||||
|
||||
## Testing Verification *(COMPREHENSIVE)*
|
||||
- [x] Server starts without errors
|
||||
- [x] Game initialization works with proper module loading
|
||||
- [x] **NEW**: Auto-start functionality working (500ms delay → instant game start)
|
||||
- [x] **FIXED**: Player movement functional with no tile skipping
|
||||
- [x] **VERIFIED**: Single-tile movement precision confirmed via server logs
|
||||
- [x] Monster AI and collision detection operational
|
||||
- [x] Treasure collection working
|
||||
- [x] **ENHANCED**: Frontend modules load with initialization protection
|
||||
- [x] **CONFIRMED**: All socket events properly handled and received
|
||||
- [x] **TESTED**: Movement throttling prevents rapid-fire commands
|
||||
- [x] **VALIDATED**: Server-side movement validation working correctly
|
||||
|
||||
## Current Status: ✅ MAJOR BUGS RESOLVED
|
||||
The Wowngeon game is now in excellent working condition with all critical movement and initialization bugs fixed. The codebase is much more maintainable and follows modern software engineering practices while preserving all original game functionality.
|
||||
@@ -1,141 +0,0 @@
|
||||
# Wowngeon
|
||||
|
||||
A blockchain-based roguelike dungeon crawler built on the Wownero network.
|
||||
|
||||
## Project Overview
|
||||
|
||||
Wowngeon is a web-based roguelike game that integrates with the Wownero blockchain for a unique gaming experience. Players enter a randomly generated dungeon with the goal of escaping before the next block is discovered on the network. The player requests to enter (and optionally pay an entrance fee), and then waits for the next block to be mined. When the next block is found, the player is placed in the dungeon and must escape before the next block is found. If they fail to escape, they die and lose their entrance fee. There is a singular monster and treasure in the dungeon. If the monster catches the player, they die. If the player finds the treasure and manages to escape, they could win 3x or 5x instead of just 2x for escaping sans treasure. The game is designed to be played in a web browser, making it accessible to a wide audience.
|
||||
The game is built using Node.js for the backend, with Express and Socket.io for real-time communication. The frontend is developed using HTML5, CSS, and JavaScript, with ROT.js for rendering the dungeon and managing game mechanics. The Wownero blockchain is integrated via RPC calls to monitor block height and handle transactions.
|
||||
|
||||
### Key Features:
|
||||
|
||||
- **Blockchain-linked gameplay**: Players enter when one block is found and must escape before the next block (approximately 5 minutes in Wownero)
|
||||
- **Permadeath mechanics**: If a player fails to escape before the next block is found, they die
|
||||
- **Random dungeons**: Each game features procedurally generated maps using ROT.js
|
||||
- **Monster AI**: Evade monster as you navigate the dungeon
|
||||
- **Treasure hunting**: Find treasure for bonus rewards
|
||||
- **Wownero integration**: Players pay an entrance fee (10-100 WOW) and can win rewards
|
||||
- **Chat system**: Players can communicate in real-time during gameplay
|
||||
- **View other players' game states**: Spectate other players' dungeons in real-time
|
||||
|
||||
### Technology Stack:
|
||||
- Backend: Node.js with Express and Socket.io
|
||||
- Frontend: HTML5, CSS, and JavaScript with ROT.js for rendering
|
||||
- Blockchain: Wownero RPC integration for block monitoring and transactions
|
||||
|
||||
## File Structure
|
||||
|
||||
### Server Files
|
||||
|
||||
**index.js**
|
||||
The main server file that handles HTTP requests, WebSocket connections, game lifecycle management, and blockchain monitoring. Coordinates the entire application. Now includes movement throttling, auto-start functionality, and improved socket ID handling.
|
||||
|
||||
**game.js**
|
||||
Contains the Game class and logic for dungeon generation, player movement, monster AI, field-of-view calculations, and game state management. Enhanced with better debugging and state synchronization.
|
||||
|
||||
**user.js**
|
||||
Manages user registration, authentication, game association, and payment tracking. Maintains a registry of all active users with improved socket ID mapping.
|
||||
|
||||
**dbcalls.js**
|
||||
Handles database operations for storing user data, game history, and payment records.
|
||||
|
||||
**rpccalls.js**
|
||||
Contains functions for interacting with the Wownero blockchain via RPC, including checking block height and verifying transactions.
|
||||
|
||||
### Client Files
|
||||
|
||||
**html/index.html**
|
||||
The main HTML file served to clients, containing the structure for the game UI and chat interface. Now includes proper module initialization order to prevent duplicate event handlers.
|
||||
|
||||
**html/js/game.js**
|
||||
Client-side game logic handling rendering the game state using ROT.js and managing core game functionality. Maintained original structure for compatibility.
|
||||
|
||||
**html/js/socketHandlers.js** *(NEW MODULAR STRUCTURE)*
|
||||
Dedicated module for all WebSocket event handling including connect, game_start, game_update, and game_over events. Includes auto-start functionality and initialization protection.
|
||||
|
||||
**html/js/inputHandler.js** *(NEW MODULAR STRUCTURE)*
|
||||
Handles all keyboard input (WASD/arrow keys) and form submissions. Includes movement throttling (100ms cooldown) and duplicate event prevention.
|
||||
|
||||
**html/js/ui.js** *(NEW MODULAR STRUCTURE)*
|
||||
UI utilities including chat scrolling, block height updates, teletype animations, and browser detection.
|
||||
|
||||
**html/styles/stylesheet.css**
|
||||
Styling for the game interface, ensuring proper layout and visual appeal.
|
||||
|
||||
**html/js/rot.js**
|
||||
The Roguelike Toolkit library that provides dungeon generation, field-of-view calculations, and display capabilities.
|
||||
|
||||
## Recent Bug Fixes and Improvements
|
||||
|
||||
### ✅ Movement System Overhaul (Completed)
|
||||
- **Fixed movement skipping bug**: Players no longer skip over tiles when moving through hallways
|
||||
- **Implemented movement throttling**: Added 100ms cooldown on both client and server to prevent rapid-fire commands
|
||||
- **Resolved duplicate event handlers**: Fixed double initialization of InputHandler and SocketHandlers that caused movement issues
|
||||
- **Enhanced debugging**: Added comprehensive logging with emojis and timing information for movement events
|
||||
|
||||
### ✅ Auto-Start System (Completed)
|
||||
- **Instant game start**: Players automatically enter games without waiting for blockchain blocks (for testing)
|
||||
- **Fixed socket initialization**: Resolved missing SocketHandlers.init() call that prevented game_start events from being received
|
||||
- **Improved connection flow**: Streamlined the connection → registration → game start process
|
||||
- **Enhanced error handling**: Better feedback when auto-start fails or hangs
|
||||
|
||||
### ✅ Client-Side Architecture (Completed)
|
||||
- **Modular JavaScript structure**: Split monolithic code into focused modules (ui.js, socketHandlers.js, inputHandler.js)
|
||||
- **Initialization protection**: Added flags to prevent multiple module initializations
|
||||
- **Clean separation of concerns**: Network, input, and UI logic properly separated
|
||||
- **Backward compatibility**: Maintained all original game functionality while improving code organization
|
||||
|
||||
### ✅ Server-Side Improvements (Completed)
|
||||
- **Movement validation**: Server-side movement throttling and validation
|
||||
- **Socket ID mapping**: Proper handling of client-to-server socket ID relationships
|
||||
- **Disconnect cleanup**: Proper cleanup of player data when clients disconnect
|
||||
- **Debug mode enhancements**: Improved block simulation for faster testing
|
||||
|
||||
## To-Do List
|
||||
|
||||
### High Priority
|
||||
- [x] ~~Fix movement skipping bug~~ **COMPLETED**
|
||||
- [x] ~~Fix auto-start hanging issue~~ **COMPLETED**
|
||||
- [x] ~~Resolve duplicate event handler registration~~ **COMPLETED**
|
||||
- [ ] Implement proper payment verification through Wownero RPC
|
||||
- [ ] Add visual indicators for block time status (when you're in danger)
|
||||
- [ ] Add score tracking and leaderboard functionality
|
||||
|
||||
### Medium Priority
|
||||
- [ ] Improve monster AI with more sophisticated pathfinding
|
||||
- [ ] Add multiple dungeon layouts and difficulty levels
|
||||
- [ ] Implement different monster types with varying behaviors
|
||||
- [ ] Create persistent user accounts with game history
|
||||
- [ ] Add sound effects and basic animations
|
||||
- [ ] Optimize chat system for better message broadcasting
|
||||
|
||||
### Low Priority
|
||||
- [ ] Implement additional power-ups or items in the dungeon
|
||||
- [ ] Add achievements system
|
||||
- [ ] Create detailed statistics tracking
|
||||
- [ ] Optimize performance for mobile devices
|
||||
- [ ] Add difficulty settings with corresponding reward multipliers
|
||||
|
||||
## Running the Game
|
||||
|
||||
1. Install dependencies: `npm install`
|
||||
2. Configure Wownero RPC settings in `config.js` or environment variables
|
||||
3. Start the server: `node index.js`
|
||||
4. Access the game at `http://localhost:3000`
|
||||
|
||||
## Development Mode
|
||||
|
||||
The game includes a DEBUG_MODE setting that simulates block discovery every 30 seconds for easier testing. Set `DEBUG_MODE = true` in `index.js` to enable this feature.
|
||||
|
||||
### Auto-Start Testing Mode
|
||||
When DEBUG_MODE is enabled, the game automatically:
|
||||
- Connects players and sends "enter" command after 500ms
|
||||
- Starts games immediately without waiting for blockchain blocks
|
||||
- Provides instant feedback for testing movement and game mechanics
|
||||
- Includes comprehensive debug logging with emojis for easy tracking
|
||||
|
||||
### Debug Features
|
||||
- **Movement Logging**: Track every player movement with timing information
|
||||
- **Socket Communication**: Monitor all WebSocket events and data flow
|
||||
- **FOV Debugging**: Detailed field-of-view calculation logs
|
||||
- **Game State Tracking**: Real-time monitoring of player, monster, and treasure states
|
||||
@@ -102,8 +102,10 @@ class Game {
|
||||
}
|
||||
if (this.dungeon.treasure && this.player.isAt(this.dungeon.treasure[0], this.dungeon.treasure[1]) && !this.player.hasTreasure) {
|
||||
this.player.hasTreasure = true;
|
||||
console.log(`🏆 TREASURE PICKUP: Player ${this.socketId} collected treasure at (${this.dungeon.treasure[0]}, ${this.dungeon.treasure[1]})`);
|
||||
// Remove treasure from dungeon so it won't be sent in future updates
|
||||
this.dungeon.treasure = null;
|
||||
console.log(`🗑️ TREASURE REMOVED: dungeon.treasure is now null for player ${this.socketId}`);
|
||||
console.log(`Player ${this.socketId} collected treasure! hasTreasure: ${this.player.hasTreasure}`);
|
||||
return { status: 'moved', event: 'treasure_found', player: this.player.getState(), visibleTiles: this.visibleTiles };
|
||||
}
|
||||
@@ -135,6 +137,9 @@ class Game {
|
||||
|
||||
// Debug logging to verify entity data
|
||||
console.log("🎮 getState() sending entities - Monster:", state.monster, "Entrance:", state.entrance, "Exit:", state.exit, "Treasure:", state.treasure);
|
||||
if (state.treasure === null) {
|
||||
console.log("✅ TREASURE NULL: Confirmed treasure is null in getState() - treasure was picked up!");
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
+22
-6
@@ -1,4 +1,5 @@
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
var app = express();
|
||||
var http = require('http').Server(app);
|
||||
var io = require('socket.io')(http);
|
||||
@@ -38,9 +39,11 @@ const DEBUG_MODE = true; // Set to false to disable debug mode
|
||||
let debugBlockHeight = 1;
|
||||
const clientSocketMap = new Map(); // To track client-to-server socket ID mappings
|
||||
|
||||
app.use(express.static('../../html'));
|
||||
// Use absolute path to html directory to ensure static files are served correctly
|
||||
const htmlPath = path.join(__dirname, '../../html');
|
||||
app.use(express.static(htmlPath));
|
||||
app.get('/', function(req, res) {
|
||||
res.sendFile('index.html', { root: '../../html' });
|
||||
res.sendFile('index.html', { root: htmlPath });
|
||||
});
|
||||
|
||||
// Replace your existing block check interval with this conditional version
|
||||
@@ -89,7 +92,7 @@ if (DEBUG_MODE) {
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// Start games for waiting players
|
||||
// Start games for waiting players (QUEUE ENTRY METHOD)
|
||||
function startGamesForWaiting(blockHeight) {
|
||||
console.log(`Starting games for ${WAITING_PLAYERS.length} waiting players at block height ${blockHeight}`);
|
||||
|
||||
@@ -102,7 +105,9 @@ function startGamesForWaiting(blockHeight) {
|
||||
const currentUser = getUserBySocket(serverId);
|
||||
|
||||
if (currentUser) {
|
||||
// For queue entry, player gets 3 blocks starting from their entry block
|
||||
currentUser.blockRec = blockHeight;
|
||||
console.log(`🕒 QUEUE ENTRY: Player starts on block ${currentUser.blockRec}, will die after block ${currentUser.blockRec + 2}`);
|
||||
|
||||
try {
|
||||
const game = currentUser.startGame(80, 40);
|
||||
@@ -135,8 +140,9 @@ function checkGamesTimeout(currentHeight) {
|
||||
|
||||
// Player has 3 blocks to complete the dungeon
|
||||
// If they started on block 2, they must escape before block 5 is found
|
||||
// Note: Auto-entry players start timing from next block for consistent behavior
|
||||
if (user && user.blockRec && currentHeight > user.blockRec + 2) {
|
||||
console.log(`Game timeout for player ${socketId}: started on block ${user.blockRec}, current block ${currentHeight} (allowed until block ${user.blockRec + 2})`);
|
||||
console.log(`💀 GAME TIMEOUT for player ${socketId}: started timing on block ${user.blockRec}, current block ${currentHeight} (died after block ${user.blockRec + 2})`);
|
||||
|
||||
// Game has timed out - player didn't escape in time
|
||||
game.gameState = 'lost';
|
||||
@@ -180,6 +186,11 @@ io.on('connection', function(socket) {
|
||||
'Welcome, to enter the dungeon type Enter, and you will be given a Wownero address, ' +
|
||||
'which you must send between 10-100 WOW to enter. The more you send, the more you can win.');
|
||||
}
|
||||
// ====== GAME ENTRY HANDLERS ======
|
||||
// There are two ways to enter a game:
|
||||
// 1. QUEUE ENTRY: Type "enter" and wait for next block (players get 3 blocks from entry block)
|
||||
// 2. AUTO ENTRY: Type "enter" and start immediately in debug mode (players get 3 blocks from next block)
|
||||
|
||||
// Update the 'enter' command handler to start game immediately for testing
|
||||
if (msg.toLowerCase() == 'enter') {
|
||||
console.log(`Player ${socket.id} requested to enter the dungeon - STARTING IMMEDIATELY`);
|
||||
@@ -192,12 +203,17 @@ io.on('connection', function(socket) {
|
||||
|
||||
// Start game immediately for faster testing
|
||||
try {
|
||||
currentUser.blockRec = debugBlockHeight || lastBlockHeight || 1;
|
||||
// For auto-entry in debug mode, give player 3 blocks starting from NEXT block
|
||||
// This ensures consistent death timing regardless of entry method
|
||||
const currentBlock = debugBlockHeight || lastBlockHeight || 1;
|
||||
currentUser.blockRec = currentBlock + 1; // Start timing from NEXT block
|
||||
console.log(`🕒 AUTO-ENTRY: Player starts on block ${currentUser.blockRec}, will die after block ${currentUser.blockRec + 2}`);
|
||||
|
||||
const game = currentUser.startGame(80, 40);
|
||||
activeGames.set(socket.id, game);
|
||||
|
||||
const gameState = game.getState();
|
||||
gameState.blockHeight = debugBlockHeight || lastBlockHeight || 1;
|
||||
gameState.blockHeight = currentBlock;
|
||||
|
||||
console.log(`🎮 SENDING IMMEDIATE GAME_START to ${socket.id}`);
|
||||
io.to(socket.id).emit('game_start', gameState);
|
||||
|
||||
Reference in New Issue
Block a user