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:
1 parent
0d41fbc59a
commit
edeba37c6d
13 files changed
+288
-64
No files matched your search
@@ -0,0 +1,17 @@
|
|||||||
|
import { theme } from "../../../shared/theme";
|
||||||
|
import { MockupBlock } from "../../Common/MockupBlock.styled";
|
||||||
|
import { TimingBoardLayout } from "./styles";
|
||||||
|
import { TimingTower } from "./TimingTower";
|
||||||
|
|
||||||
|
export function TimingBoard() {
|
||||||
|
return (
|
||||||
|
<TimingBoardLayout>
|
||||||
|
<MockupBlock
|
||||||
|
height="73px"
|
||||||
|
width={`${theme.design.timingTower.rowLeftHalfWidthPx}px`}
|
||||||
|
color="black"
|
||||||
|
/>
|
||||||
|
<TimingTower />
|
||||||
|
</TimingBoardLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ import {
|
|||||||
|
|
||||||
export function TimingTower() {
|
export function TimingTower() {
|
||||||
|
|
||||||
const { lastUpdate, grid, trackLength, leaderGridSpot } = useSelector(eventSelector);
|
const { lastUpdate, grid, trackLength } = useSelector(eventSelector);
|
||||||
const { timingBoard: { timingTower }, timingBoard: { timingTower: { splitsMode } } } = useSelector(
|
const { timingBoard: { timingTower }, timingBoard: { timingTower: { splitsMode } } } = useSelector(
|
||||||
broadcastGraphicsSelector,
|
broadcastGraphicsSelector,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ const Rounded = styled.div<RoundedProp>`
|
|||||||
roundedCornerTop && css`border-top-right-radius: ${roundedCornerTop}px;`}
|
roundedCornerTop && css`border-top-right-radius: ${roundedCornerTop}px;`}
|
||||||
${({ roundedCornerBottom }) =>
|
${({ roundedCornerBottom }) =>
|
||||||
roundedCornerBottom && css`border-bottom-right-radius: ${roundedCornerBottom}px;`}
|
roundedCornerBottom && css`border-bottom-right-radius: ${roundedCornerBottom}px;`}
|
||||||
|
transition: border-top-right-radius 500ms, border-bottom-right-radius 500ms;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const RowLeftHalf = styled(Rounded)`
|
export const RowLeftHalf = styled(Rounded)`
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./TimingBoard";
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
export const TimingBoardLayout = styled.div`
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: flex-start;
|
||||||
|
`;
|
||||||
+64
-4
@@ -1,19 +1,27 @@
|
|||||||
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||||
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
|
import { Split } from "@bedrock-layout/split";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
|
||||||
|
|
||||||
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
||||||
import { setTimingTowerSplitsMode } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
import { setTimingTowerSplitsMode } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
||||||
|
import { eventSelector } from "../../../../features/event/eventSelector";
|
||||||
import { refreshRunningOrder } from "../../../../features/event/eventSlice";
|
import { increaseDistance, refreshRunningOrder, setCarStatus } from "../../../../features/event/eventSlice";
|
||||||
import { BGTimingTowerSplitsMode } from "../../../../types/state";
|
import { BGTimingTowerSplitsMode, CarStatus } from "../../../../types/state";
|
||||||
|
import { GridSelection } from "../GridSelection";
|
||||||
|
|
||||||
import { ClickSpan } from "./styles";
|
import { ClickSpan } from "./styles";
|
||||||
|
|
||||||
export function TimingTowerPrototypeControls() {
|
export function TimingTowerPrototypeControls() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const { selectedCars } = useSelector(broadcastDirectorSelector);
|
||||||
const { timingBoard: { timingTower: { splitsMode } } } = useSelector(broadcastGraphicsSelector);
|
const { timingBoard: { timingTower: { splitsMode } } } = useSelector(broadcastGraphicsSelector);
|
||||||
|
const { grid } = useSelector(eventSelector);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InlineCluster gutter="md">
|
<Split gutter="md">
|
||||||
|
<InlineCluster as={PadBox} padding="md" gutter="md">
|
||||||
<ClickSpan onClick={() => dispatch(refreshRunningOrder())}>
|
<ClickSpan onClick={() => dispatch(refreshRunningOrder())}>
|
||||||
Refresh Running Order
|
Refresh Running Order
|
||||||
</ClickSpan>
|
</ClickSpan>
|
||||||
@@ -28,6 +36,58 @@ export function TimingTowerPrototypeControls() {
|
|||||||
>
|
>
|
||||||
Splits Mode = {BGTimingTowerSplitsMode[splitsMode]}
|
Splits Mode = {BGTimingTowerSplitsMode[splitsMode]}
|
||||||
</ClickSpan>
|
</ClickSpan>
|
||||||
|
<ClickSpan
|
||||||
|
onClick={() => {
|
||||||
|
dispatch(increaseDistance({
|
||||||
|
cars: selectedCars,
|
||||||
|
distance: 200,
|
||||||
|
randomness: 0,
|
||||||
|
usePerformance: false,
|
||||||
|
}));
|
||||||
|
dispatch(refreshRunningOrder());
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
+200m to cars
|
||||||
|
</ClickSpan>
|
||||||
|
<ClickSpan
|
||||||
|
onClick={() => {
|
||||||
|
dispatch(increaseDistance({
|
||||||
|
cars: grid,
|
||||||
|
distance: 100,
|
||||||
|
randomness: 0.05,
|
||||||
|
usePerformance: true,
|
||||||
|
}));
|
||||||
|
dispatch(refreshRunningOrder());
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
+100m performance to all
|
||||||
|
</ClickSpan>
|
||||||
|
<ClickSpan
|
||||||
|
onClick={() => {
|
||||||
|
dispatch(setCarStatus({
|
||||||
|
cars: selectedCars,
|
||||||
|
status: CarStatus.Retired,
|
||||||
|
}));
|
||||||
|
dispatch(refreshRunningOrder());
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Retire cars
|
||||||
|
</ClickSpan>
|
||||||
|
<ClickSpan
|
||||||
|
onClick={() => {
|
||||||
|
dispatch(setCarStatus({
|
||||||
|
cars: selectedCars,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
}));
|
||||||
|
dispatch(refreshRunningOrder());
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Un-retire cars
|
||||||
|
</ClickSpan>
|
||||||
</InlineCluster>
|
</InlineCluster>
|
||||||
|
<PadBox padding="md">
|
||||||
|
<GridSelection />
|
||||||
|
</PadBox>
|
||||||
|
</Split>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ import { AngledFlagPrototypeControls } from "./PrototypingControls/AngledFlagPro
|
|||||||
import { ChyronContainer } from "../BroadcastGraphics/Chyrons/Container";
|
import { ChyronContainer } from "../BroadcastGraphics/Chyrons/Container";
|
||||||
import { VenetianBlindsWorkspace } from "./CustomWorkSpaces/VenetianBlindsWorkspace";
|
import { VenetianBlindsWorkspace } from "./CustomWorkSpaces/VenetianBlindsWorkspace";
|
||||||
import { VenetianBlindsPrototypeControls } from "./PrototypingControls/VenetianBlindsPrototype";
|
import { VenetianBlindsPrototypeControls } from "./PrototypingControls/VenetianBlindsPrototype";
|
||||||
import { TimingTower } from "../BroadcastGraphics/TimingBoard/TimingTower";
|
import { TimingBoard } from "../BroadcastGraphics/TimingBoard";
|
||||||
import { TimingTowerPrototypeControls } from "./PrototypingControls/TimingTowerPrototype";
|
import { TimingTowerPrototypeControls } from "./PrototypingControls/TimingTowerPrototype";
|
||||||
|
|
||||||
const WORKSPACE_LIST_WIDTH = 180;
|
const WORKSPACE_LIST_WIDTH = 180;
|
||||||
@@ -94,7 +94,7 @@ export default function Workspaces() {
|
|||||||
<Route path="timingBoard" element={
|
<Route path="timingBoard" element={
|
||||||
<Workspace
|
<Workspace
|
||||||
workspaceId="timingBoard"
|
workspaceId="timingBoard"
|
||||||
previewContent={<TimingTower />}
|
previewContent={<TimingBoard />}
|
||||||
prototypeControls={<TimingTowerPrototypeControls />}
|
prototypeControls={<TimingTowerPrototypeControls />}
|
||||||
bleedover={500}
|
bleedover={500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -13,60 +13,70 @@ export const teams: {[id: string]: Team} = {
|
|||||||
shortName: "Alfa Romeo",
|
shortName: "Alfa Romeo",
|
||||||
fullName: "Alfa Romeo F1 Team ORLEN",
|
fullName: "Alfa Romeo F1 Team ORLEN",
|
||||||
nationality: "CHE",
|
nationality: "CHE",
|
||||||
|
performance: 1.007,
|
||||||
},
|
},
|
||||||
alphaTauri: {
|
alphaTauri: {
|
||||||
id: "alphaTauri",
|
id: "alphaTauri",
|
||||||
shortName: "AlphaTauri",
|
shortName: "AlphaTauri",
|
||||||
fullName: "Scuderia AlphaTauri",
|
fullName: "Scuderia AlphaTauri",
|
||||||
nationality: "ITA",
|
nationality: "ITA",
|
||||||
|
performance: 1.016,
|
||||||
},
|
},
|
||||||
alpine: {
|
alpine: {
|
||||||
id: "alpine",
|
id: "alpine",
|
||||||
shortName: "Alpine",
|
shortName: "Alpine",
|
||||||
fullName: "Alpine F1 Team",
|
fullName: "Alpine F1 Team",
|
||||||
nationality: "FRA",
|
nationality: "FRA",
|
||||||
|
performance: 1.014,
|
||||||
},
|
},
|
||||||
astonMartin: {
|
astonMartin: {
|
||||||
id: "astonMartin",
|
id: "astonMartin",
|
||||||
shortName: "Aston Martin",
|
shortName: "Aston Martin",
|
||||||
fullName: "Aston Martin Cognizant Formula One Team",
|
fullName: "Aston Martin Cognizant Formula One Team",
|
||||||
nationality: "GBR",
|
nationality: "GBR",
|
||||||
|
performance: 1.012,
|
||||||
},
|
},
|
||||||
ferrari: {
|
ferrari: {
|
||||||
id: "ferrari",
|
id: "ferrari",
|
||||||
shortName: "Ferrari",
|
shortName: "Ferrari",
|
||||||
fullName: "Scuderia Ferrari",
|
fullName: "Scuderia Ferrari",
|
||||||
nationality: "ITA",
|
nationality: "ITA",
|
||||||
|
performance: 1.021,
|
||||||
},
|
},
|
||||||
haas: {
|
haas: {
|
||||||
id: "haas",
|
id: "haas",
|
||||||
shortName: "Haas F1 Team",
|
shortName: "Haas F1 Team",
|
||||||
fullName: "Uralkali Haas F1 Team",
|
fullName: "Uralkali Haas F1 Team",
|
||||||
nationality: "USA",
|
nationality: "USA",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
mclaren: {
|
mclaren: {
|
||||||
id: "mclaren",
|
id: "mclaren",
|
||||||
shortName: "McLaren",
|
shortName: "McLaren",
|
||||||
fullName: "McLaren F1 Team",
|
fullName: "McLaren F1 Team",
|
||||||
nationality: "GBR",
|
nationality: "GBR",
|
||||||
|
performance: 1.020,
|
||||||
},
|
},
|
||||||
mercedes: {
|
mercedes: {
|
||||||
id: "mercedes",
|
id: "mercedes",
|
||||||
shortName: "Mercedes",
|
shortName: "Mercedes",
|
||||||
fullName: "Mercedes-AMG Petronas Formula One Team",
|
fullName: "Mercedes-AMG Petronas Formula One Team",
|
||||||
nationality: "DEU",
|
nationality: "DEU",
|
||||||
|
performance: 1.025,
|
||||||
},
|
},
|
||||||
redBull: {
|
redBull: {
|
||||||
id: "redBull",
|
id: "redBull",
|
||||||
shortName: "Red Bull Racing",
|
shortName: "Red Bull Racing",
|
||||||
fullName: "Red Bull Racing",
|
fullName: "Red Bull Racing",
|
||||||
nationality: "AUT",
|
nationality: "AUT",
|
||||||
|
performance: 1.024,
|
||||||
},
|
},
|
||||||
williams: {
|
williams: {
|
||||||
id: "williams",
|
id: "williams",
|
||||||
shortName: "Williams",
|
shortName: "Williams",
|
||||||
fullName: "Williams Racing",
|
fullName: "Williams Racing",
|
||||||
nationality: "GBR",
|
nationality: "GBR",
|
||||||
|
performance: 1.008,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -84,6 +94,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false, // TBD
|
yellowTCam: false, // TBD
|
||||||
initials: "ALB",
|
initials: "ALB",
|
||||||
nationality: "THA",
|
nationality: "THA",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
alonso: {
|
alonso: {
|
||||||
id: "alonso",
|
id: "alonso",
|
||||||
@@ -94,6 +105,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false,
|
yellowTCam: false,
|
||||||
initials: "ALO",
|
initials: "ALO",
|
||||||
nationality: "ESP",
|
nationality: "ESP",
|
||||||
|
performance: 1.003,
|
||||||
},
|
},
|
||||||
bottas: {
|
bottas: {
|
||||||
id: "bottas",
|
id: "bottas",
|
||||||
@@ -104,6 +116,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: true,
|
yellowTCam: true,
|
||||||
initials: "BOT",
|
initials: "BOT",
|
||||||
nationality: "FIN",
|
nationality: "FIN",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
gasly: {
|
gasly: {
|
||||||
id: "gasly",
|
id: "gasly",
|
||||||
@@ -114,6 +127,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: true,
|
yellowTCam: true,
|
||||||
initials: "GAS",
|
initials: "GAS",
|
||||||
nationality: "FRA",
|
nationality: "FRA",
|
||||||
|
performance: 1.020,
|
||||||
},
|
},
|
||||||
giovinazzi: {
|
giovinazzi: {
|
||||||
id: "giovinazzi",
|
id: "giovinazzi",
|
||||||
@@ -124,6 +138,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: true,
|
yellowTCam: true,
|
||||||
initials: "GIO",
|
initials: "GIO",
|
||||||
nationality: "ITA",
|
nationality: "ITA",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
hamilton: {
|
hamilton: {
|
||||||
id: "hamilton",
|
id: "hamilton",
|
||||||
@@ -134,6 +149,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false,
|
yellowTCam: false,
|
||||||
initials: "HAM",
|
initials: "HAM",
|
||||||
nationality: "GBR",
|
nationality: "GBR",
|
||||||
|
performance: 1.010,
|
||||||
},
|
},
|
||||||
kubica: {
|
kubica: {
|
||||||
id: "kubica",
|
id: "kubica",
|
||||||
@@ -144,6 +160,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false,
|
yellowTCam: false,
|
||||||
initials: "KUB",
|
initials: "KUB",
|
||||||
nationality: "POL",
|
nationality: "POL",
|
||||||
|
performance: 0.980,
|
||||||
},
|
},
|
||||||
latifi: {
|
latifi: {
|
||||||
id: "latifi",
|
id: "latifi",
|
||||||
@@ -154,6 +171,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: true,
|
yellowTCam: true,
|
||||||
initials: "LAT",
|
initials: "LAT",
|
||||||
nationality: "CAN",
|
nationality: "CAN",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
leclerc: {
|
leclerc: {
|
||||||
id: "leclerc",
|
id: "leclerc",
|
||||||
@@ -164,6 +182,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false,
|
yellowTCam: false,
|
||||||
initials: "LEC",
|
initials: "LEC",
|
||||||
nationality: "MCO",
|
nationality: "MCO",
|
||||||
|
performance: 1.005,
|
||||||
},
|
},
|
||||||
mazepin: {
|
mazepin: {
|
||||||
id: "mazepin",
|
id: "mazepin",
|
||||||
@@ -174,6 +193,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false,
|
yellowTCam: false,
|
||||||
initials: "MAZ",
|
initials: "MAZ",
|
||||||
nationality: "RAF",
|
nationality: "RAF",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
norris: {
|
norris: {
|
||||||
id: "norris",
|
id: "norris",
|
||||||
@@ -184,6 +204,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: true,
|
yellowTCam: true,
|
||||||
initials: "NOR",
|
initials: "NOR",
|
||||||
nationality: "GBR",
|
nationality: "GBR",
|
||||||
|
performance: 1.009,
|
||||||
},
|
},
|
||||||
ocon: {
|
ocon: {
|
||||||
id: "ocon",
|
id: "ocon",
|
||||||
@@ -194,6 +215,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: true,
|
yellowTCam: true,
|
||||||
initials: "OCO",
|
initials: "OCO",
|
||||||
nationality: "FRA",
|
nationality: "FRA",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
perez: {
|
perez: {
|
||||||
id: "perez",
|
id: "perez",
|
||||||
@@ -204,6 +226,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: true,
|
yellowTCam: true,
|
||||||
initials: "PER",
|
initials: "PER",
|
||||||
nationality: "MEX",
|
nationality: "MEX",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
raikkonen: {
|
raikkonen: {
|
||||||
id: "raikkonen",
|
id: "raikkonen",
|
||||||
@@ -214,6 +237,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false,
|
yellowTCam: false,
|
||||||
initials: "RAI",
|
initials: "RAI",
|
||||||
nationality: "FIN",
|
nationality: "FIN",
|
||||||
|
performance: 1.002,
|
||||||
},
|
},
|
||||||
ricciardo: {
|
ricciardo: {
|
||||||
id: "ricciardo",
|
id: "ricciardo",
|
||||||
@@ -224,6 +248,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false,
|
yellowTCam: false,
|
||||||
initials: "RIC",
|
initials: "RIC",
|
||||||
nationality: "AUS",
|
nationality: "AUS",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
russell: {
|
russell: {
|
||||||
id: "russell",
|
id: "russell",
|
||||||
@@ -234,6 +259,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false,
|
yellowTCam: false,
|
||||||
initials: "RUS",
|
initials: "RUS",
|
||||||
nationality: "GBR",
|
nationality: "GBR",
|
||||||
|
performance: 1.016,
|
||||||
},
|
},
|
||||||
sainz: {
|
sainz: {
|
||||||
id: "sainz",
|
id: "sainz",
|
||||||
@@ -244,6 +270,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: true,
|
yellowTCam: true,
|
||||||
initials: "SAI",
|
initials: "SAI",
|
||||||
nationality: "ESP",
|
nationality: "ESP",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
schumacher: {
|
schumacher: {
|
||||||
id: "schumacher",
|
id: "schumacher",
|
||||||
@@ -254,6 +281,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: true,
|
yellowTCam: true,
|
||||||
initials: "MSC",
|
initials: "MSC",
|
||||||
nationality: "DEU",
|
nationality: "DEU",
|
||||||
|
performance: 1.025,
|
||||||
},
|
},
|
||||||
stroll: {
|
stroll: {
|
||||||
id: "stroll",
|
id: "stroll",
|
||||||
@@ -264,6 +292,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false,
|
yellowTCam: false,
|
||||||
initials: "STR",
|
initials: "STR",
|
||||||
nationality: "CAN",
|
nationality: "CAN",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
tsunoda: {
|
tsunoda: {
|
||||||
id: "tsunoda",
|
id: "tsunoda",
|
||||||
@@ -274,6 +303,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false,
|
yellowTCam: false,
|
||||||
initials: "TSU",
|
initials: "TSU",
|
||||||
nationality: "JPN",
|
nationality: "JPN",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
verstappen: {
|
verstappen: {
|
||||||
id: "verstappen",
|
id: "verstappen",
|
||||||
@@ -284,6 +314,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: false,
|
yellowTCam: false,
|
||||||
initials: "VER",
|
initials: "VER",
|
||||||
nationality: "NLD",
|
nationality: "NLD",
|
||||||
|
performance: 1.020,
|
||||||
},
|
},
|
||||||
vettel: {
|
vettel: {
|
||||||
id: "vettel",
|
id: "vettel",
|
||||||
@@ -294,6 +325,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: true,
|
yellowTCam: true,
|
||||||
initials: "VET",
|
initials: "VET",
|
||||||
nationality: "DEU",
|
nationality: "DEU",
|
||||||
|
performance: 1.003,
|
||||||
},
|
},
|
||||||
zhou: {
|
zhou: {
|
||||||
id: "zhou",
|
id: "zhou",
|
||||||
@@ -304,6 +336,7 @@ export const drivers: {[lastName: string]: Driver} = {
|
|||||||
yellowTCam: true,
|
yellowTCam: true,
|
||||||
initials: "ZHO",
|
initials: "ZHO",
|
||||||
nationality: "CHN",
|
nationality: "CHN",
|
||||||
|
performance: 1.000,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const initialState: RootState["broadcastGraphics"] = {
|
|||||||
relativePos: {},
|
relativePos: {},
|
||||||
openState: 0,
|
openState: 0,
|
||||||
statusIndicator: {
|
statusIndicator: {
|
||||||
mode: BGStatusIndicatorModes.NormalNarrow,
|
mode: BGStatusIndicatorModes.LapNarrow,
|
||||||
},
|
},
|
||||||
timingTower: {
|
timingTower: {
|
||||||
open: 1,
|
open: 1,
|
||||||
|
|||||||
@@ -1,7 +1,22 @@
|
|||||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
import { random } from "lodash";
|
||||||
|
|
||||||
import { CourseFlag, CarStatus, RootState, Tyre, TyreCompound, CarNotice } from "../../types/state";
|
import {
|
||||||
import { cloneDriver } from "../../utils/dataLookup";
|
CourseFlag,
|
||||||
|
CarStatus,
|
||||||
|
RootState,
|
||||||
|
Tyre,
|
||||||
|
TyreCompound,
|
||||||
|
CarNotice,
|
||||||
|
EventMode,
|
||||||
|
SectorFlag,
|
||||||
|
SafetyCarStatus,
|
||||||
|
VirtualSafetyCarStatus,
|
||||||
|
Car,
|
||||||
|
} from "../../types/state";
|
||||||
|
import { Meters } from "../../types/util";
|
||||||
|
import { cloneDriver, getTeam } from "../../utils/dataLookup";
|
||||||
|
import { driverToGridMap } from "../../utils/event";
|
||||||
|
|
||||||
const DEFAULT_TYRE: Tyre = {
|
const DEFAULT_TYRE: Tyre = {
|
||||||
compound: TyreCompound.Medium,
|
compound: TyreCompound.Medium,
|
||||||
@@ -9,16 +24,19 @@ const DEFAULT_TYRE: Tyre = {
|
|||||||
new: true,
|
new: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const GRID_POSITION_GAP: Meters = 8;
|
||||||
|
const POLE_TO_START: Meters = 10;
|
||||||
|
|
||||||
const initialState: RootState["event"] = {
|
const initialState: RootState["event"] = {
|
||||||
trackName: "Circuit de Spa-Franchorchamps",
|
trackName: "Circuit de Spa-Franchorchamps",
|
||||||
trackLength: 7004,
|
trackLength: 7004,
|
||||||
courseStatus: {
|
courseStatus: {
|
||||||
courseFlag: "green",
|
courseFlag: CourseFlag.Green,
|
||||||
sectorFlags: ["green", "green", "green"],
|
sectorFlags: [SectorFlag.Green, SectorFlag.Green, SectorFlag.Green],
|
||||||
safetyCar: "clear",
|
safetyCar: SafetyCarStatus.Clear,
|
||||||
virtualSafetyCar: "clear",
|
virtualSafetyCar: VirtualSafetyCarStatus.Clear,
|
||||||
},
|
},
|
||||||
mode: "race",
|
mode: EventMode.Race,
|
||||||
progress: {
|
progress: {
|
||||||
startTime: Date.now(),
|
startTime: Date.now(),
|
||||||
timeLimit: 60 * 60 * 2 * 1000,
|
timeLimit: 60 * 60 * 2 * 1000,
|
||||||
@@ -32,7 +50,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [CarNotice.FastestLap],
|
notices: [CarNotice.FastestLap],
|
||||||
distance: 2000 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 0,
|
||||||
driver: cloneDriver("verstappen"),
|
driver: cloneDriver("verstappen"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -40,7 +58,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 1900 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 1,
|
||||||
driver: cloneDriver("hamilton"),
|
driver: cloneDriver("hamilton"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -48,7 +66,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 1800 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 2,
|
||||||
driver: cloneDriver("bottas"),
|
driver: cloneDriver("bottas"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -56,7 +74,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Retired,
|
status: CarStatus.Retired,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 1700 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 3,
|
||||||
driver: cloneDriver("perez"),
|
driver: cloneDriver("perez"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -64,7 +82,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 1600 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 4,
|
||||||
driver: cloneDriver("sainz"),
|
driver: cloneDriver("sainz"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -72,7 +90,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Retired,
|
status: CarStatus.Retired,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 1500 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 5,
|
||||||
driver: cloneDriver("norris"),
|
driver: cloneDriver("norris"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -80,7 +98,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 1400 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 6,
|
||||||
driver: cloneDriver("leclerc"),
|
driver: cloneDriver("leclerc"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -88,15 +106,15 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 1300 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 7,
|
||||||
driver: cloneDriver("ricciardo"),
|
driver: cloneDriver("ricciardo"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
position: 9,
|
position: 9,
|
||||||
status: CarStatus.DidNotStart,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 1200 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 8,
|
||||||
driver: cloneDriver("gasly"),
|
driver: cloneDriver("gasly"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -104,7 +122,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 1100 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 9,
|
||||||
driver: cloneDriver("alonso"),
|
driver: cloneDriver("alonso"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -112,7 +130,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 1000 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 10,
|
||||||
driver: cloneDriver("ocon"),
|
driver: cloneDriver("ocon"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -120,7 +138,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 900 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 11,
|
||||||
driver: cloneDriver("vettel"),
|
driver: cloneDriver("vettel"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -128,7 +146,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 800 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 12,
|
||||||
driver: cloneDriver("stroll"),
|
driver: cloneDriver("stroll"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -136,7 +154,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 700 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 13,
|
||||||
driver: cloneDriver("tsunoda"),
|
driver: cloneDriver("tsunoda"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -144,7 +162,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 600 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 14,
|
||||||
driver: cloneDriver("russell"),
|
driver: cloneDriver("russell"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -152,7 +170,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 500 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 15,
|
||||||
driver: cloneDriver("raikkonen"),
|
driver: cloneDriver("raikkonen"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -160,7 +178,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 400 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 16,
|
||||||
driver: cloneDriver("latifi"),
|
driver: cloneDriver("latifi"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -168,7 +186,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 300 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 17,
|
||||||
driver: cloneDriver("giovinazzi"),
|
driver: cloneDriver("giovinazzi"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -176,7 +194,7 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 200 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 18,
|
||||||
driver: cloneDriver("schumacher"),
|
driver: cloneDriver("schumacher"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -184,13 +202,25 @@ const initialState: RootState["event"] = {
|
|||||||
status: CarStatus.Normal,
|
status: CarStatus.Normal,
|
||||||
tyre: DEFAULT_TYRE,
|
tyre: DEFAULT_TYRE,
|
||||||
notices: [],
|
notices: [],
|
||||||
distance: 100 * 4,
|
distance: POLE_TO_START - GRID_POSITION_GAP * 19,
|
||||||
driver: cloneDriver("mazepin"),
|
driver: cloneDriver("mazepin"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
lastUpdate: Date.now(),
|
lastUpdate: Date.now(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface IncreaseDistanceAction {
|
||||||
|
cars: Car[];
|
||||||
|
distance: Meters;
|
||||||
|
randomness: number;
|
||||||
|
usePerformance: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SetCarStatusAction {
|
||||||
|
cars: Car[];
|
||||||
|
status: CarStatus;
|
||||||
|
}
|
||||||
|
|
||||||
export const eventSlice = createSlice({
|
export const eventSlice = createSlice({
|
||||||
name: "event",
|
name: "event",
|
||||||
initialState,
|
initialState,
|
||||||
@@ -226,11 +256,57 @@ export const eventSlice = createSlice({
|
|||||||
state.leaderGridSpot = sortingGrid[0].gridSpot;
|
state.leaderGridSpot = sortingGrid[0].gridSpot;
|
||||||
state.lastUpdate = Date.now();
|
state.lastUpdate = Date.now();
|
||||||
},
|
},
|
||||||
|
increaseDistance: (state, action: PayloadAction<IncreaseDistanceAction>) => {
|
||||||
|
const gridMap = driverToGridMap(state.grid);
|
||||||
|
|
||||||
|
const { cars, distance, randomness, usePerformance } = action.payload;
|
||||||
|
|
||||||
|
cars.forEach(car => {
|
||||||
|
let addedDistance = distance;
|
||||||
|
|
||||||
|
if (randomness !== 0){
|
||||||
|
addedDistance *= random(1 - randomness, 1 + randomness);
|
||||||
|
}
|
||||||
|
if (usePerformance) {
|
||||||
|
addedDistance *=
|
||||||
|
getTeam(car.driver.team.id).performance + car.driver.performance;
|
||||||
|
}
|
||||||
|
state.grid[gridMap[car.driver.id]].distance += addedDistance;
|
||||||
|
});
|
||||||
|
state.lastUpdate = Date.now();
|
||||||
|
},
|
||||||
|
awardFastestLap: (state, action: PayloadAction<Car>) => {
|
||||||
|
// Awards fastest lap to provided car. Removes fastest lap from anyone else.
|
||||||
|
state.grid.forEach((car, index) => {
|
||||||
|
const fastestLapNoticeIndex = car.notices.findIndex(
|
||||||
|
notice => notice === CarNotice.FastestLap,
|
||||||
|
);
|
||||||
|
if (car.driver.id === action.payload.driver.id) {
|
||||||
|
if (fastestLapNoticeIndex === -1) {
|
||||||
|
state.grid[index].notices.push(CarNotice.FastestLap);
|
||||||
|
}
|
||||||
|
} else if (fastestLapNoticeIndex !== -1) {
|
||||||
|
state.grid[index].notices.splice(fastestLapNoticeIndex, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
state.lastUpdate = Date.now();
|
||||||
|
},
|
||||||
|
setCarStatus: (state, action: PayloadAction<SetCarStatusAction>) => {
|
||||||
|
const gridMap = driverToGridMap(state.grid);
|
||||||
|
const { cars, status } = action.payload;
|
||||||
|
cars.forEach(car => {
|
||||||
|
state.grid[gridMap[car.driver.id]].status = status;
|
||||||
|
});
|
||||||
|
state.lastUpdate = Date.now();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const {
|
export const {
|
||||||
setCourseFlag,
|
setCourseFlag,
|
||||||
refreshRunningOrder,
|
refreshRunningOrder,
|
||||||
|
increaseDistance,
|
||||||
|
awardFastestLap,
|
||||||
|
setCarStatus,
|
||||||
} = eventSlice.actions;
|
} = eventSlice.actions;
|
||||||
export default eventSlice.reducer;
|
export default eventSlice.reducer;
|
||||||
+37
-25
@@ -74,7 +74,7 @@ export interface Event {
|
|||||||
courseStatus: CourseStatus;
|
courseStatus: CourseStatus;
|
||||||
mode: EventMode;
|
mode: EventMode;
|
||||||
progress: EventProgress;
|
progress: EventProgress;
|
||||||
leaderGridSpot: GridSpot;
|
leaderGridSpot: GridSpot; // Might be removed.
|
||||||
grid: Grid;
|
grid: Grid;
|
||||||
// gridPositions: GridSpot[];
|
// gridPositions: GridSpot[];
|
||||||
lastUpdate: number;
|
lastUpdate: number;
|
||||||
@@ -85,39 +85,49 @@ export interface EventProgress {
|
|||||||
currentLap: number;
|
currentLap: number;
|
||||||
lapCount: number;
|
lapCount: number;
|
||||||
}
|
}
|
||||||
export type EventMode =
|
export enum EventMode {
|
||||||
| "race"
|
Race,
|
||||||
| "sprint"
|
Sprint,
|
||||||
| "p1"
|
Practice1,
|
||||||
| "p2"
|
Practice2,
|
||||||
| "p3"
|
Practice3,
|
||||||
| "q1"
|
Qualifying1,
|
||||||
| "q2"
|
Qualifying2,
|
||||||
| "q3";
|
Qualifying3,
|
||||||
|
}
|
||||||
export interface CourseStatus {
|
export interface CourseStatus {
|
||||||
courseFlag: CourseFlag;
|
courseFlag: CourseFlag;
|
||||||
sectorFlags: CourseFlag[];
|
sectorFlags: SectorFlag[];
|
||||||
safetyCar: SafetyCarStatus;
|
safetyCar: SafetyCarStatus;
|
||||||
virtualSafetyCar: VirtualSafetyCarStatus;
|
virtualSafetyCar: VirtualSafetyCarStatus;
|
||||||
}
|
}
|
||||||
export type CourseFlag =
|
|
||||||
| "green"
|
export enum CourseFlag {
|
||||||
| "yellow"
|
Green,
|
||||||
| "doubleYellow"
|
Yellow,
|
||||||
| "chequered"
|
Chequered,
|
||||||
| "red"
|
Red,
|
||||||
| "white"
|
}
|
||||||
| "redYellow";
|
|
||||||
export type SafetyCarStatus = "clear" | "starting" | "out" | "ending";
|
export enum SectorFlag {
|
||||||
export type VirtualSafetyCarStatus = "clear" | "out" | "ending";
|
Green,
|
||||||
|
Yellow,
|
||||||
|
DoubleYellow,
|
||||||
|
White,
|
||||||
|
RedYellow,
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum SafetyCarStatus { Clear, Starting, Out, Ending }
|
||||||
|
export enum VirtualSafetyCarStatus { Clear, Active, Ending }
|
||||||
export type Grid = Car[]; // Grid order does not change.
|
export type Grid = Car[]; // Grid order does not change.
|
||||||
export type GridSpot = number;
|
export type GridSpot = number;
|
||||||
export interface Car {
|
export interface Car {
|
||||||
position: number;
|
position: number; // Position is DERIVED from distance and status.
|
||||||
driver: Driver;
|
driver: Driver;
|
||||||
status: CarStatus;
|
status: CarStatus;
|
||||||
tyre: Tyre;
|
tyre: Tyre;
|
||||||
// flags: ???, // blue, red, meatball, black/white, black
|
// tyreHistory: Tyre[];
|
||||||
|
// pitsCompleted: number;
|
||||||
notices: CarNotice[];
|
notices: CarNotice[];
|
||||||
distance: Meters;
|
distance: Meters;
|
||||||
}
|
}
|
||||||
@@ -130,6 +140,7 @@ export interface Driver {
|
|||||||
yellowTCam: boolean;
|
yellowTCam: boolean;
|
||||||
initials: string;
|
initials: string;
|
||||||
nationality: string; // ISO 3166-1 alpha-3 codes
|
nationality: string; // ISO 3166-1 alpha-3 codes
|
||||||
|
performance: Fraction; // Versus teammate
|
||||||
}
|
}
|
||||||
export type DriverId =
|
export type DriverId =
|
||||||
| "albon"
|
| "albon"
|
||||||
@@ -199,6 +210,7 @@ export interface Team {
|
|||||||
shortName: TeamShortName;
|
shortName: TeamShortName;
|
||||||
fullName: TeamFullName;
|
fullName: TeamFullName;
|
||||||
nationality: string; // ISO 3166-1 alpha-3 codes
|
nationality: string; // ISO 3166-1 alpha-3 codes
|
||||||
|
performance: Fraction;
|
||||||
// logo: string;
|
// logo: string;
|
||||||
}
|
}
|
||||||
export type TeamId =
|
export type TeamId =
|
||||||
@@ -275,8 +287,8 @@ export interface BGStatusIndicator {
|
|||||||
mode: BGStatusIndicatorModes;
|
mode: BGStatusIndicatorModes;
|
||||||
}
|
}
|
||||||
export enum BGStatusIndicatorModes {
|
export enum BGStatusIndicatorModes {
|
||||||
NormalNarrow, // "LAP" above "##/##" lap count.
|
LapNarrow, // "LAP" above "##/##" lap count.
|
||||||
NormalWide, // "LAP" to the left of "##/##" lap count.
|
LapWide, // "LAP" to the left of "##/##" lap count.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timing Tower
|
// Timing Tower
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
import { drivers, teams, teamNumberStyles, teamFlagStyles, teamGemStyles } from "../domain/data/teams";
|
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.
|
* Prefer getting data from teams.ts through these simple getter functions.
|
||||||
|
|||||||
+16
-2
@@ -1,4 +1,3 @@
|
|||||||
import { random } from "lodash";
|
|
||||||
import { Car, Grid } from "../types/state";
|
import { Car, Grid } from "../types/state";
|
||||||
|
|
||||||
import { Meters } from "../types/util";
|
import { Meters } from "../types/util";
|
||||||
@@ -13,7 +12,7 @@ export function timeDiff(
|
|||||||
* 61.015 m/s average. So, let's do that.
|
* 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;
|
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;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user