Skip to content

Commit c0f1524

Browse files
committed
check last at bat for reported descriptions as well
1 parent ad3110f commit c0f1524

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/gameday.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ async function reportPlays (bot, gamePk) {
129129
async function reportAnyMissedEvents (atBat, bot, gamePk, atBatIndex) {
130130
const missedEventsToReport = atBat.playEvents?.filter(event => globals.EVENT_WHITELIST.includes(event?.details?.eventType)
131131
&& !globalCache.values.game.reportedDescriptions
132-
.find(reportedDescription => reportedDescription.description === event?.details?.description && reportedDescription.atBatIndex === atBatIndex));
132+
.find(reportedDescription => reportedDescription.description === event?.details?.description
133+
&& (reportedDescription.atBatIndex === atBatIndex || reportedDescription.atBatIndex === (atBatIndex - 1))
134+
)
135+
);
133136
for (const missedEvent of missedEventsToReport) {
134137
await processAndPushPlay(bot, currentPlayProcessor.process(missedEvent), gamePk, atBatIndex);
135138
}
@@ -139,7 +142,10 @@ async function processAndPushPlay (bot, play, gamePk, atBatIndex) {
139142
if (play.reply
140143
&& play.reply.length > 0
141144
&& !globalCache.values.game.reportedDescriptions
142-
.find(reportedDescription => reportedDescription.description === play.description && reportedDescription.atBatIndex === atBatIndex)) {
145+
.find(reportedDescription => reportedDescription.description === play.description
146+
&& (reportedDescription.atBatIndex === atBatIndex || reportedDescription.atBatIndex === (atBatIndex - 1))
147+
)
148+
) {
143149
globalCache.values.game.reportedDescriptions.push({ description: play.description, atBatIndex });
144150
const feed = liveFeed.init(globalCache.values.game.currentLiveFeed);
145151
if (play.isComplete) {

0 commit comments

Comments
 (0)