Skip to content

Commit

Permalink
Better football sportState
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Nov 5, 2023
1 parent ed0b486 commit b0da6b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ FBGM show field during game
- different colors for positive and negative plays
- some minimum height of field, but expand dynamically for long drives
- draw vertical lines for scrimmage and togo
- not when awaitingKickoff
- would be nice to show the kickoff as a drive - kick and return as 2 bars
- fumbles too
- light mode
- how to update numPlays
- accepted penalties only count as a play if they are added on to the end of the play. this means we sometimes need to decrease numPlays when a penalty gets accepted, but not always
Expand Down
13 changes: 7 additions & 6 deletions src/ui/util/processLiveGameEvents.football.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getPeriodName } from "../../common";
import { helpers } from "../../ui/util";

export type SportState = {
awaitingKickoff: boolean;
t: 0 | 1;
numPlays: number;
initialScrimmage: number;
Expand All @@ -11,6 +12,7 @@ export type SportState = {
};

export const DEFAULT_SPORT_STATE: SportState = {
awaitingKickoff: true,
t: 0,
numPlays: 0,
initialScrimmage: 0,
Expand Down Expand Up @@ -107,7 +109,8 @@ const processLiveGameEvents = ({
stop = true;
} else if (e.type === "clock") {
let textWithoutTime;
if (e.awaitingKickoff !== undefined) {
const awaitingKickoff = e.awaitingKickoff !== undefined;
if (awaitingKickoff) {
textWithoutTime = `${boxScore.teams[actualT].abbrev} kicking off`;
} else {
let fieldPos = "";
Expand All @@ -132,13 +135,11 @@ const processLiveGameEvents = ({
sportState.t = actualT;
sportState.numPlays = 0;
sportState.initialScrimmage = e.scrimmage;
sportState.scrimmage = e.scrimmage;
sportState.plays = [];
sportState.text = textWithoutTime;
} else {
sportState.text = textWithoutTime;
sportState.scrimmage = e.scrimmage;
}
sportState.awaitingKickoff = awaitingKickoff;
sportState.text = textWithoutTime;
sportState.scrimmage = e.scrimmage;
} else if (e.type === "stat") {
// Quarter-by-quarter score
if (e.s === "pts") {
Expand Down

0 comments on commit b0da6b6

Please sign in to comment.