# Phase 2: Levels 1-10 Implementation

**Priority**: HIGH - Core tutorial and early progression  
**Estimated Effort**: 16-20 hours  
**Status**: Not Started  
**Dependencies**: Phase 1 (Campaign Foundation)

---

## 🎯 Phase Goals

Implement the first 10 levels of The Academy, covering the **Foundation Arc** (L1-5) and **Feature Discovery Arc** (L6-10). These levels introduce basic edging, build to complex feature combinations, and include the first preference checkpoint.

---

## 📋 What This Phase Delivers

### Arcs Implemented:
1. **Foundation Arc (L1-5)**: Basic edging, rhythm, video introduction, library setup
2. **Feature Discovery Arc (L6-10)**: Webcam, dual video, TTS, quad video, hypno spiral

### Level-by-Level:
- **L1**: Edge Training 101 (5min) - Basic edges
- **L2**: Rhythm & Control (10min) - Rhythm patterns + library addition
- **L3**: Visual Immersion (15min) - First porn video + file tagging
- **L4**: Multi-Tasking Challenge (20min) - Multiple actions, rhythm + video
- **L5**: Foundation Checkpoint (25min) - Preference update + L1-4 recap
- **L6**: The Observer (30min) - Webcam unlock
- **L7**: Dual Focus (40min) - Picture-in-picture dual video
- **L8**: Vocal Commands (50min) - TTS unlock
- **L9**: Sensory Array (60min) - Quad video unlock
- **L10**: Hypnotic Gateway (70min) - Hypno spiral unlock + Checkpoint

**End Result**: Fully functional early campaign with progressive feature unlocking.

---

## 🏗️ Implementation Tasks

### Task 1: Action Handler Extensions (6-8 hours)

**File to Update**: `src/features/tasks/interactiveTaskManager.js`

Add handlers for new actions used in L1-10:

#### New Action Types Needed:

**Basic Actions (L1-5)**:
```javascript
{
  type: 'edge',
  params: {
    count: 5,
    instruction: 'Edge 5 times in a row'
  }
}

{
  type: 'rhythm',
  params: {
    pattern: 'slow-fast-slow', // or 'fast-slow-fast', 'steady'
    duration: 120
  }
}

{
  type: 'add-library-directory',
  params: {
    directory: '/assets/amateur/',
    suggestedTags: ['amateur', 'solo']
  }
}

{
  type: 'tag-files',
  params: {
    directory: '/assets/amateur/',
    minFiles: 10,
    suggestedTags: ['pov', 'blowjob', 'riding']
  }
}
```

**Feature Unlock Actions (L6-10)**:
```javascript
{
  type: 'enable-webcam',
  params: {
    instruction: 'Turn on your webcam to watch yourself'
  }
}

{
  type: 'dual-video',
  params: {
    mainVideo: 'focus',
    pipVideo: 'overlay',
    pipPosition: 'bottom-right'
  }
}

{
  type: 'tts-command',
  params: {
    text: 'Good gooner. Edge again.',
    voice: 'feminine'
  }
}

{
  type: 'quad-video',
  params: {
    layout: 'grid', // or 'cascade'
    videos: ['random', 'random', 'random', 'random']
  }
}

{
  type: 'hypno-spiral',
  params: {
    duration: 120,
    overlay: true,
    opacity: 0.5
  }
}
```

#### Handler Implementation:

```javascript
class InteractiveTaskManager {
  // ... existing code ...
  
  async handleEdgeAction(action) {
    // Show edge counter UI
    // Wait for user to edge X times
    // Track edge count
    // Return when complete
  }
  
  async handleRhythmAction(action) {
    // Display rhythm pattern indicator
    // Play metronome sounds
    // Track user compliance
  }
  
  async handleAddLibraryAction(action) {
    // Call LibraryManager.addDirectory
    // Show success message
  }
  
  async handleTagFilesAction(action) {
    // Open tagging UI
    // Pre-fill directory and suggestions
    // Wait for user to tag N files
    // Update library stats
  }
  
  async handleEnableWebcamAction(action) {
    // Call WebcamManager.start()
    // Show webcam in overlay
    // Mark webcam as unlocked
  }
  
  async handleDualVideoAction(action) {
    // Load main video in FocusVideoPlayer
    // Load PiP video in OverlayVideoPlayer
    // Position PiP
  }
  
  async handleTTSAction(action) {
    // Call VoiceManager.speak()
    // Wait for speech to finish
  }
  
  async handleQuadVideoAction(action) {
    // Initialize QuadVideoPlayer
    // Load 4 random videos
    // Display in grid layout
  }
  
  async handleHypnoSpiralAction(action) {
    // Show hypno spiral overlay
    // Animate spiral
    // Play hypno audio
    // Run for duration
  }
}
```

**Testing Checklist**:
- [ ] Edge action tracks count correctly
- [ ] Rhythm action displays pattern
- [ ] Library directory adds successfully
- [ ] File tagging UI works
- [ ] Webcam enables correctly
- [ ] Dual video displays properly
- [ ] TTS speaks commands
- [ ] Quad video grid renders
- [ ] Hypno spiral animates

---

### Task 2: Level Data Definitions (4-5 hours)

**File to Create**: `src/data/modes/academyLevelData.js`

Define all 30 levels. For Phase 2, implement L1-10 in detail:

```javascript
const academyLevels = {
  1: {
    name: "Edge Training 101",
    arc: "Foundation",
    duration: 300, // 5 minutes
    requirements: {
      minLevel: 1,
      featuresRequired: []
    },
    unlocks: {
      level: 2,
      features: []
    },
    sessionStructure: {
      warmup: [
        { type: 'caption', text: 'Welcome to The Academy, gooner.' },
        { type: 'instruction', text: 'Today you learn the basics of edging.' }
      ],
      main: [
        { type: 'edge', params: { count: 5, instruction: 'Edge 5 times slowly' } },
        { type: 'wait', duration: 30 },
        { type: 'edge', params: { count: 3, instruction: 'Edge 3 more times' } }
      ],
      cooldown: [
        { type: 'caption', text: 'You completed your first level!' },
        { type: 'save-progress' }
      ]
    },
    failureConditions: {
      cumming: true,
      closingFeatures: false, // no features to close yet
      abandoningSession: true
    }
  },
  
  2: {
    name: "Rhythm & Control",
    arc: "Foundation",
    duration: 600, // 10 minutes
    requirements: {
      minLevel: 2,
      completedLevels: [1]
    },
    unlocks: {
      level: 3,
      features: []
    },
    sessionStructure: {
      warmup: [
        { type: 'caption', text: 'Level 2: Learning rhythm and building your library.' }
      ],
      main: [
        { type: 'rhythm', params: { pattern: 'slow-fast-slow', duration: 180 } },
        { type: 'add-library-directory', params: { 
          directory: '/assets/amateur/', 
          suggestedTags: ['amateur', 'solo'] 
        }},
        { type: 'edge', params: { count: 10 } }
      ],
      cooldown: [
        { type: 'caption', text: 'Your library is growing...' }
      ]
    },
    failureConditions: {
      cumming: true,
      abandoningSession: true
    }
  },
  
  3: {
    name: "Visual Immersion",
    arc: "Foundation",
    duration: 900, // 15 minutes
    requirements: {
      minLevel: 3,
      completedLevels: [2]
    },
    unlocks: {
      level: 4,
      features: ['video']
    },
    sessionStructure: {
      warmup: [
        { type: 'caption', text: 'Time to add visuals to your training.' }
      ],
      main: [
        { type: 'video-start', params: { player: 'focus', tags: ['amateur'] } },
        { type: 'tag-files', params: { 
          directory: '/assets/amateur/', 
          minFiles: 10,
          suggestedTags: ['pov', 'blowjob', 'riding']
        }},
        { type: 'edge', params: { count: 15 } },
        { type: 'video-stop' }
      ],
      cooldown: []
    },
    failureConditions: {
      cumming: true,
      abandoningSession: true,
      closingFeatures: ['video']
    }
  },
  
  4: {
    name: "Multi-Tasking Challenge",
    arc: "Foundation",
    duration: 1200, // 20 minutes
    requirements: {
      minLevel: 4,
      completedLevels: [3]
    },
    unlocks: {
      level: 5
    },
    sessionStructure: {
      warmup: [],
      main: [
        { type: 'video-start', params: { player: 'focus' } },
        { type: 'rhythm', params: { pattern: 'fast-slow-fast', duration: 240 } },
        { type: 'edge', params: { count: 20 } },
        { type: 'caption', text: 'Keep going... faster...' }
      ],
      cooldown: []
    }
  },
  
  5: {
    name: "Foundation Checkpoint",
    arc: "Foundation",
    duration: 1500, // 25 minutes
    isCheckpoint: true,
    requirements: {
      minLevel: 5,
      completedLevels: [4]
    },
    unlocks: {
      level: 6,
      features: [],
      arcsCompleted: ['Foundation']
    },
    sessionStructure: {
      warmup: [
        { type: 'show-preferences', reason: 'checkpoint' }
      ],
      main: [
        // Recap of L1-4 techniques
        { type: 'edge', params: { count: 5 } },
        { type: 'rhythm', params: { pattern: 'slow-fast-slow', duration: 120 } },
        { type: 'video-start' },
        { type: 'edge', params: { count: 25 } }
      ],
      cooldown: [
        { type: 'show-arc-complete', arc: 'Foundation' }
      ]
    }
  },
  
  6: {
    name: "The Observer",
    arc: "Feature Discovery",
    duration: 1800, // 30 minutes
    requirements: {
      minLevel: 6,
      completedLevels: [5]
    },
    unlocks: {
      level: 7,
      features: ['webcam']
    },
    sessionStructure: {
      warmup: [
        { type: 'caption', text: 'Welcome to Feature Discovery. Time to watch yourself.' }
      ],
      main: [
        { type: 'enable-webcam' },
        { type: 'video-start' },
        { type: 'caption', text: 'Watch yourself gooning...' },
        { type: 'edge', params: { count: 30 } }
      ],
      cooldown: []
    },
    failureConditions: {
      cumming: true,
      abandoningSession: true,
      closingFeatures: ['webcam', 'video']
    }
  },
  
  7: {
    name: "Dual Focus",
    arc: "Feature Discovery",
    duration: 2400, // 40 minutes
    requirements: {
      minLevel: 7,
      completedLevels: [6],
      featuresUnlocked: ['webcam']
    },
    unlocks: {
      level: 8,
      features: ['dual-video']
    },
    sessionStructure: {
      main: [
        { type: 'dual-video', params: { mainVideo: 'focus', pipVideo: 'overlay' } },
        { type: 'edge', params: { count: 40 } }
      ]
    }
  },
  
  8: {
    name: "Vocal Commands",
    arc: "Feature Discovery",
    duration: 3000, // 50 minutes
    requirements: {
      minLevel: 8,
      completedLevels: [7],
      featuresUnlocked: ['dual-video']
    },
    unlocks: {
      level: 9,
      features: ['tts']
    },
    sessionStructure: {
      main: [
        { type: 'enable-tts' },
        { type: 'video-start' },
        { type: 'tts-command', params: { text: 'Edge for me, gooner.' } },
        { type: 'edge', params: { count: 50 } },
        { type: 'tts-command', params: { text: 'Good gooner. Keep going.' } }
      ]
    }
  },
  
  9: {
    name: "Sensory Array",
    arc: "Feature Discovery",
    duration: 3600, // 60 minutes
    requirements: {
      minLevel: 9,
      completedLevels: [8],
      featuresUnlocked: ['tts']
    },
    unlocks: {
      level: 10,
      features: ['quad-video']
    },
    sessionStructure: {
      main: [
        { type: 'quad-video', params: { layout: 'grid' } },
        { type: 'tts-command', params: { text: 'Watch all four screens...' } },
        { type: 'edge', params: { count: 60 } }
      ]
    }
  },
  
  10: {
    name: "Hypnotic Gateway",
    arc: "Feature Discovery",
    duration: 4200, // 70 minutes
    isCheckpoint: true,
    requirements: {
      minLevel: 10,
      completedLevels: [9],
      featuresUnlocked: ['quad-video']
    },
    unlocks: {
      level: 11,
      features: ['hypno'],
      arcsCompleted: ['Feature Discovery']
    },
    sessionStructure: {
      warmup: [
        { type: 'show-preferences', reason: 'checkpoint' }
      ],
      main: [
        { type: 'hypno-spiral', params: { duration: 120, overlay: true } },
        { type: 'quad-video' },
        { type: 'tts-command', params: { text: 'Deeper... watch the spiral...' } },
        { type: 'edge', params: { count: 70 } }
      ],
      cooldown: [
        { type: 'show-arc-complete', arc: 'Feature Discovery' }
      ]
    }
  }
};

export default academyLevels;
```

**Testing Checklist**:
- [ ] All 10 levels defined
- [ ] Level requirements check correctly
- [ ] Unlocks work as specified
- [ ] Checkpoint levels trigger preferences

---

### Task 3: UI Components for Levels (3-4 hours)

**File to Update**: `training-academy.html`

Add UI elements:

```html
<!-- Level Completion Screen -->
<div id="level-complete-modal" class="modal hidden">
  <h2>Level Complete!</h2>
  <div id="level-stats">
    <p>Time: <span id="session-time"></span></p>
    <p>Edges: <span id="edge-count"></span></p>
    <p>Next Level Unlocked: <span id="next-level"></span></p>
  </div>
  <button id="continue-btn">Continue</button>
</div>

<!-- Arc Complete Screen -->
<div id="arc-complete-modal" class="modal hidden">
  <h2>Arc Complete: <span id="arc-name"></span></h2>
  <p id="arc-description"></p>
  <button id="continue-arc-btn">Continue to Next Arc</button>
</div>

<!-- Level Select Screen Updates -->
<div id="level-grid">
  <!-- Generate 30 level cards -->
  <!-- L1-10 should be functional after this phase -->
</div>
```

**Testing Checklist**:
- [ ] Level complete modal displays stats
- [ ] Arc complete modal shows at L5 and L10
- [ ] Level select shows L1-10 unlockable

---

### Task 4: Feature Unlock Integration (2-3 hours)

Connect action handlers to actual feature managers:

**Webcam Unlock** → `WebcamManager.start()`  
**Dual Video** → `FocusVideoPlayer` + `OverlayVideoPlayer`  
**TTS** → `VoiceManager.speak()`  
**Quad Video** → `QuadVideoPlayer.initialize()`  
**Hypno** → Create hypno spiral overlay

**Testing Checklist**:
- [ ] Webcam activates at L6
- [ ] Dual video works at L7
- [ ] TTS speaks at L8
- [ ] Quad video displays at L9
- [ ] Hypno spiral shows at L10

---

### Task 5: Library/Preference Integration (1-2 hours)

Ensure checkpoints work:

**At L1**: Show preference form  
**At L5**: Show preference form + library stats  
**At L10**: Show preference form + library stats

**Testing Checklist**:
- [ ] L1 shows preferences
- [ ] L5 shows preferences and library
- [ ] L10 shows preferences and library
- [ ] Preferences affect content selection

---

## 📏 Measurable Test Criteria

After Phase 2, ALL of these must pass:

### Level 1:
- [ ] Can start L1
- [ ] Preference form appears
- [ ] Edge counter works
- [ ] Completing L1 unlocks L2

### Level 2:
- [ ] Rhythm pattern displays
- [ ] Library directory adds
- [ ] Completing L2 unlocks L3

### Level 3:
- [ ] Video plays
- [ ] Tagging UI works
- [ ] Tag at least 10 files
- [ ] Completing L3 unlocks L4

### Level 4:
- [ ] Video + rhythm work simultaneously
- [ ] Completing L4 unlocks L5

### Level 5 (Checkpoint):
- [ ] Preference form appears
- [ ] Library stats display
- [ ] Foundation Arc completes
- [ ] Completing L5 unlocks L6

### Level 6:
- [ ] Webcam enables
- [ ] Webcam feed displays
- [ ] Completing L6 unlocks L7

### Level 7:
- [ ] Dual video displays (main + PiP)
- [ ] PiP positions correctly
- [ ] Completing L7 unlocks L8

### Level 8:
- [ ] TTS speaks commands
- [ ] Voice is audible
- [ ] Completing L8 unlocks L9

### Level 9:
- [ ] Quad video grid displays
- [ ] All 4 videos play
- [ ] Completing L9 unlocks L10

### Level 10 (Checkpoint):
- [ ] Hypno spiral displays
- [ ] Spiral animates
- [ ] Preference form appears
- [ ] Feature Discovery Arc completes
- [ ] Completing L10 unlocks L11

### Overall:
- [ ] All levels playable
- [ ] No console errors
- [ ] Progress saves after each level
- [ ] Feature unlocks persist

---

## 🎯 Success Criteria

**Phase 2 Complete When:**
1. Levels 1-10 fully functional
2. Foundation + Feature Discovery arcs complete
3. All measurable tests pass
4. Checkpoints at L5 and L10 work
5. Feature unlocking progresses correctly
6. Can play L1 → L10 sequentially

---

## 📂 Files Created/Modified

### New Files:
- `src/data/modes/academyLevelData.js`

### Modified Files:
- `src/features/tasks/interactiveTaskManager.js`
- `training-academy.html`
- `src/features/webcam/webcamManager.js`
- `src/features/video/videoPlayerManager.js`
- `src/features/tts/voiceManager.js`

---

## 🚀 Next Phase

After Phase 2: **Phase 3: Levels 11-20 Implementation** (Mind & Body + Advanced Training arcs)
