Skip to content

Commit

Permalink
Add some bold text back
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Nov 29, 2023
1 parent 591286e commit e6d2dff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 37 deletions.
33 changes: 21 additions & 12 deletions src/ui/util/processLiveGameEvents.football.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type SportState = {
toGo: number;
scrimmage: number;
yards: number;
texts: string[];
texts: ReactNode[];
scoreInfo: ReturnType<typeof getScoreInfo> | undefined;
intendedPossessionChange: boolean; // For punts and kickoffs
turnover: boolean;
Expand All @@ -40,7 +40,7 @@ export type SportState = {
t: 0 | 1;
}[];
text: string;
newPeriodText: string | undefined;
newPeriodText: ReactNode | undefined;
};

export const DEFAULT_SPORT_STATE: SportState = {
Expand Down Expand Up @@ -169,7 +169,7 @@ export const getText = (event: PlayByPlayEvent, numPeriods: number) => {
}
}

let text: string | undefined;
let text: ReactNode | undefined;

if (event.type === "injury") {
text = `${event.names[0]} was injured!`;
Expand Down Expand Up @@ -309,10 +309,7 @@ export const getText = (event: PlayByPlayEvent, numPeriods: number) => {
: ""
}`;
} else if (event.type === "penalty") {
text = `Penalty - ${event.penaltyName.toLowerCase()}${
event.names.length > 0 ? ` on ${event.names[0]}` : ""
}`;

let decisionText;
if (event.offsetStatus !== "offset") {
const spotFoulText = event.tackOn
? " from the end of the play"
Expand All @@ -330,15 +327,27 @@ export const getText = (event: PlayByPlayEvent, numPeriods: number) => {
text += `, ${event.yds} yards${spotFoulText}${automaticFirstDownText}`;
}

let decisionText;
let innerText;
if (event.offsetStatus === "overrule") {
decisionText = event.decision === "accept" ? "enforced" : "overruled";
innerText = event.decision === "accept" ? "enforced" : "overruled";
} else {
decisionText = event.decision === "accept" ? "accepted" : "declined";
innerText = event.decision === "accept" ? "accepted" : "declined";
}

text += ` - ${decisionText}`;
decisionText = (
<>
{" "}
- <b>{innerText}</b>
</>
);
}

text = (
<>
Penalty - {event.penaltyName.toLowerCase()}
{event.names.length > 0 ? ` on ${event.names[0]}` : ""}
{decisionText}
</>
);
} else if (event.type === "timeout") {
text = `Timeout, ${event.offense ? "offense" : "defense"} (${
event.numLeft
Expand Down
37 changes: 12 additions & 25 deletions src/ui/views/LiveGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ export const LiveGame = (props: View<"liveGame">) => {
quarters: quarters.current,
sportState: sportState.current,
});
let text = output.text;
const showOuts =
isSport("baseball") && output.sportState.outs > prevOuts!;
const text = output.text;
const currentPts =
boxScore.current.teams[0].pts + boxScore.current.teams[1].pts;
const showScore = currentPts !== prevPts;
Expand All @@ -273,6 +271,8 @@ export const LiveGame = (props: View<"liveGame">) => {

if (text !== undefined) {
/*if (isSport("baseball")) {
const showOuts =
isSport("baseball") && output.sportState.outs > prevOuts!;
if (showOuts) {
let endWithPeriod = true;
if (!text.endsWith("!") && !text.endsWith(".")) {
Expand All @@ -289,29 +289,16 @@ export const LiveGame = (props: View<"liveGame">) => {
}
const p = document.createElement("p");
if (isSport("football") && text.startsWith("Penalty")) {
p.innerHTML = text
.replace("accepted", "<b>accepted</b>")
.replace("declined", "<b>declined</b>")
.replace("enforced", "<b>enforced</b>")
.replace("overruled", "<b>overruled</b>");
const node = document.createTextNode(text);
if (
(isSport("hockey") &&
(text.includes("Goal!") || text.includes("penalty"))) ||
) {
const b = document.createElement("b");
b.appendChild(node);
p.appendChild(b);
} else {
const node = document.createTextNode(text);
if (
text === "End of game" ||
text.startsWith("Start of") ||
(isSport("basketball") &&
text.startsWith("Elam Ending activated! First team to")) ||
(isSport("hockey") &&
(text.includes("Goal!") || text.includes("penalty"))) ||
output.bold
) {
const b = document.createElement("b");
b.appendChild(node);
p.appendChild(b);
} else {
p.appendChild(node);
}
p.appendChild(node);
}*/

const score =
Expand Down

0 comments on commit e6d2dff

Please sign in to comment.