# 🎮 Miku UNO - First Test Guide

## ⚡ Quick Setup (5 Minutes)

### Step 1: Install Playwright (One-Time Setup)
```bash
cd /home/koko210Serve/docker/miku-discord/bot
bash setup_uno_playwright.sh
```

**Expected Output:**
```
✅ Playwright browsers installed successfully!
```

---

## 🚀 Running the Test

### Step 2: Start All Services (3 Terminals)

#### Terminal 1: UNO Backend
```bash
cd /home/koko210Serve/docker/uno-online
node server.js
```
**Expected Output:**
```
Server listening on port 5000
```

#### Terminal 2: UNO Frontend
```bash
cd /home/koko210Serve/docker/uno-online/client
npm start
```
**Expected Output:**
```
webpack compiled successfully
Compiled successfully!

You can now view client in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://192.168.1.2:3002
```

#### Terminal 3: Miku Bot
```bash
cd /home/koko210Serve/docker/miku-discord/bot
python bot.py
```
**Expected Output:**
```
🎤 MikuBot connected as <bot name>
```

---

## 🎮 First Game Test

### Step 3: Create Game in Discord
Open Discord and type:
```
!uno create
```

**Expected Response:**
```
🎮 Created UNO room: ABC123
Join at: http://192.168.1.2:3002
I'm joining now as Player 2! ✨
```

### Step 4: Join as Player 1
1. Copy the URL from bot's response
2. Open it in your web browser
3. Click "Join Room"
4. Enter the room code (e.g., ABC123)
5. Click "Join Game"

**You should see:**
- "Player 1" (you) in the room
- "Player 2" (Miku) in the room
- Game starts automatically
- Both players get 7 cards
- A card appears in the center

### Step 5: Watch Miku Play! 🎵

When it's Miku's turn (Player 2), watch for:

**In Discord:**
- A message like: "Playing my card~ Let's keep this fun! 🎵"
- Or: "Draw two cards! Don't worry, I still believe in you~ ✨"

**In Browser:**
- Miku's card appears on the pile
- Turn indicator switches
- Miku's hand count decreases

**In Bot Logs (Terminal 3):**
```
[UNO] Creating new game room...
[MikuUnoPlayer] Browser launched
[MikuUnoPlayer] Joining room: ABC123
[MikuUnoPlayer] Game started! Players: 2
[MikuUnoPlayer] Polling game state...
[MikuUnoPlayer] It's my turn! Analyzing game state...
[MikuUnoPlayer] Hand: ['R5', 'G2', 'B7', 'YS', 'WD4', 'GD', 'Y3']
[MikuUnoPlayer] Top card: R3
[MikuUnoPlayer] Getting Miku's strategic decision...
[MikuUnoPlayer] LLM Response: {"action":"play","card":"R5"}
[MikuUnoPlayer] Sending action: play R5
[MikuUnoPlayer] Action executed successfully!
[UNO] Sent trash talk to Discord
```

---

## ✅ Success Checklist

- [ ] Playwright installed successfully
- [ ] All 3 servers running (5000, 3002, bot)
- [ ] Bot responded to `!uno create`
- [ ] Got room code and join link
- [ ] Joined game in browser as Player 1
- [ ] See both players in room
- [ ] Game started automatically
- [ ] Both players have 7 cards
- [ ] Miku made a move on her turn
- [ ] Saw trash talk message in Discord
- [ ] Game continues smoothly

---

## 🎯 What to Test

### 1. Basic Gameplay (5-10 minutes)
- Play a full game to completion
- Watch Miku's moves
- Check if moves are legal
- Verify trash talk messages

### 2. Strategy Quality
- Does Miku match colors/numbers correctly?
- Does she use action cards strategically?
- Does she play Wild cards when needed?
- Does she call UNO at 1 card?

### 3. Personality Check
- Are messages cheerful and idol-like?
- Do emojis feel appropriate (💙✨🎵)?
- Does she use tildes (~)?
- Are messages encouraging?

---

## 🐛 Common Issues

### "Executable doesn't exist"
**Problem:** Playwright browsers not installed

**Solution:**
```bash
python -m playwright install chromium
```

### "Connection refused" on port 5000
**Problem:** Backend server not running

**Solution:**
```bash
cd /home/koko210Serve/docker/uno-online
node server.js
```

### "Cannot GET /" on port 3002
**Problem:** Frontend not running

**Solution:**
```bash
cd /home/koko210Serve/docker/uno-online/client
npm start
```

### Bot doesn't respond to !uno
**Problem:** Bot not running or command not loaded

**Solution:**
```bash
# Restart bot
cd /home/koko210Serve/docker/miku-discord/bot
python bot.py

# Check for errors in startup logs
```

### "Room not found"
**Problem:** Room code expired or invalid

**Solution:**
- Create a new game with `!uno create`
- Use the new room code

---

## 📊 Expected Behavior

### When It's Player 1's Turn (You)
- You can play cards manually
- Bot is polling in background
- Nothing happens in Discord

### When It's Player 2's Turn (Miku)
1. Bot detects it's her turn
2. Bot analyzes game state
3. Bot asks LLM for strategy
4. Bot makes a move
5. Bot sends trash talk to Discord
6. Turn passes back to you

### Game End
- Winner is determined
- Bot sends final message
- Bot stops polling
- Browser can be closed

---

## 🎮 Try These Commands

After the first game:

```
!uno list
```
Shows active games (should show your current game)

```
!uno help
```
Shows all available commands

```
!uno quit ABC123
```
Makes Miku leave the game (use actual room code)

```
!uno join XYZ789
```
Join a different game (if you create one manually)

---

## 📝 Notes for Testing

### Take Note Of:
1. **Response Time**: How long between Miku's turn and her move?
2. **Move Quality**: Are moves strategic or random?
3. **Personality**: Does she sound like Miku?
4. **Errors**: Any crashes or invalid moves?
5. **Performance**: Does bot slow down over time?

### Log Everything:
- Keep all 3 terminals visible
- Watch for error messages
- Note any unusual behavior
- Check if moves make sense strategically

### Test Multiple Games:
- Play 2-3 full games
- Try different scenarios:
  - Games where Miku wins
  - Games where you win
  - Games with lots of action cards
  - Games that go long (20+ turns)

---

## 🎉 If Everything Works

1. ✅ Mark tests as passed in `UNO_BOT_TESTING.md`
2. 📝 Note any quirks or improvements
3. 🎮 Play more games to test edge cases
4. 💡 Think about Phase 2 (Discord Activity)

---

## 🆘 If Something Breaks

1. 📸 Screenshot the error
2. 📋 Copy error logs
3. 🔍 Check which step failed
4. 📖 Refer to `UNO_BOT_SETUP.md` troubleshooting
5. 🔧 Debug and fix
6. 🔄 Re-test

---

## 📚 Documentation Reference

**After Setup**: `UNO_QUICK_REF.md` - Quick reference card
**Full Guide**: `UNO_BOT_SETUP.md` - Detailed setup
**Testing**: `UNO_BOT_TESTING.md` - Full test checklist
**Summary**: `UNO_INTEGRATION_SUMMARY.md` - Complete overview

---

## 🚀 Let's Go!

**Ready?** Run the 3 commands above and type `!uno create` in Discord!

**Have fun playing UNO with Miku!** 💙✨🎵

---

**Pro Tip**: Keep the bot logs visible (Terminal 3) during gameplay to see what Miku is thinking! 🧠
