This commit is contained in:
2025-12-11 11:25:22 +01:00
parent 6a427eab57
commit e4c1be628d
86 changed files with 1222 additions and 736 deletions

View File

@@ -1,10 +1,12 @@
/**
* Domain Entity: Track
*
*
* Represents a racing track/circuit in the GridPilot platform.
* Immutable entity with factory methods and domain validation.
*/
import { RacingDomainValidationError } from '../errors/RacingDomainError';
export type TrackCategory = 'oval' | 'road' | 'street' | 'dirt';
export type TrackDifficulty = 'beginner' | 'intermediate' | 'advanced' | 'expert';
@@ -87,27 +89,27 @@ export class Track {
gameId: string;
}): void {
if (!props.id || props.id.trim().length === 0) {
throw new Error('Track ID is required');
throw new RacingDomainValidationError('Track ID is required');
}
if (!props.name || props.name.trim().length === 0) {
throw new Error('Track name is required');
throw new RacingDomainValidationError('Track name is required');
}
if (!props.country || props.country.trim().length === 0) {
throw new Error('Track country is required');
throw new RacingDomainValidationError('Track country is required');
}
if (props.lengthKm <= 0) {
throw new Error('Track length must be positive');
throw new RacingDomainValidationError('Track length must be positive');
}
if (props.turns < 0) {
throw new Error('Track turns cannot be negative');
throw new RacingDomainValidationError('Track turns cannot be negative');
}
if (!props.gameId || props.gameId.trim().length === 0) {
throw new Error('Game ID is required');
throw new RacingDomainValidationError('Game ID is required');
}
}