import type { DomainService } from '@core/shared/domain/Service';

export type SkillLevel = 'beginner' | 'intermediate' | 'advanced' | 'pro';

/**
 * Domain service for determining skill level based on rating.
 * This encapsulates the business rule for skill tier classification.
 */
export class SkillLevelService implements DomainService {
  readonly serviceName = 'SkillLevelService';
  /**
   * Map driver rating to skill level band.
   * Business rule: iRating thresholds determine skill tiers.
   */
  static getSkillLevel(rating: number): SkillLevel {
    if (rating >= 3000) return 'pro';
    if (rating >= 2500) return 'advanced';
    if (rating >= 1800) return 'intermediate';
    return 'beginner';
  }

  /**
   * Map average team rating to performance level.
   * Business rule: Team ratings use higher thresholds than individual drivers.
   */
  static getTeamPerformanceLevel(averageRating: number | null): SkillLevel {
    if (averageRating === null) {
      return 'beginner';
    }
    if (averageRating >= 4500) return 'pro';
    if (averageRating >= 3000) return 'advanced';
    if (averageRating >= 2000) return 'intermediate';
    return 'beginner';
  }
}