/// Represents the specific version identity of the Wolfenstein 3D data files.
///
/// Since files like 'VSWAP.WL6' exist across multiple releases (v1.0, v1.1, v1.4),
/// we use MD5 checksums of the VSWAP file to determine specific engine behaviors,
/// such as MAPTEMP support or HUD differences.
enum DataVersion {
  /// Original v1.0 Retail release.
  version10Retail('a6d901dfb455dfac96db5e4705837cdb'),

  /// v1.1 Retail update.
  version11Retail('a80904e0283a921d88d977b56c279b9d'),

  /// v1.4 Shareware release (VSWAP.WL1).
  version14Shareware('6efa079414b817c97db779cecfb081c9'),

  /// v1.4 Retail release (found on GOG and Steam).
  version14Retail('b8ff4997461bafa5ef2a94c11f9de001'),

  /// Spear of Destiny Shareware release (VSWAP.SDM).
  spearOfDestinyShareware('35afda760bea840b547d686a930322dc'),

  /// Default state if the file hash is unrecognized.
  unknown('unknown')
  ;

  /// The MD5 hash of the VSWAP file associated with this version.
  final String checksum;

  const DataVersion(this.checksum);

  /// Matches a provided [hash] string to a known [DataVersion].
  static DataVersion fromChecksum(String hash) {
    return DataVersion.values.firstWhere(
      (v) => v.checksum == hash,
      orElse: () => DataVersion.unknown,
    );
  }
}
