fix issues in core

This commit is contained in:
2025-12-23 15:38:50 +01:00
parent df5c20c5cc
commit 120d3bb1a1
125 changed files with 1005 additions and 793 deletions

View File

@@ -39,10 +39,11 @@ export class RaceResultGenerator {
// Generate results
const results: Result[] = [];
for (let i = 0; i < driverPerformances.length; i++) {
const { driverId } = driverPerformances[i];
const position = i + 1;
const startPosition = qualiPerformances.findIndex(p => p.driverId === driverId) + 1;
for (const [index, performance] of driverPerformances.entries()) {
const driverId = performance.driverId;
const position = index + 1;
const startPosition =
qualiPerformances.findIndex(p => p.driverId === driverId) + 1;
// Generate realistic lap times (90-120 seconds for a lap)
const baseLapTime = 90000 + Math.random() * 30000;

View File

@@ -40,10 +40,11 @@ export class RaceResultGeneratorWithIncidents {
// Generate results
const results: ResultWithIncidents[] = [];
for (let i = 0; i < driverPerformances.length; i++) {
const { driverId } = driverPerformances[i];
const position = i + 1;
const startPosition = qualiPerformances.findIndex(p => p.driverId === driverId) + 1;
for (const [index, performance] of driverPerformances.entries()) {
const driverId = performance.driverId;
const position = index + 1;
const startPosition =
qualiPerformances.findIndex(p => p.driverId === driverId) + 1;
// Generate realistic lap times (90-120 seconds for a lap)
const baseLapTime = 90000 + Math.random() * 30000;
@@ -118,7 +119,7 @@ export class RaceResultGeneratorWithIncidents {
/**
* Select appropriate incident type based on context
*/
private static selectIncidentType(position: number, totalDrivers: number, incidentIndex: number): IncidentType {
private static selectIncidentType(position: number, totalDrivers: number, _incidentIndex: number): IncidentType {
// Different incident types have different probabilities
const incidentProbabilities: Array<{ type: IncidentType; weight: number }> = [
{ type: 'track_limits', weight: 40 }, // Most common
@@ -153,9 +154,8 @@ export class RaceResultGeneratorWithIncidents {
/**
* Select appropriate lap for incident
*/
private static selectIncidentLap(incidentNumber: number, totalIncidents: number): number {
private static selectIncidentLap(incidentNumber: number, _totalIncidents: number): number {
// Spread incidents throughout the race
const raceLaps = 20; // Assume 20 lap race
const lapRanges = [
{ min: 1, max: 5 }, // Early race
{ min: 6, max: 12 }, // Mid race
@@ -164,8 +164,7 @@ export class RaceResultGeneratorWithIncidents {
// Distribute incidents across race phases
const phaseIndex = Math.min(incidentNumber - 1, lapRanges.length - 1);
const range = lapRanges[phaseIndex];
const range = lapRanges[phaseIndex] ?? lapRanges[0]!;
return Math.floor(Math.random() * (range.max - range.min + 1)) + range.min;
}
@@ -228,8 +227,9 @@ export class RaceResultGeneratorWithIncidents {
],
};
const options = descriptions[type] || descriptions.other;
return options[Math.floor(Math.random() * options.length)];
const options = descriptions[type] ?? descriptions.other;
const selected = options[Math.floor(Math.random() * options.length)];
return selected ?? descriptions.other[0]!;
}
/**