Skip to content

Commit 87af6b7

Browse files
author
Julien
committed
style(SDK): factorized check for correct output
1 parent 0674310 commit 87af6b7

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

runner/src/main/java/com/codingame/gameengine/runner/GameRunner.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,8 @@ private String getNextPlayerOutput(NextPlayerInfo nextPlayerInfo, String nextPla
271271
if (playerOutput != null)
272272
playerOutput = playerOutput.replace('\r', '\n');
273273

274-
boolean outputCheckOk = checkOutput(playerOutput, nextPlayerInfo.nbLinesNextOutput) == OutputResult.OK;
275-
276-
if (outputCheckOk) {
277-
// Read this turns stderr
274+
if (checkOutput(playerOutput, nextPlayerInfo.nbLinesNextOutput) == OutputResult.OK) {
275+
// Read this turn's stderr
278276
readError(player);
279277
} else {
280278
// Give the agent time to crash cleanly
@@ -283,13 +281,11 @@ private String getNextPlayerOutput(NextPlayerInfo nextPlayerInfo, String nextPla
283281
} catch (InterruptedException e) {
284282
e.printStackTrace();
285283
}
286-
// Read this turns stderr and crash output
284+
// Read this turns stderr and the crash output
287285
readError(player);
288-
}
289-
290-
if (!outputCheckOk) {
291286
return null;
292287
}
288+
293289
if ((playerOutput != null) && playerOutput.isEmpty() && (nextPlayerInfo.nbLinesNextOutput == 1)) {
294290
return "\n";
295291
}

0 commit comments

Comments
 (0)