Added the -c (clock) flag to determine the maximum time in seconds before the sim execution calls the match a draw. (#8202)

This commit is contained in:
Matija Huremović
2025-09-06 11:04:59 +02:00
committed by GitHub
parent 85812d819f
commit cce25a37c4
2 changed files with 15 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ public class GameRules {
private boolean AISideboardingEnabled = false;
private boolean sideboardForAI = false;
private final Set<GameType> appliedVariants = EnumSet.noneOf(GameType.class);
private int simTimeout = 120;
// it's a preference, not rule... but I could hardly find a better place for it
private boolean useGrayText;
@@ -124,4 +125,12 @@ public class GameRules {
public void setWarnAboutAICards(final boolean warnAboutAICards) {
this.warnAboutAICards = warnAboutAICards;
}
public int getSimTimeout() {
return this.simTimeout;
}
public void setSimTimeout(final int duration) {
this.simTimeout = duration;
}
}

View File

@@ -130,6 +130,10 @@ public class SimulateMatch {
}
}
if (params.containsKey("c")) {
rules.setSimTimeout(Integer.parseInt(params.get("c").get(0)));
}
sb.append(" - ").append(Lang.nounWithNumeral(nGames, "game")).append(" of ").append(type);
System.out.println(sb.toString());
@@ -163,6 +167,7 @@ public class SimulateMatch {
System.out.println("\tT - Type of tournament to run with all provided decks (Bracket, RoundRobin, Swiss)");
System.out.println("\tP - Amount of players per match (used only with Tournaments, defaults to 2)");
System.out.println("\tF - format of games, defaults to constructed");
System.out.println("\tc - Clock flag. Set the maximum time in seconds before calling the match a draw, defaults to 120.");
System.out.println("\tq - Quiet flag. Output just the game result, not the entire game log.");
}
@@ -176,7 +181,7 @@ public class SimulateMatch {
TimeLimitedCodeBlock.runWithTimeout(() -> {
mc.startGame(g1);
sw.stop();
}, 120, TimeUnit.SECONDS);
}, mc.getRules().getSimTimeout(), TimeUnit.SECONDS);
} catch (TimeoutException e) {
System.out.println("Stopping slow match as draw");
} catch (Exception | StackOverflowError e) {