diff --git a/forge-game/src/main/java/forge/game/GameRules.java b/forge-game/src/main/java/forge/game/GameRules.java index f36ccef565c..c38b6c113c9 100644 --- a/forge-game/src/main/java/forge/game/GameRules.java +++ b/forge-game/src/main/java/forge/game/GameRules.java @@ -15,6 +15,7 @@ public class GameRules { private boolean AISideboardingEnabled = false; private boolean sideboardForAI = false; private final Set 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; + } } diff --git a/forge-gui-desktop/src/main/java/forge/view/SimulateMatch.java b/forge-gui-desktop/src/main/java/forge/view/SimulateMatch.java index 6fe9bd2e68b..b573dadf430 100644 --- a/forge-gui-desktop/src/main/java/forge/view/SimulateMatch.java +++ b/forge-gui-desktop/src/main/java/forge/view/SimulateMatch.java @@ -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) {