All files / player-browser/src/chart bmson-bga.ts

100% Statements 10/10
100% Branches 6/6
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19                43x 43x 43x 10x 10x 32x     43x    
import { buildBmsonBGAEventTimeline, type BmsonBGAEventCue } from '@be-music/chart-model';
import type { BeMusicJSON } from '@be-music/chart-source';
 
/** Every possible event-layer filename, including alternatives not selected at the first trigger. */
export function collectBmsonBGAFrameKeys(
  chart: BeMusicJSON,
  cues?: readonly BmsonBGAEventCue[],
): { layer: Set<string>; poor: Set<string> } {
  const layer = new Set<string>();
  const poor = new Set<string>();
  for (const cue of cues ?? buildBmsonBGAEventTimeline(chart, { beatToSeconds: (beat) => beat })) {
    const keys = cue.condition === 'miss' ? poor : layer;
    for (const sequence of cue.sequences) {
      for (const frame of sequence.frames) if (frame.key) keys.add(frame.key);
    }
  }
  return { layer, poor };
}