import { Game } from '@core/racing/domain/entities/Game'; import type { LeagueScoringConfig } from '@core/racing/domain/entities/LeagueScoringConfig'; import { Season } from '@core/racing/domain/entities/season/Season'; import type { Logger } from '@core/shared/domain/Logger'; import { InMemoryChampionshipStandingRepository, InMemoryGameRepository, InMemoryLeagueScoringConfigRepository, InMemorySeasonRepository, } from '../racing/persistence/inmemory/InMemoryScoringRepositories'; import { getLeagueScoringPresetById } from './LeagueScoringPresets'; /* eslint-disable @typescript-eslint/no-unused-vars */ class SilentLogger implements Logger { private getTimestamp(): string { return new Date().toISOString(); } debug(..._args: unknown[]): void { // console.debug(`[${this.getTimestamp()}]`, ...args); } info(..._args: unknown[]): void { // console.info(`[${this.getTimestamp()}]`, ...args); } warn(..._args: unknown[]): void { // console.warn(`[${this.getTimestamp()}]`, ...args); } error(..._args: unknown[]): void { // console.error(`[${this.getTimestamp()}]`, ...args); } } export function createSprintMainDemoScoringSetup(params: { leagueId: string; seasonId?: string; }): { gameRepo: InMemoryGameRepository; seasonRepo: InMemorySeasonRepository; scoringConfigRepo: InMemoryLeagueScoringConfigRepository; championshipStandingRepo: InMemoryChampionshipStandingRepository; seasonId: string; championshipId: string; } { const { leagueId } = params; const seasonId = params.seasonId ?? 'season-sprint-main-demo'; const championshipId = 'driver-champ'; const logger = new SilentLogger(); const game = Game.create({ id: 'iracing', name: 'iRacing' }); const season = Season.create({ id: seasonId, leagueId, gameId: game.id.toString(), name: 'Sprint + Main Demo Season', year: 2025, order: 1, status: 'active', startDate: new Date('2025-01-01'), endDate: new Date('2025-12-31'), }); const preset = getLeagueScoringPresetById('sprint-main-driver'); if (!preset) { throw new Error('Missing sprint-main-driver scoring preset'); } const leagueScoringConfig: LeagueScoringConfig = preset.createConfig({ seasonId: season.id, }); const gameRepo = new InMemoryGameRepository(logger, [game]); const seasonRepo = new InMemorySeasonRepository(logger, [season]); const scoringConfigRepo = new InMemoryLeagueScoringConfigRepository(logger, [ leagueScoringConfig, ]); const championshipStandingRepo = new InMemoryChampionshipStandingRepository(logger); return { gameRepo, seasonRepo, scoringConfigRepo, championshipStandingRepo, seasonId: season.id, championshipId, }; }