wip
This commit is contained in:
32
packages/racing/domain/services/SkillLevelService.ts
Normal file
32
packages/racing/domain/services/SkillLevelService.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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 {
|
||||
/**
|
||||
* 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';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user