import { DomainEvent } from './domain-event.base';
import { LeaderboardType } from '../value-objects/leaderboard-type.enum';

export interface LeaderboardRefreshedPayload {
  leaderboardType: LeaderboardType;
  periodKey: string;
  totalParticipants: number;
  topScore: number;
  refreshedAt: Date;
}

/**
 * 榜单刷新完成事件
 */
export class LeaderboardRefreshedEvent extends DomainEvent {
  constructor(private readonly payload: LeaderboardRefreshedPayload) {
    super();
  }

  get eventType(): string {
    return 'LeaderboardRefreshed';
  }

  get aggregateId(): string {
    return `${this.payload.leaderboardType}_${this.payload.periodKey}`;
  }

  get aggregateType(): string {
    return 'Leaderboard';
  }

  toPayload(): LeaderboardRefreshedPayload {
    return { ...this.payload };
  }
}
