Skip to content

Commit

Permalink
Merge pull request #35 from AlecM33/gameday-fix
Browse files Browse the repository at this point in the history
check last at bat for reported descriptions as well
  • Loading branch information
AlecM33 authored Aug 9, 2024
2 parents ad3110f + c0f1524 commit a26fcff
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/gameday.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ async function reportPlays (bot, gamePk) {
async function reportAnyMissedEvents (atBat, bot, gamePk, atBatIndex) {
const missedEventsToReport = atBat.playEvents?.filter(event => globals.EVENT_WHITELIST.includes(event?.details?.eventType)
&& !globalCache.values.game.reportedDescriptions
.find(reportedDescription => reportedDescription.description === event?.details?.description && reportedDescription.atBatIndex === atBatIndex));
.find(reportedDescription => reportedDescription.description === event?.details?.description
&& (reportedDescription.atBatIndex === atBatIndex || reportedDescription.atBatIndex === (atBatIndex - 1))
)
);
for (const missedEvent of missedEventsToReport) {
await processAndPushPlay(bot, currentPlayProcessor.process(missedEvent), gamePk, atBatIndex);
}
Expand All @@ -139,7 +142,10 @@ async function processAndPushPlay (bot, play, gamePk, atBatIndex) {
if (play.reply
&& play.reply.length > 0
&& !globalCache.values.game.reportedDescriptions
.find(reportedDescription => reportedDescription.description === play.description && reportedDescription.atBatIndex === atBatIndex)) {
.find(reportedDescription => reportedDescription.description === play.description
&& (reportedDescription.atBatIndex === atBatIndex || reportedDescription.atBatIndex === (atBatIndex - 1))
)
) {
globalCache.values.game.reportedDescriptions.push({ description: play.description, atBatIndex });
const feed = liveFeed.init(globalCache.values.game.currentLiveFeed);
if (play.isComplete) {
Expand Down

0 comments on commit a26fcff

Please sign in to comment.