Skip to content
Snippets Groups Projects
Commit 6ea0b32e authored by Zandor Smith's avatar Zandor Smith :computer:
Browse files

More fixes after team swap.

parent 6929223c
No related branches found
No related tags found
No related merge requests found
Pipeline #449998 passed
......@@ -70,10 +70,17 @@ function combineDriverPoints2024(points) {
}
function calculateDriverPoints2025(points, races, teams, results) {
const drivers = Object.values(teams).map((team) => team.drivers).reduce((acc, val) => acc.concat(val), []);
const drivers = Object.values(teams).map((team) => {
return team.drivers.map((driver) => {
return driver.split("-")[0];
});
}).reduce((acc, val) => acc.concat(val), []);
let driverPoints = {};
drivers.forEach((driver) => {
driverPoints[driver] = getCurrentPointsOfDriver(driver, points, races, results);
if(!driverPoints[driver]) {
driverPoints[driver] = 0;
}
driverPoints[driver] += getCurrentPointsOfDriver(driver, points, races, results);
});
let driverPointsSorted = {};
Object.entries(driverPoints).sort((a, b) => {
......
......@@ -35,14 +35,18 @@ function getPointsOfDriverForRace(driver, points, race, results) {
if(!result) {
return null;
}
const position = result.positions.indexOf(driver);
const driverShort = driver.split("-")[0];
const positionsNoTeam = result.positions.map((position) => {
return position.split("-")[0];
});
const position = positionsNoTeam.indexOf(driverShort) + 1;
if(position === -1) {
return 0;
}
const positionPoints = pointsSystem.points.find((points, index) => {
return index === position;
return index + 1 === position;
});
if(result.fastestLap === driver) {
if(result.fastestLap === driverShort) {
return positionPoints + pointsSystem.fastestLap;
}
return positionPoints;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment