Skip to content

Commit

Permalink
Show actual number of flags, and show when they are thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Nov 8, 2023
1 parent bf30259 commit 1601b8d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
1 change: 1 addition & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ FBGM show field during game
- punt/kick out of back of endzone - cap bar width
- also make sure logic for a kick in the endzone is correct
- penalty yardage is not being assessed correctly in UI for width of play bar yards. it's just being added to end of play, when it could be either from the spot of the foul or a tack on at the end. penalty event should have enough info to handle this.
- test for offsetting penalties too
- need to set scrimmage and toGo for extra points/2pt, currently they are weird
- extra point or 2 point conversion should be treated as a separate play bar?
- don't count towards numPlays
Expand Down
24 changes: 14 additions & 10 deletions src/ui/components/BoxScore.football.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -589,16 +589,20 @@ const PlayBar = forwardRef<
{score}
</div>
) : null}
{play.flag ? (
<span
className="glyphicon glyphicon-stop text-warning"
style={{
// Center icon vertically
lineHeight: "unset",
top: "unset",
}}
/>
) : null}
{play.numFlags > 0
? range(play.numFlags).map(i => (
<span
key={i}
className="glyphicon glyphicon-stop text-warning"
style={{
// Center icon vertically
lineHeight: "unset",
top: "unset",
}}
title="Flag on the play"
/>
))
: null}
</div>
);
},
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 @@ -17,7 +17,7 @@ export type SportState = {
scoreInfos: ReturnType<typeof getScoreInfo>[];
intendedPossessionChange: boolean; // For punts and kickoffs
numPossessionChanges: number;
flag: boolean;
numFlags: 0;
countsTowardsNumPlays: boolean;
countsTowardsYards: boolean;

Expand Down Expand Up @@ -436,7 +436,7 @@ const processLiveGameEvents = ({
scoreInfos: [],
intendedPossessionChange: awaitingKickoff,
numPossessionChanges: 0,
flag: false,
numFlags: 0,
countsTowardsNumPlays: false,
countsTowardsYards: false,
});
Expand Down Expand Up @@ -524,22 +524,23 @@ const processLiveGameEvents = ({
play.numPossessionChanges += 1;
}
}
if (e.type === "penalty") {

if (e.type === "flag") {
play.numFlags += 1;
} else if (e.type === "penalty") {
// Penalty could have changed possession
const actualT2 = e.possessionAfterPenalty === 0 ? 1 : 0;
if (play.t !== actualT2) {
play.t = actualT2;
play.numPossessionChanges += 1;
}

play.flag = true;

// For penalties before the snap, still count them
play.countsTowardsNumPlays = true;
play.countsTowardsYards = true;
} else if (e.type === "penaltyCount" && e.offsetStatus === "offset") {
// Offsetting penalties don't make it this far in the penalty event, because they have no associated text. But we can find them here. No play since the down is replayed.
// Maybe accepted penalties that lead to replaying the down should also be considered here, but I'm not totally sure how to find those (!e.tackOn penalty events maybe?) and I'm not sure it's actually useful to do that (can have weird stuff like a 5 yard drive from 0 plays).
// Maybe accepted penalties that lead to replaying the down should also be considered here, but I'm not totally sure how to find those (!e.tackOn penalty events maybe?) and I'm not sure it's actually useful to do that (can have weird stuff like a 5 yard drive from 0 plays). https://www.nflpenalties.com/blog/what-is-a-play? argues similarly
play.countsTowardsNumPlays = false;
} else if (e.type === "dropback" || e.type === "handoff") {
play.countsTowardsNumPlays = true;
Expand Down

0 comments on commit 1601b8d

Please sign in to comment.