Skip to content

Commit

Permalink
Hockey
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Nov 29, 2023
1 parent f58f9fb commit 8a80bea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
10 changes: 2 additions & 8 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
better play by play log
- test other sports
- football
- benchmark
- hockey
- t
- textOnly
- benchmark
- baseball
- showScore in LiveGame
- t
- textOnly
- bold = false
- output.bold
- benchmark
- make text JSX, get rid of any processing in LiveGame
- test performance
Expand All @@ -22,7 +16,7 @@ better play by play log
- go back to editing DOM?
- then i still can't use jsx in processLiveGameEvents text output
- maybe not that slow in prod mode, benchmark
- colored text for football interceptions/fumble/downs turnovers, hockey power plays, maybe baseball outs, maybe baseball/hockey/football scores
- colored text for football interceptions/fumble/downs turnovers, hockey penalty, maybe baseball outs, maybe baseball/hockey/football scores

no need to track scoringSummary at all for basketball

Expand Down
2 changes: 2 additions & 0 deletions src/ui/util/processLiveGameEvents.baseball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ const processLiveGameEvents = ({

const output = getText(e, getName);
text = output.text;
t = actualT;
bold = output.bold;

stop = true;
Expand All @@ -576,6 +577,7 @@ const processLiveGameEvents = ({
overtimes,
quarters,
sportState,
t,
text,
};
};
Expand Down
17 changes: 5 additions & 12 deletions src/ui/util/processLiveGameEvents.hockey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,22 @@ const getText = (
) => {
let text;

let showTeamAndClock = true;

if (event.type === "injury") {
text = `${event.names[0]} was injured!`;
}
if (event.type === "quarter") {
text = `Start of ${helpers.ordinal(event.quarter)} ${getPeriodName(
boxScore.numPeriods,
)}`;
showTeamAndClock = false;
}
if (event.type === "overtime") {
const overtimes = event.quarter - boxScore.numPeriods;
text = `Start of ${
overtimes === 1 ? "" : `${helpers.ordinal(overtimes)} `
} overtime`;
showTeamAndClock = false;
}
if (event.type === "gameOver") {
text = "End of game";
showTeamAndClock = false;
}
if (event.type === "hit") {
text = `${event.names[0]} hit ${event.names[1]}`;
Expand Down Expand Up @@ -167,13 +162,6 @@ const getText = (
throw new Error(`Invalid event type "${event.type}"`);
}

if (showTeamAndClock) {
const actualT = (event as any).t === 0 ? 1 : 0;
text = `${formatClock((event as any).clock)} - ${
boxScore.teams[actualT].abbrev
} - ${text}`;
}

return text;
};

Expand Down Expand Up @@ -296,6 +284,9 @@ const processLiveGameEvents = ({
}

text = getText(e, boxScore);
t = actualT;
textOnly =
e.type === "gameOver" || e.type === "quarter" || e.type === "overtime";
boxScore.time = formatClock(e.clock);
stop = true;
}
Expand Down Expand Up @@ -328,7 +319,9 @@ const processLiveGameEvents = ({
return {
overtimes,
quarters,
t,
text,
textOnly,
};
};

Expand Down

0 comments on commit 8a80bea

Please sign in to comment.