import 'package:wolf_3d_dart/wolf_3d_data_types.dart';

/// Handles identity and difficulty-based logic for enemies in map data.
///
/// In Wolf3D, each enemy type (Guard, SS, etc.) occupies a block of 48 IDs
/// in the map object layer to account for behavior, direction, and difficulty.
class EnemyMapData {
  /// The starting ID for this specific enemy type (e.g., 108 for Guards).
  final int baseId;

  const EnemyMapData(this.baseId);

  /// Returns true if the provided [id] belongs to this enemy type's 48-ID block.
  bool claimsId(int id) => id >= baseId && id < baseId + 48;

  /// Returns true if the ID represents a patrolling version for the [difficulty].
  bool isPatrolForDifficulty(int id, Difficulty difficulty) {
    // Patrolling enemies occupy the first 16 IDs (4 per difficulty level)
    int start = baseId + (difficulty.level * 4);
    return id >= start && id < start + 4;
  }

  /// Returns true if the ID represents a standing (static) version for the [difficulty].
  bool isStaticForDifficulty(int id, Difficulty difficulty) {
    // Standing enemies occupy the next 16 IDs
    int start = baseId + 16 + (difficulty.level * 4);
    return id >= start && id < start + 4;
  }

  /// Returns true if the ID represents an "Ambush" version for the [difficulty].
  /// Ambush enemies wait for the player to enter their line of sight before moving.
  bool isAmbushForDifficulty(int id, Difficulty difficulty) {
    // Ambush enemies occupy the final 16 IDs of the block
    int start = baseId + 32 + (difficulty.level * 4);
    return id >= start && id < start + 4;
  }
}
