ISSUE-057 - Progress on building prototyping tools.

New reducers for event slice that allow increasing of car distances, awarding fastest laps, and changing the statuses of cars.
Updating more types to enums, which are just better in most cases as far as I can tell.
This commit is contained in:
Kyle Geib committed 2022-02-22 19:12:29 -05:00
1 parent 0d41fbc59a
commit edeba37c6d
13 files changed
+301 -77

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
import { cloneDeep } from "lodash";
import { drivers, teams, teamNumberStyles, teamFlagStyles, teamGemStyles } from "../domain/data/teams";
import { DriverId, Team, TeamId } from "../types/state";
import { DriverId, TeamId } from "../types/state";
/**
* Prefer getting data from teams.ts through these simple getter functions.
+16 -2
View File
@@ -1,4 +1,3 @@
import { random } from "lodash";
import { Car, Grid } from "../types/state";
import { Meters } from "../types/util";
@@ -13,7 +12,7 @@ export function timeDiff(
* 61.015 m/s average. So, let's do that.
*/
return random(0.95, 1.05) * ((front - back) / 61.015);
return (front - back) / 61.015;
}
@@ -27,3 +26,18 @@ export function getCarAtPos(
}
return foundCar;
}
/**
* Helper function returns a map of driver ids to their index in the Grid. This
* removes the need for repeating find functions over and over again when making
* bulk changes to a list of cars.
* @param grid Master list of cars
* @returns
*/
export function driverToGridMap(grid: Grid) {
const gridMap: { [driverId: string]: number } = {};
grid.forEach((car, index) => {
gridMap[car.driver.id] = index;
});
return gridMap;
}