fix issues in core

This commit is contained in:
2025-12-23 11:25:08 +01:00
parent 1efd971032
commit 2854ae3c5c
113 changed files with 1142 additions and 458 deletions

View File

@@ -1,7 +1,7 @@
import type { ChampionshipConfig } from '../types/ChampionshipConfig';
import type { SessionType } from '../types/SessionType';
import type { ParticipantRef } from '../types/ParticipantRef';
import type { Result } from '../entities/Result';
import type { Result } from '../entities/result/Result';
import type { Penalty } from '../entities/Penalty';
import type { BonusRule } from '../types/BonusRule';
import type { ChampionshipType } from '../types/ChampionshipType';
@@ -50,9 +50,9 @@ export class EventScoringService
const penaltyByDriver = new Map<string, number>();
for (const result of results) {
const driverId = result.driverId;
const driverId = result.driverId.toString();
const currentBase = baseByDriver.get(driverId) ?? 0;
const added = pointsTable.getPointsForPosition(result.position);
const added = pointsTable.getPointsForPosition(result.position.toNumber());
baseByDriver.set(driverId, currentBase + added);
}
@@ -112,7 +112,7 @@ export class EventScoringService
): void {
if (results.length === 0) return;
const sortedByLap = [...results].sort((a, b) => a.fastestLap - b.fastestLap);
const sortedByLap = [...results].sort((a, b) => a.fastestLap.toNumber() - b.fastestLap.toNumber());
const best = sortedByLap[0];
if (!best) {
@@ -121,13 +121,13 @@ export class EventScoringService
const requiresTop = rule.requiresFinishInTopN;
if (typeof requiresTop === 'number') {
if (best.position <= 0 || best.position > requiresTop) {
if (best.position.toNumber() <= 0 || best.position.toNumber() > requiresTop) {
return;
}
}
const current = bonusByDriver.get(best.driverId) ?? 0;
bonusByDriver.set(best.driverId, current + rule.points);
const current = bonusByDriver.get(best.driverId.toString()) ?? 0;
bonusByDriver.set(best.driverId.toString(), current + rule.points);
}
private aggregatePenalties(penalties: Penalty[]): Map<string, number> {