# Daily Rewards - Quick Start Guide

## 1. Files Created
✅ `/home/user/lichun/ws/retention/daily_rewards.py` - Main implementation
✅ `/home/user/lichun/ws/test_daily_rewards.py` - Test suite
✅ `/home/user/lichun/ws/retention/DAILY_REWARDS_README.md` - Full documentation

## 2. Integration (Copy-Paste Ready)

### Add to app.py (player connection):
```python
# After player connects and loads their game
from retention.daily_rewards import handle_daily_login_check

handle_daily_login_check(
    player_id=websocket.userID,
    send_to_client=lambda pid, msg: asyncio.create_task(websocket.send(json.dumps(msg)))
)
```

### Add to app.py consumer() function:
```python
# Handle reward claim request
if event['type'] == 'claimDailyReward':
    from retention.daily_rewards import claim_daily_reward

    result = claim_daily_reward(player_id)
    await websocket.send(json.dumps({
        'type': 'dailyRewardClaimed',
        'success': result['success'],
        'reward': result['reward'],
        'message': result['message']
    }))
```

## 3. Client Messages

### Server sends on login (if reward available):
```json
{
    "type": "dailyRewardAvailable",
    "streak": 3,
    "reward": {"day": 3, "type": "energy", "amount": 50, "name": "50 Energy"}
}
```

### Client sends to claim:
```json
{"type": "claimDailyReward"}
```

### Server responds to claim:
```json
{
    "type": "dailyRewardClaimed",
    "success": true,
    "reward": {"day": 3, "type": "energy", "amount": 50, "name": "50 Energy"}
}
```

## 4. Testing
```bash
cd /home/user/lichun/ws
python3 test_daily_rewards.py
```

## 5. API Quick Reference
```python
from retention.daily_rewards import (
    check_daily_login,      # Check streak on login
    claim_daily_reward,     # Award reward to player
    get_login_streak_info,  # Get player's streak data
)

# Check login
result = check_daily_login(player_id)
# Returns: {'reward_available': bool, 'streak': int, 'reward': dict}

# Claim reward
result = claim_daily_reward(player_id)
# Returns: {'success': bool, 'reward': dict, 'message': str}

# Get streak info
info = get_login_streak_info(player_id)
# Returns: {'current_streak': int, 'total_logins': int, 'next_reward_day': int}
```

## 6. Reward Calendar
Day 1: 5 💎 | Day 2: 10 💎 | Day 3: 50 ⚡ | Day 4: 15 💎
Day 5: 20 💎 + 🎁 | Day 6: 25 💎 | Day 7: 50 💎 🎉

## 7. Done!
✅ Database tables already created (migration 001)
✅ Code ready to use
✅ Just add the 2 code snippets above to app.py
