[minor] formatting

This commit is contained in:
LevelX2 2013-03-27 17:24:51 +01:00
parent 7014b28797
commit 8e3ebed11f
11 changed files with 118 additions and 77 deletions

View file

@ -28,6 +28,9 @@
package mage.server; package mage.server;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import mage.MageException; import mage.MageException;
import mage.server.services.LogKeys; import mage.server.services.LogKeys;
import mage.server.services.impl.LogServiceImpl; import mage.server.services.impl.LogServiceImpl;
@ -35,9 +38,6 @@ import mage.view.UserDataView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.InvokerCallbackHandler;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* *
@ -55,7 +55,9 @@ public class SessionManager {
private ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<String, Session>(); private ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<String, Session>();
public Session getSession(String sessionId) { public Session getSession(String sessionId) {
if (sessions == null || sessionId == null) return null; if (sessions == null || sessionId == null) {
return null;
}
return sessions.get(sessionId); return sessions.get(sessionId);
} }
@ -135,8 +137,9 @@ public class SessionManager {
} }
public boolean isValidSession(String sessionId) { public boolean isValidSession(String sessionId) {
if (sessions.containsKey(sessionId)) if (sessions.containsKey(sessionId)) {
return true; return true;
}
return false; return false;
} }

View file

@ -28,6 +28,12 @@
package mage.server; package mage.server;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import mage.Constants.RangeOfInfluence; import mage.Constants.RangeOfInfluence;
import mage.Constants.TableState; import mage.Constants.TableState;
import mage.MageException; import mage.MageException;
@ -59,12 +65,6 @@ import mage.server.util.ServerMessagesUtil;
import mage.server.util.ThreadExecutor; import mage.server.util.ThreadExecutor;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
/** /**
* *
@ -95,8 +95,9 @@ public class TableController {
User user = UserManager.getInstance().getUser(userId); User user = UserManager.getInstance().getUser(userId);
controllerName = user.getName(); controllerName = user.getName();
} }
else else {
controllerName = "System"; controllerName = "System";
}
table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getDeckType()), options.getPlayerTypes(), match); table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getDeckType()), options.getPlayerTypes(), match);
init(); init();
} }
@ -109,8 +110,9 @@ public class TableController {
User user = UserManager.getInstance().getUser(userId); User user = UserManager.getInstance().getUser(userId);
controllerName = user.getName(); controllerName = user.getName();
} }
else else {
controllerName = "System"; controllerName = "System";
}
table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), tournament); table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), tournament);
} }
@ -265,8 +267,9 @@ public class TableController {
else { else {
player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill); player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill);
} }
if (player != null) if (player != null) {
logger.info("Player created " + player.getId()); logger.info("Player created " + player.getId());
}
return player; return player;
} }
@ -276,9 +279,10 @@ public class TableController {
} }
public synchronized void leaveTable(UUID userId) { public synchronized void leaveTable(UUID userId) {
if (table.getState() == TableState.WAITING || table.getState() == TableState.STARTING) if (table.getState() == TableState.WAITING || table.getState() == TableState.STARTING) {
table.leaveTable(userPlayerMap.get(userId)); table.leaveTable(userPlayerMap.get(userId));
} }
}
public synchronized void startMatch(UUID userId) { public synchronized void startMatch(UUID userId) {
if (userId.equals(this.userId)) { if (userId.equals(this.userId)) {
@ -292,9 +296,9 @@ public class TableController {
match.startMatch(); match.startMatch();
match.startGame(); match.startGame();
table.initGame(); table.initGame();
GameOptions options = new GameOptions(); GameOptions gameOptions = new GameOptions();
options.testMode = true; gameOptions.testMode = true;
// match.getGame().setGameOptions(options); // match.getGame().setGameOptions(gameOptions);
GameManager.getInstance().createGameSession(match.getGame(), userPlayerMap, table.getId(), null); GameManager.getInstance().createGameSession(match.getGame(), userPlayerMap, table.getId(), null);
ChallengeManager.getInstance().prepareChallenge(getPlayerId(), match); ChallengeManager.getInstance().prepareChallenge(getPlayerId(), match);
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) { for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
@ -312,8 +316,9 @@ public class TableController {
playerId = entry.getValue(); playerId = entry.getValue();
break; break;
} }
if (playerId == null) if (playerId == null) {
throw new GameException("Couldn't find a player in challenge mode."); throw new GameException("Couldn't find a player in challenge mode.");
}
return playerId; return playerId;
} }
@ -397,8 +402,9 @@ public class TableController {
if (entry.getValue().equals(playerId)) { if (entry.getValue().equals(playerId)) {
User user = UserManager.getInstance().getUser(entry.getKey()); User user = UserManager.getInstance().getUser(entry.getKey());
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS); int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
if (user != null) if (user != null) {
user.sideboard(deck, table.getId(), remaining, options.isLimited()); user.sideboard(deck, table.getId(), remaining, options.isLimited());
}
break; break;
} }
} }
@ -464,10 +470,11 @@ public class TableController {
private void autoSideboard() { private void autoSideboard() {
for (MatchPlayer player: match.getPlayers()) { for (MatchPlayer player: match.getPlayers()) {
if (!player.isDoneSideboarding()) if (!player.isDoneSideboarding()) {
match.submitDeck(player.getPlayer().getId(), player.generateDeck()); match.submitDeck(player.getPlayer().getId(), player.generateDeck());
} }
} }
}
public void endDraft(Draft draft) { public void endDraft(Draft draft) {
for (DraftPlayer player: draft.getPlayers()) { for (DraftPlayer player: draft.getPlayers()) {
@ -494,8 +501,9 @@ public class TableController {
} }
public boolean isOwner(UUID userId) { public boolean isOwner(UUID userId) {
if (userId == null) if (userId == null) {
return false; return false;
}
return userId.equals(this.userId); return userId.equals(this.userId);
} }

View file

@ -28,6 +28,12 @@
package mage.server; package mage.server;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import mage.Constants;
import mage.MageException; import mage.MageException;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.cards.decks.DeckCardLists; import mage.cards.decks.DeckCardLists;
@ -36,19 +42,13 @@ import mage.game.Table;
import mage.game.draft.Draft; import mage.game.draft.Draft;
import mage.game.match.Match; import mage.game.match.Match;
import mage.game.match.MatchOptions; import mage.game.match.MatchOptions;
import mage.game.match.MatchPlayer;
import mage.game.tournament.Tournament; import mage.game.tournament.Tournament;
import mage.game.tournament.TournamentOptions; import mage.game.tournament.TournamentOptions;
import mage.players.Player; import mage.players.Player;
import mage.server.game.GamesRoomManager; import mage.server.game.GamesRoomManager;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import mage.Constants;
import mage.game.match.MatchPlayer;
/** /**
* *
@ -124,8 +124,9 @@ public class TableManager {
} }
public Match getMatch(UUID tableId) { public Match getMatch(UUID tableId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
return controllers.get(tableId).getMatch(); return controllers.get(tableId).getMatch();
}
return null; return null;
} }
@ -138,27 +139,31 @@ public class TableManager {
} }
public boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws MageException { public boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws MageException {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
return controllers.get(tableId).joinTable(userId, name, playerType, skill, deckList); return controllers.get(tableId).joinTable(userId, name, playerType, skill, deckList);
}
return false; return false;
} }
public boolean joinTournament(UUID userId, UUID tableId, String name, String playerType, int skill) throws GameException { public boolean joinTournament(UUID userId, UUID tableId, String name, String playerType, int skill) throws GameException {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
return controllers.get(tableId).joinTournament(userId, name, playerType, skill); return controllers.get(tableId).joinTournament(userId, name, playerType, skill);
}
return false; return false;
} }
public boolean submitDeck(UUID userId, UUID tableId, DeckCardLists deckList) throws MageException { public boolean submitDeck(UUID userId, UUID tableId, DeckCardLists deckList) throws MageException {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
return controllers.get(tableId).submitDeck(userId, deckList); return controllers.get(tableId).submitDeck(userId, deckList);
}
return false; return false;
} }
public void updateDeck(UUID userId, UUID tableId, DeckCardLists deckList) throws MageException { public void updateDeck(UUID userId, UUID tableId, DeckCardLists deckList) throws MageException {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).updateDeck(userId, deckList); controllers.get(tableId).updateDeck(userId, deckList);
} }
}
public void removeSession(UUID userId) { public void removeSession(UUID userId) {
for (TableController controller: controllers.values()) { for (TableController controller: controllers.values()) {
@ -167,8 +172,9 @@ public class TableManager {
} }
public boolean isTableOwner(UUID tableId, UUID userId) { public boolean isTableOwner(UUID tableId, UUID userId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
return controllers.get(tableId).isOwner(userId); return controllers.get(tableId).isOwner(userId);
}
return false; return false;
} }
@ -181,67 +187,79 @@ public class TableManager {
} }
public void leaveTable(UUID userId, UUID tableId) { public void leaveTable(UUID userId, UUID tableId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).leaveTable(userId); controllers.get(tableId).leaveTable(userId);
} }
}
public UUID getChatId(UUID tableId) { public UUID getChatId(UUID tableId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
return controllers.get(tableId).getChatId(); return controllers.get(tableId).getChatId();
}
return null; return null;
} }
public void startMatch(UUID userId, UUID roomId, UUID tableId) { public void startMatch(UUID userId, UUID roomId, UUID tableId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).startMatch(userId); controllers.get(tableId).startMatch(userId);
} }
}
public void startMatch(UUID roomId, UUID tableId) { public void startMatch(UUID roomId, UUID tableId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).startMatch(); controllers.get(tableId).startMatch();
} }
}
public void startChallenge(UUID userId, UUID roomId, UUID tableId, UUID challengeId) { public void startChallenge(UUID userId, UUID roomId, UUID tableId, UUID challengeId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).startChallenge(userId, challengeId); controllers.get(tableId).startChallenge(userId, challengeId);
} }
}
public void startTournament(UUID userId, UUID roomId, UUID tableId) { public void startTournament(UUID userId, UUID roomId, UUID tableId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).startTournament(userId); controllers.get(tableId).startTournament(userId);
} }
}
public void startDraft(UUID tableId, Draft draft) { public void startDraft(UUID tableId, Draft draft) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).startDraft(draft); controllers.get(tableId).startDraft(draft);
} }
}
public boolean watchTable(UUID userId, UUID tableId) { public boolean watchTable(UUID userId, UUID tableId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
return controllers.get(tableId).watchTable(userId); return controllers.get(tableId).watchTable(userId);
}
return false; return false;
} }
public boolean replayTable(UUID userId, UUID tableId) { public boolean replayTable(UUID userId, UUID tableId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
return controllers.get(tableId).replayTable(userId); return controllers.get(tableId).replayTable(userId);
}
return false; return false;
} }
public void endGame(UUID tableId) { public void endGame(UUID tableId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).endGame(); controllers.get(tableId).endGame();
} }
}
public void endDraft(UUID tableId, Draft draft) { public void endDraft(UUID tableId, Draft draft) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).endDraft(draft); controllers.get(tableId).endDraft(draft);
} }
}
public void endTournament(UUID tableId, Tournament tournament) { public void endTournament(UUID tableId, Tournament tournament) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).endTournament(tournament); controllers.get(tableId).endTournament(tournament);
} }
}
public void swapSeats(UUID tableId, UUID userId, int seatNum1, int seatNum2) { public void swapSeats(UUID tableId, UUID userId, int seatNum1, int seatNum2) {
if (controllers.containsKey(tableId) && isTableOwner(tableId, userId)) { if (controllers.containsKey(tableId) && isTableOwner(tableId, userId)) {
@ -250,14 +268,16 @@ public class TableManager {
} }
public void construct(UUID tableId) { public void construct(UUID tableId) {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).construct(); controllers.get(tableId).construct();
} }
}
public void addPlayer(UUID userId, UUID tableId, Player player, String playerType, Deck deck) throws GameException { public void addPlayer(UUID userId, UUID tableId, Player player, String playerType, Deck deck) throws GameException {
if (controllers.containsKey(tableId)) if (controllers.containsKey(tableId)) {
controllers.get(tableId).addPlayer(userId, player, playerType, deck); controllers.get(tableId).addPlayer(userId, player, playerType, deck);
} }
}
public void removeTable(UUID tableId) { public void removeTable(UUID tableId) {
if (tables.containsKey(tableId)) { if (tables.containsKey(tableId)) {
@ -265,10 +285,11 @@ public class TableManager {
controllers.remove(tableId); controllers.remove(tableId);
tables.remove(tableId); tables.remove(tableId);
GamesRoomManager.getInstance().removeTable(tableId); GamesRoomManager.getInstance().removeTable(tableId);
if (table.getMatch() != null && table.getMatch().getGame() != null) if (table.getMatch() != null && table.getMatch().getGame() != null) {
table.getMatch().getGame().end(); table.getMatch().getGame().end();
} }
} }
}
private void checkExpired() { private void checkExpired() {
logger.info("Table expire checking..."); logger.info("Table expire checking...");

View file

@ -27,6 +27,11 @@
*/ */
package mage.server; package mage.server;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.game.Table; import mage.game.Table;
import mage.interfaces.callback.ClientCallback; import mage.interfaces.callback.ClientCallback;
@ -38,11 +43,6 @@ import mage.server.tournament.TournamentSession;
import mage.view.TableClientMessage; import mage.view.TableClientMessage;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
/** /**
* *
@ -120,10 +120,11 @@ public class User {
public synchronized void fireCallback(final ClientCallback call) { public synchronized void fireCallback(final ClientCallback call) {
if (isConnected()) { if (isConnected()) {
Session session = SessionManager.getInstance().getSession(sessionId); Session session = SessionManager.getInstance().getSession(sessionId);
if (session != null) if (session != null) {
session.fireCallback(call); session.fireCallback(call);
} }
} }
}
public void joinedTable(final UUID roomId, final UUID tableId, boolean isTournament) { public void joinedTable(final UUID roomId, final UUID tableId, boolean isTournament) {
fireCallback(new ClientCallback("joinedTable", tableId, new TableClientMessage(roomId, tableId, isTournament))); fireCallback(new ClientCallback("joinedTable", tableId, new TableClientMessage(roomId, tableId, isTournament)));

View file

@ -27,9 +27,6 @@
*/ */
package mage.server; package mage.server;
import mage.view.ChatMessage.MessageColor;
import org.apache.log4j.Logger;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
@ -37,6 +34,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import mage.view.ChatMessage.MessageColor;
import org.apache.log4j.Logger;
/** /**
* *
@ -68,8 +67,9 @@ public class UserManager {
private ConcurrentHashMap<UUID, User> users = new ConcurrentHashMap<UUID, User>(); private ConcurrentHashMap<UUID, User> users = new ConcurrentHashMap<UUID, User>();
public User createUser(String userName, String host) { public User createUser(String userName, String host) {
if (findUser(userName) != null) if (findUser(userName) != null) {
return null; //user already exists return null; //user already exists
}
User user = new User(userName, host); User user = new User(userName, host);
users.put(user.getId(), user); users.put(user.getId(), user);
return user; return user;
@ -81,9 +81,10 @@ public class UserManager {
public User findUser(String userName) { public User findUser(String userName) {
for (User user: users.values()) { for (User user: users.values()) {
if (user.getName().equals(userName)) if (user.getName().equals(userName)) {
return user; return user;
} }
}
return null; return null;
} }

View file

@ -1,11 +1,10 @@
package mage.server.challenge; package mage.server.challenge;
import mage.Constants;
import mage.game.match.Match;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import mage.Constants;
import mage.game.match.Match;
/** /**
* Loads challenges from scenarios. * Loads challenges from scenarios.

View file

@ -153,8 +153,9 @@ public class DraftController {
} }
private boolean allJoined() { private boolean allJoined() {
if (!draft.allJoined()) if (!draft.allJoined()) {
return false; return false;
}
for (DraftPlayer player: draft.getPlayers()) { for (DraftPlayer player: draft.getPlayers()) {
if (player.getPlayer().isHuman() && draftSessions.get(player.getPlayer().getId()) == null) { if (player.getPlayer().isHuman() && draftSessions.get(player.getPlayer().getId()) == null) {
return false; return false;
@ -206,8 +207,9 @@ public class DraftController {
} }
private synchronized void pickCard(UUID playerId, int timeout) throws MageException { private synchronized void pickCard(UUID playerId, int timeout) throws MageException {
if (draftSessions.containsKey(playerId)) if (draftSessions.containsKey(playerId)) {
draftSessions.get(playerId).pickCard(timeout); draftSessions.get(playerId).pickCard(timeout);
} }
}
} }

View file

@ -148,16 +148,18 @@ public class DraftSession {
public DraftPickView sendCardPick(UUID cardId) { public DraftPickView sendCardPick(UUID cardId) {
cancelTimeout(); cancelTimeout();
if (draft.addPick(playerId, cardId)) if (draft.addPick(playerId, cardId)) {
return getDraftPickView(0); return getDraftPickView(0);
}
return null; return null;
} }
public void removeDraft() { public void removeDraft() {
User user = UserManager.getInstance().getUser(userId); User user = UserManager.getInstance().getUser(userId);
if (user != null) if (user != null) {
user.removeDraft(playerId); user.removeDraft(playerId);
} }
}
private DraftView getDraftView() { private DraftView getDraftView() {
return new DraftView(draft); return new DraftView(draft);

View file

@ -28,6 +28,9 @@
package mage.server.tournament; package mage.server.tournament;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import mage.MageException; import mage.MageException;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.game.GameException; import mage.game.GameException;
@ -49,9 +52,6 @@ import mage.view.ChatMessage.MessageColor;
import mage.view.TournamentView; import mage.view.TournamentView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* *
@ -156,8 +156,9 @@ public class TournamentController {
} }
private boolean allJoined() { private boolean allJoined() {
if (!tournament.allJoined()) if (!tournament.allJoined()) {
return false; return false;
}
for (TournamentPlayer player: tournament.getPlayers()) { for (TournamentPlayer player: tournament.getPlayers()) {
if (player.getPlayer().isHuman() && tournamentSessions.get(player.getPlayer().getId()) == null) { if (player.getPlayer().isHuman() && tournamentSessions.get(player.getPlayer().getId()) == null) {
return false; return false;
@ -263,9 +264,10 @@ public class TournamentController {
private UUID getPlayerSessionId(UUID playerId) { private UUID getPlayerSessionId(UUID playerId) {
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) { for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
if (entry.getValue().equals(playerId)) if (entry.getValue().equals(playerId)) {
return entry.getKey(); return entry.getKey();
} }
}
return null; return null;
} }

View file

@ -33,10 +33,10 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import mage.cards.Sets;
import mage.game.tournament.Tournament; import mage.game.tournament.Tournament;
import mage.game.tournament.TournamentOptions; import mage.game.tournament.TournamentOptions;
import mage.game.tournament.TournamentType; import mage.game.tournament.TournamentType;
import mage.cards.Sets;
import mage.view.TournamentTypeView; import mage.view.TournamentTypeView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;

View file

@ -124,8 +124,9 @@ public class TournamentSession {
} }
private synchronized void setupTimeout(int seconds) { private synchronized void setupTimeout(int seconds) {
if (futureTimeout != null && !futureTimeout.isDone()) if (futureTimeout != null && !futureTimeout.isDone()) {
return; return;
}
cancelTimeout(); cancelTimeout();
if (seconds > 0) { if (seconds > 0) {
futureTimeout = timeoutExecutor.schedule( futureTimeout = timeoutExecutor.schedule(
@ -148,9 +149,10 @@ public class TournamentSession {
public void removeTournament() { public void removeTournament() {
User user = UserManager.getInstance().getUser(userId); User user = UserManager.getInstance().getUser(userId);
if (user != null) if (user != null) {
user.removeTournament(playerId); user.removeTournament(playerId);
} }
}
private TournamentView getTournamentView() { private TournamentView getTournamentView() {
return new TournamentView(tournament); return new TournamentView(tournament);