Skip to content

Commit

Permalink
Fix fast forward
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Apr 14, 2024
1 parent 109b54c commit 744e8ff
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ shootouts
- show attempt number in play-by-play
- scoring summary
- "1 run scores" -> "Shootout"
- test if fast forward to end of inning/side doesn't stop before shootout
- hockey
- confirm for all sports
- check what fast-forward options are shown during shootout
- no injuries during shootout
- if still tied, keep going one at a time
- make sure it's not all 0, all sports should have some min prob of success
Expand Down
22 changes: 12 additions & 10 deletions src/ui/components/BoxScoreWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,18 @@ export const HeadlineScore = ({
<span className="d-none d-sm-inline">
{boxScore.gameOver
? "Final score"
: boxScore.elamTarget !== undefined
? `Elam Ending target: ${boxScore.elamTarget} points`
: isSport("baseball")
? `${
boxScore.teams[0].ptsQtrs.length ===
boxScore.teams[1].ptsQtrs.length
? "Bottom"
: "Top"
} of the ${boxScore.quarter}`
: `${boxScore.quarter}, ${boxScore.time} remaining`}
: boxScore.shootout
? "Shootout"
: boxScore.elamTarget !== undefined
? `Elam Ending target: ${boxScore.elamTarget} points`
: isSport("baseball")
? `${
boxScore.teams[0].ptsQtrs.length ===
boxScore.teams[1].ptsQtrs.length
? "Bottom"
: "Top"
} of the ${boxScore.quarter}`
: `${boxScore.quarter}, ${boxScore.time} remaining`}
</span>
<span className="d-sm-none">
{boxScore.gameOver
Expand Down
22 changes: 18 additions & 4 deletions src/ui/views/LiveGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,11 @@ export const LiveGame = (props: View<"liveGame">) => {
const playSeconds = (cutoff: number) => {
let seconds = 0;
let numPlays = 0;
while (seconds < cutoff && !boxScore.current.gameOver) {
while (
seconds < cutoff &&
!boxScore.current.gameOver &&
!boxScore.current.shootout
) {
const elapsedSeconds = processToNextPause(true);
numPlays += 1;
if (elapsedSeconds > 0) {
Expand Down Expand Up @@ -583,7 +587,11 @@ export const LiveGame = (props: View<"liveGame">) => {
boxScore.current.teams[0].pts + boxScore.current.teams[1].pts;
let currentPts = initialPts;
let numPlays = 0;
while (initialPts === currentPts && !boxScore.current.gameOver) {
while (
initialPts === currentPts &&
!boxScore.current.gameOver &&
!boxScore.current.shootout
) {
processToNextPause(true);
currentPts =
boxScore.current.teams[0].pts + boxScore.current.teams[1].pts;
Expand Down Expand Up @@ -738,7 +746,10 @@ export const LiveGame = (props: View<"liveGame">) => {
let numPlays = 0;

const numSidesSoFar = getNumSidesSoFar();
while (!boxScore.current.gameOver) {
while (
!boxScore.current.gameOver &&
!boxScore.current.shootout
) {
processToNextPause(true);
numPlays += 1;

Expand All @@ -757,7 +768,10 @@ export const LiveGame = (props: View<"liveGame">) => {
let numPlays = 0;

const numSidesSoFar = getNumSidesSoFar();
while (!boxScore.current.gameOver) {
while (
!boxScore.current.gameOver &&
!boxScore.current.shootout
) {
processToNextPause(true);
numPlays += 1;

Expand Down

0 comments on commit 744e8ff

Please sign in to comment.