Skip to content

Commit

Permalink
Fix clutch shot tracking and text for shootouts
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Apr 8, 2024
1 parent a193593 commit cb31591
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 4 additions & 5 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ shootouts
- don't track any stats
- no clock
- in writeGameStats, add sPts to gameStats.won and lost
- basketball
- make sure game-tying and game-winning appear correctly in text of clutch shots when there is a shootout
- do shootout after calling checkGameWinner()
- make sure game-tying shots are logged as clutch right before a shootout
- might need to call checkGameTyingShot again
- make sure it works for player feats - see PlayerFeats.tsx "const result" - needs shootout info
- show shootout result somewhere
- basketball - clutch play could say who beat who
- other sports - scoring log
- upgrades
- league file import
- idb upgrade
Expand All @@ -35,6 +33,7 @@ shootouts
- blog
- settings screenshot
- screenshot of each sport's sim, and description
- see result live in play-by-play, or in clutch play description or scoring log depending on sport

various baseball gamesim text improvements https://mail.google.com/mail/u/0/#search/gould/FMfcgzGxSRQrSRzJfBGgRVKHNxBWCJnJ

Expand Down
13 changes: 8 additions & 5 deletions src/worker/core/GameSim.basketball/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2431,6 +2431,7 @@ class GameSim extends GameSimBase {
);
}

// This runs before an overtime period is played, so all these shots lead to another overtime period, not the end of the game
checkGameTyingShot() {
if (this.lastScoringPlay.length === 0 || this.elamActive) {
return;
Expand Down Expand Up @@ -2520,15 +2521,13 @@ class GameSim extends GameSimBase {
});
}

// This runs after the game ends (except shootout) so it could be a game-tying shot if the game will end in a tie or shootout
checkGameWinner() {
if (this.lastScoringPlay.length === 0) {
return;
}

const winner = getWinner([this.team[0].stat, this.team[1].stat]);
if (winner === undefined) {
return;
}
const winner = getWinner([this.team[0].stat, this.team[1].stat])!;
const loser = winner === 0 ? 1 : 0;
const finalMargin =
winner === -1
Expand Down Expand Up @@ -2589,7 +2588,7 @@ class GameSim extends GameSimBase {
default:
}

margin -= play.team === winner ? pts : -pts;
margin -= winner === -1 || play.team === winner ? pts : -pts;

if (margin <= 0) {
const team = this.team[play.team];
Expand All @@ -2613,6 +2612,10 @@ class GameSim extends GameSimBase {
}
}

if (winner === -1 && this.shootoutRounds > 0) {
eventText += " to force a shootout";
}

this.clutchPlays.push({
text: eventText,
showNotification: team.id === g.get("userTid"),
Expand Down

0 comments on commit cb31591

Please sign in to comment.