From c0f1524a2f245725d7491375c248db6599c3b9c3 Mon Sep 17 00:00:00 2001 From: Alec Date: Thu, 8 Aug 2024 22:10:27 -0400 Subject: [PATCH] check last at bat for reported descriptions as well --- modules/gameday.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/gameday.js b/modules/gameday.js index de98ca1..c95a8ed 100644 --- a/modules/gameday.js +++ b/modules/gameday.js @@ -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); } @@ -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) {