Skip to content

Commit

Permalink
Fix handling of twoPointConversionTeam
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Nov 7, 2023
1 parent de1255b commit 0786d6d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FBGM move event text generation to UI
- twoPointConversionTeam
- to fix after
- possessionChangeTexts
- ABBREV replace stuff
Expand Down Expand Up @@ -43,10 +42,11 @@ FBGM show field during game
- unify logic with kickoffAfterEndOfPeriod
- punt/kick out of back of endzone - cap bar width
- also make sure logic for a kick in the endzone is correct
- some of the yard stuff is wrong. like an interception doesn't occur relative to the line of scrimmage, but instead is relative to where the turnover happens. so we can't just look at event.yds and adjust that from scrimmage. possibly fumbles too?
- 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
- 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
- extra point or 2 point conversion should be treated as a separate play bar?
- don't count towards numPlays
- send additional clock event?
- need to know if it's xp or 2pt, for scrimmage
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/BoxScore.football.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const processEvents = (events: PlayByPlayEventScore[], numPeriods: number) => {
} else if (
prevEvent &&
scoreInfo.type === "2P" &&
event.t === prevEvent.t
actualT === prevEvent.t
) {
prevEvent.score = score.slice();
prevEvent.text += ` (${text})`;
Expand Down
7 changes: 4 additions & 3 deletions src/ui/util/processLiveGameEvents.football.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ export const getText = (event: PlayByPlayEvent, numPeriods: number) => {
let touchdownText = "a touchdown";
let showYdsOnTD = true;

/*if (this.twoPointConversionTeam !== undefined) {
if (this.twoPointConversionTeam === (event as any).t) {
const eAny = event as any;
if (eAny.twoPointConversionTeam !== undefined) {
if (eAny.twoPointConversionTeam === eAny.t) {
touchdownText = "a two point conversion";
showYdsOnTD = false;
} else {
touchdownText = "two points";
}
}*/
}

let text: string | undefined;

Expand Down
4 changes: 4 additions & 0 deletions src/worker/core/GameSim.football/PlayByPlayLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type PlayByPlayEventInputScore =
t: TeamNum;
td: boolean;
touchback: boolean;
twoPointConversionTeam: TeamNum | undefined;
yds: number;
}
| {
Expand All @@ -37,6 +38,7 @@ export type PlayByPlayEventInputScore =
t: TeamNum;
td: boolean;
touchback: boolean;
twoPointConversionTeam: TeamNum | undefined;
yds: number;
}
| {
Expand All @@ -46,6 +48,7 @@ export type PlayByPlayEventInputScore =
safety: boolean;
t: TeamNum;
td: boolean;
twoPointConversionTeam: TeamNum | undefined;
yds: number;
}
| {
Expand All @@ -55,6 +58,7 @@ export type PlayByPlayEventInputScore =
safety: boolean;
t: TeamNum;
td: boolean;
twoPointConversionTeam: TeamNum | undefined;
yds: number;
}
| {
Expand Down
12 changes: 9 additions & 3 deletions src/worker/core/GameSim.football/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class GameSim extends GameSimBase {
// For penalties at the end of a half
playUntimedPossession = false;

twoPointConversionTeam: TeamNum | undefined;

constructor({
gid,
day,
Expand Down Expand Up @@ -502,7 +504,7 @@ class GameSim extends GameSimBase {
const quarter = this.team[0].stat.ptsQtrs.length;

if (this.awaitingAfterTouchdown) {
if (ptsDown === 2 && Math.random() < 0.7) {
if (true || (ptsDown === 2 && Math.random() < 0.7)) {

Check failure on line 507 in src/worker/core/GameSim.football/index.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected constant condition
return "twoPointConversion";
}

Expand Down Expand Up @@ -1474,7 +1476,7 @@ class GameSim extends GameSimBase {
t: twoPointConversionTeam,
});

this.playByPlay.twoPointConversionTeam = twoPointConversionTeam;
this.twoPointConversionTeam = twoPointConversionTeam;

this.playByPlay.logEvent({
type: "twoPointConversion",
Expand Down Expand Up @@ -1506,7 +1508,7 @@ class GameSim extends GameSimBase {
});
}

this.playByPlay.twoPointConversionTeam = undefined;
this.twoPointConversionTeam = undefined;

return 0;
}
Expand Down Expand Up @@ -1591,6 +1593,7 @@ class GameSim extends GameSimBase {
t: tRecovered,
td,
touchback,
twoPointConversionTeam: this.twoPointConversionTeam,
yds,
});

Expand Down Expand Up @@ -1649,6 +1652,7 @@ class GameSim extends GameSimBase {
t: this.currentPlay.state.current.o,
td,
touchback,
twoPointConversionTeam: this.twoPointConversionTeam,
yds,
});

Expand Down Expand Up @@ -1873,6 +1877,7 @@ class GameSim extends GameSimBase {
safety,
t: o,
td,
twoPointConversionTeam: this.twoPointConversionTeam,
yds,
} as const;

Expand Down Expand Up @@ -2019,6 +2024,7 @@ class GameSim extends GameSimBase {
safety,
t: o,
td,
twoPointConversionTeam: this.twoPointConversionTeam,
yds,
});

Expand Down

0 comments on commit 0786d6d

Please sign in to comment.