# UNO Bot Integration - Setup Notes ## Node.js Version Compatibility This project was originally developed with Node.js 14-16. **IMPORTANT:** Due to PostCSS compatibility issues, this project requires Node.js 16 or 18. ### Current System Issue - ❌ Node.js v25.3.0 - PostCSS subpath export errors - ✅ Node.js 18.x - Recommended - ✅ Node.js 16.x - Also works ### Solution: Use nvm to switch Node version ```bash # Install nvm if not already installed curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash # Install Node 18 nvm install 18 # Use Node 18 nvm use 18 # Verify version node --version # Should show v18.x.x ``` After switching to Node 18, proceed with the setup below. ## Quick Start ### 1. Install Dependencies **Server:** ```bash cd /home/koko210Serve/docker/uno-online npm install ``` **Client:** ```bash cd /home/koko210Serve/docker/uno-online/client npm install ``` ### 2. Start Server (Terminal 1) ```bash cd /home/koko210Serve/docker/uno-online npm start ``` Server runs on: `http://localhost:5000` ### 3. Start Client (Terminal 2) ```bash cd /home/koko210Serve/docker/uno-online/client npm start ``` Client opens at: `http://localhost:3000` ### 4. Test Bot Integration **Create a game:** - Open `http://localhost:3000` - Click "CREATE GAME" - Note the room code (e.g., "ABCDEF") **Open browser console (F12)** to see game state logs **Test API:** ```bash # Get game state (replace ABCDEF with your room code) curl http://localhost:5000/api/game/ABCDEF/state # Play a card (after joining as Player 2) curl -X POST http://localhost:5000/api/game/ABCDEF/action \ -H "Content-Type: application/json" \ -d '{"action":"draw_card"}' ``` ## What to Look For ### Browser Console Output When you play as Player 2, you'll see: ``` 🎮 UNO GAME STATE (Simplified): { turn: "Player 2", currentCard: "5 red (5R)", ... } 🤖 FULL GAME STATE (For Bot): { game: {...}, currentCard: {...}, ... } 📋 JSON for Bot API: { "game": { ... } ... } ``` ### Server Console Output ``` [Bot Game State] Room: ABCDEF { "game": { ... } } ``` ## Files Modified for Bot Integration ### New Files - `/client/src/utils/cardParser.js` - Parse card codes to JSON - `/client/src/utils/gameStateBuilder.js` - Build comprehensive game state - `/BOT_INTEGRATION_GUIDE.md` - Full integration documentation - `/BOT_QUICK_REF.md` - Quick reference guide - `/SETUP_NOTES.md` - This file ### Modified Files - `/client/src/components/Game.js` - Added state export and logging - `/server.js` - Added HTTP API endpoints and Socket.IO handlers ## Common Issues ### Port Already in Use If port 5000 or 3000 is busy: ```bash # Kill process on port 5000 lsof -ti:5000 | xargs kill -9 # Kill process on port 3000 lsof -ti:3000 | xargs kill -9 ``` ### npm Install Failures If you get peer dependency warnings, use: ```bash npm install --legacy-peer-deps ``` ### Module Not Found Errors Clear cache and reinstall: ```bash rm -rf node_modules package-lock.json npm install ``` ## Next Steps 1. ✅ Game state exports to console 2. ✅ HTTP API endpoints created 3. ⏭️ Test manual API calls 4. ⏭️ Integrate with Miku bot 5. ⏭️ Create Discord command `/uno join [room_code]` 6. ⏭️ Implement LLM decision-making See `BOT_INTEGRATION_GUIDE.md` for Miku bot integration details.