wip
This commit is contained in:
@@ -8,11 +8,27 @@ import type {
|
||||
LeagueScoringPresetProvider,
|
||||
LeagueScoringPresetDTO,
|
||||
} from '../ports/LeagueScoringPresetProvider';
|
||||
import {
|
||||
LeagueVisibility,
|
||||
MIN_RANKED_LEAGUE_DRIVERS,
|
||||
} from '../../domain/value-objects/LeagueVisibility';
|
||||
|
||||
/**
|
||||
* League visibility/ranking mode.
|
||||
* - 'ranked' (or legacy 'public'): Competitive, public, affects driver ratings. Min 10 drivers.
|
||||
* - 'unranked' (or legacy 'private'): Casual with friends, no rating impact.
|
||||
*/
|
||||
export type LeagueVisibilityInput = 'ranked' | 'unranked' | 'public' | 'private';
|
||||
|
||||
export interface CreateLeagueWithSeasonAndScoringCommand {
|
||||
name: string;
|
||||
description?: string;
|
||||
visibility: 'public' | 'private';
|
||||
/**
|
||||
* League visibility/ranking mode.
|
||||
* - 'ranked' (or legacy 'public'): Competitive, public, affects ratings. Requires min 10 drivers.
|
||||
* - 'unranked' (or legacy 'private'): Casual with friends, no rating impact.
|
||||
*/
|
||||
visibility: LeagueVisibilityInput;
|
||||
ownerId: string;
|
||||
gameId: string;
|
||||
maxDrivers?: number;
|
||||
@@ -137,5 +153,20 @@ export class CreateLeagueWithSeasonAndScoringUseCase {
|
||||
if (command.maxDrivers !== undefined && command.maxDrivers <= 0) {
|
||||
throw new Error('maxDrivers must be greater than 0 when provided');
|
||||
}
|
||||
|
||||
// Validate visibility-specific constraints
|
||||
const visibility = LeagueVisibility.fromString(command.visibility);
|
||||
|
||||
if (visibility.isRanked()) {
|
||||
// Ranked (public) leagues require minimum 10 drivers for competitive integrity
|
||||
const driverCount = command.maxDrivers ?? 0;
|
||||
if (driverCount < MIN_RANKED_LEAGUE_DRIVERS) {
|
||||
throw new Error(
|
||||
`Ranked leagues require at least ${MIN_RANKED_LEAGUE_DRIVERS} drivers. ` +
|
||||
`Current setting: ${driverCount}. ` +
|
||||
`For smaller groups, consider creating an Unranked (Friends) league instead.`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user