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

/**
 * Domain Event: MainRaceCompleted
 *
 * Fired when the main race session of a race event is completed.
 * This triggers immediate performance summary notifications to drivers.
 */
export interface MainRaceCompletedEventData {
  raceEventId: string;
  sessionId: string;
  leagueId: string;
  seasonId: string;
  completedAt: Date;
  driverIds: string[]; // Drivers who participated in the main race
}

export class MainRaceCompletedEvent implements DomainEvent<MainRaceCompletedEventData> {
  readonly eventType = 'MainRaceCompleted';
  readonly aggregateId: string;
  readonly eventData: MainRaceCompletedEventData;
  readonly occurredAt: Date;

  constructor(data: MainRaceCompletedEventData) {
    this.aggregateId = data.raceEventId;
    this.eventData = { ...data };
    this.occurredAt = new Date();
  }
}