streamline components
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import type { LeagueConfigFormModel } from '@/lib/types/LeagueConfigFormModel';
|
||||
import type { LeagueScoringPresetViewModel } from '@/lib/view-models/LeagueScoringPresetViewModel';
|
||||
|
||||
export interface CustomPointsConfig {
|
||||
racePoints: number[];
|
||||
poleBonusPoints: number;
|
||||
fastestLapPoints: number;
|
||||
leaderLapPoints: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* ScoringConfigurationViewModel
|
||||
*
|
||||
* View model for scoring configuration including presets and custom points
|
||||
*/
|
||||
export class ScoringConfigurationViewModel {
|
||||
readonly patternId?: string;
|
||||
readonly customScoringEnabled: boolean;
|
||||
readonly customPoints?: CustomPointsConfig;
|
||||
readonly currentPreset?: LeagueScoringPresetViewModel;
|
||||
|
||||
constructor(
|
||||
config: LeagueConfigFormModel['scoring'],
|
||||
presets: LeagueScoringPresetViewModel[],
|
||||
customPoints?: CustomPointsConfig
|
||||
) {
|
||||
this.patternId = config.patternId;
|
||||
this.customScoringEnabled = config.customScoringEnabled || false;
|
||||
this.customPoints = customPoints;
|
||||
this.currentPreset = config.patternId
|
||||
? presets.find(p => p.id === config.patternId)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active points configuration
|
||||
*/
|
||||
getActivePointsConfig(): CustomPointsConfig {
|
||||
if (this.customScoringEnabled && this.customPoints) {
|
||||
return this.customPoints;
|
||||
}
|
||||
// Return default points if no custom config
|
||||
return {
|
||||
racePoints: [25, 18, 15, 12, 10, 8, 6, 4, 2, 1],
|
||||
poleBonusPoints: 1,
|
||||
fastestLapPoints: 1,
|
||||
leaderLapPoints: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user