mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 09:48:02 +00:00
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:
@@ -15,6 +15,7 @@ public class GameRules {
|
|||||||
private boolean AISideboardingEnabled = false;
|
private boolean AISideboardingEnabled = false;
|
||||||
private boolean sideboardForAI = false;
|
private boolean sideboardForAI = false;
|
||||||
private final Set<GameType> appliedVariants = EnumSet.noneOf(GameType.class);
|
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
|
// it's a preference, not rule... but I could hardly find a better place for it
|
||||||
private boolean useGrayText;
|
private boolean useGrayText;
|
||||||
@@ -124,4 +125,12 @@ public class GameRules {
|
|||||||
public void setWarnAboutAICards(final boolean warnAboutAICards) {
|
public void setWarnAboutAICards(final boolean warnAboutAICards) {
|
||||||
this.warnAboutAICards = warnAboutAICards;
|
this.warnAboutAICards = warnAboutAICards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSimTimeout() {
|
||||||
|
return this.simTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimTimeout(final int duration) {
|
||||||
|
this.simTimeout = duration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
sb.append(" - ").append(Lang.nounWithNumeral(nGames, "game")).append(" of ").append(type);
|
||||||
|
|
||||||
System.out.println(sb.toString());
|
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("\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("\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("\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.");
|
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(() -> {
|
TimeLimitedCodeBlock.runWithTimeout(() -> {
|
||||||
mc.startGame(g1);
|
mc.startGame(g1);
|
||||||
sw.stop();
|
sw.stop();
|
||||||
}, 120, TimeUnit.SECONDS);
|
}, mc.getRules().getSimTimeout(), TimeUnit.SECONDS);
|
||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException e) {
|
||||||
System.out.println("Stopping slow match as draw");
|
System.out.println("Stopping slow match as draw");
|
||||||
} catch (Exception | StackOverflowError e) {
|
} catch (Exception | StackOverflowError e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user