Skip to content

Commit 98cab34

Browse files
committed
properly handle game cancellations and suspensions
1 parent f350cc9 commit 98cab34

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/main/java/pw/chew/mlb/listeners/GameFeedHandler.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@ private static void runGame(String gamePk) {
206206
while (!currentState.gameState().equals("Final")) {
207207
GameState recentState = GameState.fromPk(gamePk);
208208

209+
if (recentState.isCancelled()) {
210+
endGame(gamePk, recentState, "\nUnfortunately, this game was cancelled.");
211+
return;
212+
}
213+
214+
if (recentState.isSuspended()) {
215+
endGame(gamePk, recentState, "\nUnfortunately, this game has been suspended. It will resume at a later time.");
216+
return;
217+
}
218+
209219
if (recentState.failed()) {
210220
int retryIn = fails + 3;
211221
retryIn = Math.min(20, retryIn);
@@ -321,7 +331,7 @@ private static void runGame(String gamePk) {
321331
JSONObject advisory = newAdvisories.get(i);
322332
JSONObject details = advisory.getJSONObject("details");
323333

324-
logger.debug("New advisory: " + advisory);
334+
logger.debug("New advisory: {}", advisory);
325335

326336
String event = details.getString("event");
327337
String description = details.getString("description");
@@ -379,16 +389,6 @@ private static void runGame(String gamePk) {
379389
}
380390
}
381391

382-
if (currentState.isCancelled()) {
383-
endGame(gamePk, currentState, "\nUnfortunately, this game was cancelled.");
384-
return;
385-
}
386-
387-
if (currentState.isSuspended()) {
388-
endGame(gamePk, currentState, "\nUnfortunately, this game has been suspended. It will resume at a later time.");
389-
return;
390-
}
391-
392392
// Build a scorecard embed
393393
EmbedBuilder scorecardEmbed = new EmbedBuilder();
394394
scorecardEmbed.setTitle("Scorecard");

0 commit comments

Comments
 (0)