diff --git a/Mage.Server/src/main/java/mage/server/game/GameController.java b/Mage.Server/src/main/java/mage/server/game/GameController.java index af70aa389e..3c7b72ed55 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -85,7 +85,7 @@ public class GameController implements GameCallback { private UUID tableId; private UUID choosingPlayerId; private Future gameFuture; - + private boolean useTimeout = true; public GameController(Game game, ConcurrentHashMap userPlayerMap, UUID tableId, UUID choosingPlayerId) { gameSessionId = UUID.randomUUID(); @@ -94,6 +94,12 @@ public class GameController implements GameCallback { this.game = game; this.tableId = tableId; this.choosingPlayerId = choosingPlayerId; + for (Player player: game.getPlayers().values()) { + if (!player.isHuman()) { + useTimeout = false; + break; + } + } init(); } @@ -185,7 +191,7 @@ public class GameController implements GameCallback { public void join(UUID userId) { UUID playerId = userPlayerMap.get(userId); - GameSession gameSession = new GameSession(game, userId, playerId); + GameSession gameSession = new GameSession(game, userId, playerId, useTimeout); gameSessions.put(playerId, gameSession); User user = UserManager.getInstance().getUser(userId); gameSession.setUserData(user.getUserData()); diff --git a/Mage.Server/src/main/java/mage/server/game/GameSession.java b/Mage.Server/src/main/java/mage/server/game/GameSession.java index e9e3cf0b10..d9b2939873 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameSession.java +++ b/Mage.Server/src/main/java/mage/server/game/GameSession.java @@ -57,15 +57,17 @@ import mage.view.SimpleCardsView; public class GameSession extends GameWatcher { private UUID playerId; + private boolean useTimeout; private ScheduledFuture futureTimeout; protected static ScheduledExecutorService timeoutExecutor = ThreadExecutor.getInstance().getTimeoutExecutor(); private UserData userData; - public GameSession(Game game, UUID userId, UUID playerId) { + public GameSession(Game game, UUID userId, UUID playerId, boolean useTimeout) { super(userId, game); this.playerId = playerId; + this.useTimeout = useTimeout; } public void ask(final String question) { @@ -158,6 +160,8 @@ public class GameSession extends GameWatcher { } private synchronized void setupTimeout() { + if (!useTimeout) + return; cancelTimeout(); futureTimeout = timeoutExecutor.schedule( new Runnable() {