mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
add user setting for AI Timeout
This commit is contained in:
@@ -967,7 +967,7 @@ public class AiAttackController {
|
||||
}));
|
||||
}
|
||||
CompletableFuture<?>[] futuresArray = futures.toArray(new CompletableFuture<?>[0]);
|
||||
CompletableFuture.allOf(futuresArray).completeOnTimeout(null, 5, TimeUnit.SECONDS).join();
|
||||
CompletableFuture.allOf(futuresArray).completeOnTimeout(null, ai.getTimeout(), TimeUnit.SECONDS).join();
|
||||
futures.clear();
|
||||
if (attackersLeft.isEmpty()) {
|
||||
return aiAggression;
|
||||
|
||||
@@ -1667,7 +1667,7 @@ public class AiController {
|
||||
}
|
||||
//timeout 5 seconds? even the AI don't acquire all, there should be SA to cast if valid
|
||||
CompletableFuture<?>[] futuresArray = futures.toArray(new CompletableFuture<?>[0]);
|
||||
CompletableFuture.allOf(futuresArray).completeOnTimeout(null, 5, TimeUnit.SECONDS).join();
|
||||
CompletableFuture.allOf(futuresArray).completeOnTimeout(null, player.getTimeout(), TimeUnit.SECONDS).join();
|
||||
futures.clear();
|
||||
|
||||
if (!spells.isEmpty()) {
|
||||
|
||||
@@ -215,6 +215,7 @@ public class GameCopier {
|
||||
|
||||
private void copyGameState(Game newGame, Player aiPlayer) {
|
||||
newGame.EXPERIMENTAL_RESTORE_SNAPSHOT = origGame.EXPERIMENTAL_RESTORE_SNAPSHOT;
|
||||
newGame.AI_TIMEOUT = origGame.AI_TIMEOUT;
|
||||
newGame.setAge(origGame.getAge());
|
||||
|
||||
// TODO countersAddedThisTurn
|
||||
|
||||
@@ -90,6 +90,7 @@ public class Game {
|
||||
private final GameLog gameLog = new GameLog();
|
||||
|
||||
private final Zone stackZone = new Zone(ZoneType.Stack, this);
|
||||
public int AI_TIMEOUT = 5;
|
||||
|
||||
public boolean EXPERIMENTAL_RESTORE_SNAPSHOT = false;
|
||||
// While this is false here, its really set by the Match/Preferences
|
||||
|
||||
@@ -131,6 +131,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
|
||||
private boolean revolt = false;
|
||||
private int descended = 0;
|
||||
// AI Timeout
|
||||
private int aiTimeout = 5;
|
||||
|
||||
private List<Card> sacrificedThisTurn = new ArrayList<>();
|
||||
private List<Card> discardedThisTurn = new ArrayList<>();
|
||||
@@ -209,6 +211,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
super(id0);
|
||||
|
||||
game = game0;
|
||||
aiTimeout = game.AI_TIMEOUT;
|
||||
for (final ZoneType z : Player.ALL_ZONES) {
|
||||
final PlayerZone toPut = z == ZoneType.Battlefield ? new PlayerZoneBattlefield(z, this) : new PlayerZone(z, this);
|
||||
zones.put(z, toPut);
|
||||
@@ -267,6 +270,10 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
teamNumber = iTeam;
|
||||
}
|
||||
|
||||
public final int getTimeout() {
|
||||
return aiTimeout;
|
||||
}
|
||||
|
||||
public boolean isArchenemy() {
|
||||
return getZone(ZoneType.SchemeDeck).size() > 0; //Only the archenemy has schemes.
|
||||
}
|
||||
|
||||
@@ -209,6 +209,7 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
initializeMulliganRuleComboBox();
|
||||
initializeAiProfilesComboBox();
|
||||
initializeAiSideboardingModeComboBox();
|
||||
initializeAiTimeoutComboBox();
|
||||
initializeSoundSetsComboBox();
|
||||
initializeMusicSetsComboBox();
|
||||
initializeStackAdditionsComboBox();
|
||||
@@ -415,6 +416,14 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
comboBox.addActionListener(actionEvent -> AiProfileUtil.setAiSideboardingMode(AiProfileUtil.AISideboardingMode.normalizedValueOf(comboBox.getSelectedItem())));
|
||||
}
|
||||
|
||||
private void initializeAiTimeoutComboBox() {
|
||||
final FPref userSetting = FPref.MATCH_AI_TIMEOUT;
|
||||
final FComboBoxPanel<String> panel = this.view.getAiTimeoutComboBox();
|
||||
final FComboBox<String> comboBox = createComboBox(new String[] {"5", "10", "60", "120", "240", "300", "600"}, userSetting);
|
||||
final String selectedItem = this.prefs.getPref(userSetting);
|
||||
panel.setComboBox(comboBox, selectedItem);
|
||||
}
|
||||
|
||||
private void initializeSoundSetsComboBox() {
|
||||
final FPref userSetting = FPref.UI_CURRENT_SOUND_SET;
|
||||
final FComboBoxPanel<String> panel = this.view.getSoundSetsComboBoxPanel();
|
||||
|
||||
@@ -135,6 +135,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
private final FComboBoxPanel<String> cbpMusicSets = new FComboBoxPanel<>(localizer.getMessage("cbpMusicSets")+":");
|
||||
private final FComboBoxPanel<String> cbpAiProfiles = new FComboBoxPanel<>(localizer.getMessage("cbpAiProfiles")+":");
|
||||
private final FComboBoxPanel<String> cbpAiSideboardingMode = new FComboBoxPanel<>(localizer.getMessage("cbpAiSideboardingMode")+":");
|
||||
private final FComboBoxPanel<String> cbpAiTimeout = new FComboBoxPanel<>(localizer.getMessage("cbAITimeout")+":");
|
||||
private final FComboBoxPanel<String> cbpStackAdditions = new FComboBoxPanel<>(localizer.getMessage("cbpStackAdditions")+":");
|
||||
private final FComboBoxPanel<String> cbpLandPlayed = new FComboBoxPanel<>(localizer.getMessage("cbpLandPlayed")+":");
|
||||
private final FComboBoxPanel<String> cbpDisplayCurrentCardColors = new FComboBoxPanel<>(localizer.getMessage("cbpDisplayCurrentCardColors")+":");
|
||||
@@ -245,6 +246,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
pnlPrefs.add(cbExperimentalRestore, titleConstraints);
|
||||
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlExperimentalRestore")), descriptionConstraints);
|
||||
|
||||
pnlPrefs.add(cbpAiTimeout, titleConstraints);
|
||||
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlAITimeout")), descriptionConstraints);
|
||||
|
||||
pnlPrefs.add(cbFilteredHands, titleConstraints);
|
||||
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlFilteredHands")), descriptionConstraints);
|
||||
|
||||
@@ -790,6 +794,10 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
return cbpAiSideboardingMode;
|
||||
}
|
||||
|
||||
public FComboBoxPanel<String> getAiTimeoutComboBox() {
|
||||
return cbpAiTimeout;
|
||||
}
|
||||
|
||||
public FComboBoxPanel<String> getCbpStackAdditionsComboBoxPanel() {
|
||||
return cbpStackAdditions;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class SimulationTest {
|
||||
Game game = new Game(players, rules, match);
|
||||
game.setAge(GameStage.Play);
|
||||
game.EXPERIMENTAL_RESTORE_SNAPSHOT = false;
|
||||
game.AI_TIMEOUT = FModel.getPreferences().getPrefInt(FPref.MATCH_AI_TIMEOUT);
|
||||
|
||||
return game;
|
||||
}
|
||||
|
||||
@@ -244,6 +244,10 @@ public class SettingsPage extends TabPage<SettingsScreen> {
|
||||
Forge.getLocalizer().getMessage("cbExperimentalRestore"),
|
||||
Forge.getLocalizer().getMessage("nlExperimentalRestore")),
|
||||
1);
|
||||
lstSettings.addItem(new CustomSelectSetting(FPref.MATCH_AI_TIMEOUT, Forge.getLocalizer().getMessage("cbAITimeout"),
|
||||
Forge.getLocalizer().getMessage("nlAITimeout"),
|
||||
Lists.newArrayList("5", "10", "60", "120", "240", "300", "600")),
|
||||
1);
|
||||
lstSettings.addItem(new BooleanSetting(FPref.FILTERED_HANDS,
|
||||
Forge.getLocalizer().getMessage("cbFilteredHands"),
|
||||
Forge.getLocalizer().getMessage("nlFilteredHands")),
|
||||
|
||||
@@ -3475,4 +3475,6 @@ lblDefaultCollection=Standardsammlungen
|
||||
lblSellable=Verkaufbar
|
||||
lblAutoSellable=Autoverkauf
|
||||
lblNonSellable=Kein Verkauf
|
||||
lblPromptAutoSell=Aufforderung zum Autoverkauf
|
||||
lblPromptAutoSell=Aufforderung zum Autoverkauf
|
||||
cbAITimeout=AI Time-out
|
||||
nlAITimeout=Zeitüberschreitung in Sekunden für AI, wenn die zu spielenden Zauber berechnet und Angreifer deklariert werden
|
||||
@@ -3194,4 +3194,6 @@ lblDefaultCollection=Default Collections
|
||||
lblSellable=Sellable
|
||||
lblAutoSellable=Auto-Sell
|
||||
lblNonSellable=No-Sell
|
||||
lblPromptAutoSell=Prompt for auto sell
|
||||
lblPromptAutoSell=Prompt for auto sell
|
||||
cbAITimeout=AI Timeout
|
||||
nlAITimeout=Time-out in seconds for AI when computing for spells to play and declaring attackers
|
||||
@@ -3482,4 +3482,6 @@ lblDefaultCollection=Colecciones predeterminadas
|
||||
lblSellable=Vendible
|
||||
lblAutoSellable=Venta automática
|
||||
lblNonSellable=Sin venta
|
||||
lblPromptAutoSell=Solicitar venta automática
|
||||
lblPromptAutoSell=Solicitar venta automática
|
||||
cbAITimeout=AI Se acabó el tiempo
|
||||
nlAITimeout=Tiempo de espera en segundos para AI al calcular los hechizos a jugar y declarar atacantes
|
||||
@@ -3483,4 +3483,6 @@ lblDefaultCollection=Collections par défaut
|
||||
lblSellable=Vendable
|
||||
lblAutoSellable=Vente automatique
|
||||
lblNonSellable=Pas de vente
|
||||
lblPromptAutoSell=Invite pour la vente automatique
|
||||
lblPromptAutoSell=Invite pour la vente automatique
|
||||
cbAITimeout=AI Temps mort
|
||||
nlAITimeout=Délai d'attente en secondes pour AI lors du calcul des sorts à jouer et de la déclaration des attaquants
|
||||
@@ -3481,4 +3481,6 @@ lblDefaultCollection=Raccolte predefinite
|
||||
lblSellable=Vendibile
|
||||
lblAutoSellable=Vendita automatica
|
||||
lblNonSellable=Nessuna vendita
|
||||
lblPromptAutoSell=Richiesta di vendita auto
|
||||
lblPromptAutoSell=Richiesta di vendita auto
|
||||
cbAITimeout=AI Tempo scaduto
|
||||
nlAITimeout=Timeout in secondi per AI durante il calcolo degli incantesimi da giocare e la dichiarazione degli attaccanti
|
||||
@@ -3477,4 +3477,6 @@ lblDefaultCollection=デフォルトのコレクション
|
||||
lblSellable=販売可能
|
||||
lblAutoSellable=自動販売
|
||||
lblNonSellable=売りません
|
||||
lblPromptAutoSell=自動車販売のプロンプト
|
||||
lblPromptAutoSell=自動車販売のプロンプト
|
||||
cbAITimeout=AI タイムアウト
|
||||
nlAITimeout=プレイする呪文を計算し、攻撃者を宣言するときの AI のタイムアウト (秒単位)
|
||||
@@ -3567,4 +3567,6 @@ lblDefaultCollection=Coleções padrão
|
||||
lblSellable=Vendável
|
||||
lblAutoSellable=Venda automática
|
||||
lblNonSellable=Não vender
|
||||
lblPromptAutoSell=Solicitação de venda automática
|
||||
lblPromptAutoSell=Solicitação de venda automática
|
||||
cbAITimeout=AI Tempo esgotado
|
||||
nlAITimeout=Tempo limite em segundos para AI ao calcular feitiços para jogar e declarar atacantes
|
||||
@@ -3468,4 +3468,6 @@ lblDefaultCollection=默认集合
|
||||
lblSellable=可出售
|
||||
lblAutoSellable=自动销售
|
||||
lblNonSellable=不卖
|
||||
lblPromptAutoSell=提示汽车出售
|
||||
lblPromptAutoSell=提示汽车出售
|
||||
cbAITimeout=AI 暂停
|
||||
nlAITimeout=计算要播放的咒语并宣布攻击者时,AI 超时(以秒为单位)
|
||||
@@ -155,6 +155,7 @@ public class HostedMatch {
|
||||
|
||||
game = match.createGame();
|
||||
game.EXPERIMENTAL_RESTORE_SNAPSHOT = FModel.getPreferences().getPrefBoolean(FPref.MATCH_EXPERIMENTAL_RESTORE);
|
||||
game.AI_TIMEOUT = FModel.getPreferences().getPrefInt(FPref.MATCH_AI_TIMEOUT);
|
||||
|
||||
StaticData.instance().setSourceImageForClone(FModel.getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE));
|
||||
|
||||
|
||||
@@ -205,6 +205,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
|
||||
|
||||
MATCH_AI_SIDEBOARDING_MODE("Human For AI"),
|
||||
MATCH_EXPERIMENTAL_RESTORE("false"),
|
||||
MATCH_AI_TIMEOUT("5"),
|
||||
ENFORCE_DECK_LEGALITY ("true"),
|
||||
PERFORMANCE_MODE ("false"),
|
||||
FILTERED_HANDS ("false"),
|
||||
|
||||
Reference in New Issue
Block a user