import 'package:wolf_3d_dart/src/data_types/game_version.dart';
import 'package:wolf_3d_dart/src/registry/keys/music_key.dart';
import 'package:wolf_3d_dart/src/registry/modules/music_module.dart';

/// Built-in music router backed directly by [Music] metadata.
class BuiltInMusicModule extends MusicModule {
  const BuiltInMusicModule(this.version);

  final GameVersion version;

  @override
  MusicRoute get menuMusic =>
      MusicRoute(Music.menuTheme.trackIndexFor(version)!);

  @override
  MusicRoute musicForLevel(int episodeIndex, int levelIndex) {
    return MusicRoute(
      Music.trackIndexForLevel(version, episodeIndex, levelIndex)!,
    );
  }

  @override
  MusicRoute? resolve(Music key) {
    final index = key.trackIndexFor(version);
    return index != null ? MusicRoute(index) : null;
  }
}
