# 🚀 Quick Start Guide - Advanced Features

Get all the new systems up and running in 5 minutes!

## ⚡ Installation

### 1. Update Dependencies

No new dependencies needed! Everything uses existing packages.

```bash
cd ranking-bot
npm install
```

### 2. Configure Environment

Update your `.env` file with new options:

```env
# ==================== EXISTING SETTINGS ====================
RCON_HOST=localhost
RCON_PORT=9177
RCON_PASSWORD=your_password_here
BOT_PORT=3001

# ELO System
INITIAL_ELO=1000
K_FACTOR=32
MIN_ELO=0
MAX_ELO=3000

# ==================== NEW ADVANCED FEATURES ====================

# Achievements System
ENABLE_ACHIEVEMENTS=true
ACHIEVEMENT_NOTIFICATIONS=true

# Notifications System
ENABLE_NOTIFICATIONS=true
NOTIFICATION_COOLDOWN=300000

# Hall of Fame / Seasons
AUTO_END_SEASON=false
SEASON_DURATION_DAYS=90

# Tournaments
ENABLE_AUTO_TOURNAMENTS=false
TOURNAMENT_ANNOUNCEMENT_TIME=3600000

# Discord Webhooks (Optional but recommended)
ACHIEVEMENT_WEBHOOK=https://discord.com/api/webhooks/YOUR_WEBHOOK_HERE
TOURNAMENT_WEBHOOK=https://discord.com/api/webhooks/YOUR_WEBHOOK_HERE
SEASON_WEBHOOK=https://discord.com/api/webhooks/YOUR_WEBHOOK_HERE
```

### 3. Start the Bot

```bash
npm start
```

You should see:

```
🤖 Starting Renown Ranking Bot...
🔧 Initializing advanced systems...
✅ Achievements system tables initialized
✅ Notifications system tables initialized
✅ Hall of Fame system tables initialized
✅ Tournament system tables initialized
✅ All systems initialized!
✅ Bot is online and monitoring duels!
```

---

## 🎯 Quick Test

### Test Achievements

```bash
# Simulate a duel to unlock "First Blood"
curl -X POST http://localhost:3001/api/kill \
  -H "Content-Type: application/json" \
  -d '{
    "killer": {"name": "TestPlayer", "steam_id": "test_player_1"},
    "victim": {"name": "Enemy", "steam_id": "enemy_1"}
  }'
```

Check achievements:
```bash
curl http://localhost:3001/api/achievements/player/test_player_1
```

### Test Notifications

Check unread notifications:
```bash
curl http://localhost:3001/api/notifications/test_player_1
```

### Test Hall of Fame

View current season:
```bash
curl http://localhost:3001/api/seasons
```

### Test Tournaments

Create a tournament:
```bash
curl -X POST http://localhost:3001/api/tournaments/create \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Sunday Championship",
    "type": "weekly_duel",
    "format": "single_elimination",
    "maxPlayers": 16
  }'
```

Register for it:
```bash
curl -X POST http://localhost:3001/api/tournaments/1/register \
  -H "Content-Type: application/json" \
  -d '{
    "steamId": "test_player_1",
    "playerName": "TestPlayer"
  }'
```

---

## 📊 Dashboard Access

Open your browser and go to:

```
http://localhost:3001
```

You'll see the updated dashboard with links to all new features!

---

## 🔗 Integration with Log Monitor

The systems work automatically with your existing `logMonitor.js`:

1. **Achievements** unlock when kills are detected
2. **Notifications** trigger on rank changes
3. **Rivalries** track automatically
4. **Tournaments** can be linked to special events

No additional configuration needed!

---

## 📱 New API Endpoints

### Achievements
- `GET /api/achievements/player/:steamId` - Player achievements
- `GET /api/achievements/list` - All achievements
- `GET /api/titles/player/:steamId` - Player title

### Notifications
- `GET /api/notifications/:steamId` - Unread notifications
- `POST /api/notifications/:id/read` - Mark as read
- `GET /api/rivalries/:steamId` - Player rivals

### Hall of Fame
- `GET /api/halloffame` - View Hall of Fame
- `GET /api/seasons` - All seasons
- `GET /api/seasons/:id/champions` - Season champions
- `POST /api/seasons/end` - End current season
- `POST /api/seasons/create` - Create new season

### Tournaments
- `POST /api/tournaments/create` - Create tournament
- `POST /api/tournaments/:id/register` - Register player
- `POST /api/tournaments/:id/start` - Start tournament
- `GET /api/tournaments/:id` - Tournament details
- `POST /api/tournaments/matches/:id/result` - Record result
- `GET /api/tournaments/:id/bracket` - View bracket

---

## 🎮 In-Game Usage

### For Server Admins

#### Create a Season
```bash
curl -X POST http://localhost:3001/api/seasons/create \
  -H "Content-Type: application/json" \
  -d '{"seasonName": "Season 2: Age of Heroes"}'
```

#### End a Season (Records Top 10 to Hall of Fame)
```bash
curl -X POST http://localhost:3001/api/seasons/end
```

#### Create Weekly Tournament
```bash
curl -X POST http://localhost:3001/api/tournaments/create \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Weekly Championship",
    "type": "weekly_duel",
    "format": "single_elimination",
    "maxPlayers": 16
  }'
```

### For Players

Players can:
- View their achievements progress
- Check notifications
- See their rivals
- Register for tournaments
- View Hall of Fame

All through API calls or future in-game commands!

---

## ⚙️ Common Tasks

### Check Bot Status
```bash
curl http://localhost:3001/api/status
```

### View Top 10
```bash
curl http://localhost:3001/api/leaderboard?limit=10
```

### View Player Profile (with achievements)
```bash
curl http://localhost:3001/api/player/STEAM_ID
curl http://localhost:3001/api/achievements/player/STEAM_ID
```

### View Hall of Fame
```bash
curl http://localhost:3001/api/halloffame?limit=50
```

### Active Tournaments
```bash
curl http://localhost:3001/api/tournaments/1
```

---

## 🎨 Customize Achievements

Edit `ranking-bot/achievementsSystem.js`:

```javascript
// Add your own achievement
my_achievement: {
  id: 'my_achievement',
  name: '🎖️ Custom Achievement',
  description: 'Your custom requirement',
  requirement: { type: 'kills', value: 25 },
  reward: { elo: 50, title: 'Custom Title' },
  badge: '🎖️',
  color: 0xFF00FF
}
```

Restart the bot and the new achievement will be available!

---

## 🐛 Troubleshooting

### "Tables already exist" error
Normal! The bot updates the database automatically.

### Achievements not showing
Check:
```bash
sqlite3 rankings.db "SELECT * FROM player_achievements;"
```

### Notifications not working
Verify RCON is connected:
```bash
curl http://localhost:3001/api/status
```

### Tournament won't start
Needs at least 4 players registered.

---

## 📚 Full Documentation

For complete details, see:
- [ADVANCED-FEATURES.md](./ADVANCED-FEATURES.md) - Complete API reference
- [README.md](./README.md) - Original bot documentation

---

## 💡 Tips

1. **Seasons** - Run for 30-90 days for best results
2. **Tournaments** - Announce 1 hour before via Discord
3. **Achievements** - Players love seeing progress bars!
4. **Notifications** - Keep cooldown at 5 minutes to avoid spam
5. **Hall of Fame** - Take screenshot before ending season!

---

## 🆘 Support

If you encounter issues:

1. Check console logs for errors
2. Verify database file exists: `rankings.db`
3. Test with curl commands above
4. Check RCON connection
5. Review [ADVANCED-FEATURES.md](./ADVANCED-FEATURES.md)

---

**🎮 Enjoy your enhanced Renown server!**

Built with ❤️ for the Renown Combat community

