mirror of
https://github.com/correl/mage.git
synced 2025-04-11 09:11:12 -09:00
* Changed logging level back to info, changed level of a lot of messages to debug from info. Added check that certain AI players can't join a table with no appropriate format.
This commit is contained in:
parent
7a4469fd80
commit
d34779fa68
26 changed files with 146 additions and 69 deletions
Mage.Client/src/main/java/mage/client/dialog
Mage.Server.Plugins/Mage.Player.AI.DraftBot/src/mage/player/ai
Mage.Server
config
release/config
src/main
java/mage/server
ChatSession.javaMageServerImpl.javaMain.javaSession.javaTableController.javaTableManager.javaUserManager.java
draft
game
tournament
resources
Mage/src/mage
game/tournament
players
|
@ -339,7 +339,7 @@ public class NewTableDialog extends MageDialog {
|
|||
for (TablePlayerPanel player: players) {
|
||||
if (!player.getPlayerType().equals("Human")) {
|
||||
if (!player.joinTable(roomId, table.getTableId())) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
// error message must be send by the server
|
||||
session.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
return;
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="pnlPacks" pref="67" max="32767" attributes="0"/>
|
||||
<Component id="pnlPacks" pref="69" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
|
@ -124,7 +124,7 @@
|
|||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="spnNumPlayers" pref="23" max="32767" attributes="1"/>
|
||||
<Component id="spnNumPlayers" pref="25" max="32767" attributes="1"/>
|
||||
<Component id="pnlDraftOptions" max="32767" attributes="1"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
|
||||
|
|
|
@ -401,7 +401,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
for (TournamentPlayerPanel player: players) {
|
||||
if (!player.getPlayerType().toString().equals("Human")) {
|
||||
if (!player.joinTournamentTable(roomId, table.getTableId())) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
// error message must be send by sever
|
||||
session.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
return;
|
||||
|
|
|
@ -30,6 +30,8 @@ package mage.player.ai;
|
|||
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.game.Game;
|
||||
import mage.game.Table;
|
||||
import mage.game.tournament.TournamentType;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
@ -65,4 +67,15 @@ public class ComputerDraftPlayer extends ComputerPlayer<ComputerDraftPlayer> imp
|
|||
game.concede(playerId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canJoinTable(Table table) {
|
||||
if (table.isTournament()) {
|
||||
TournamentType tournamentType = table.getTournament().getTournamentType();
|
||||
if(tournamentType != null && tournamentType.isDraft()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#default levels
|
||||
log4j.rootLogger=debug, console, logfile
|
||||
log4j.logger.com.j256.ormlite=warn
|
||||
|
||||
#console log
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#default levels
|
||||
log4j.rootLogger=warn, console, logfile
|
||||
|
||||
log4j.rootLogger=info, console, logfile
|
||||
log4j.logger.com.j256.ormlite=warn
|
||||
#console log
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ChatSession {
|
|||
String userName = user.getName();
|
||||
clients.put(userId, userName);
|
||||
broadcast(userName, " has joined", MessageColor.BLUE);
|
||||
logger.info(userName + " joined chat " + chatId);
|
||||
logger.debug(userName + " joined chat " + chatId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class ChatSession {
|
|||
message = " has left chat";
|
||||
}
|
||||
broadcast(userName, message, MessageColor.BLUE);
|
||||
logger.info(userName + message + " " + chatId);
|
||||
logger.debug(userName + message + " " + chatId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@
|
|||
|
||||
package mage.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.cards.repository.CardInfo;
|
||||
|
@ -44,26 +49,37 @@ import mage.interfaces.ServerState;
|
|||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.remote.MageVersionException;
|
||||
import mage.server.draft.DraftManager;
|
||||
import mage.server.game.*;
|
||||
import mage.server.game.DeckValidatorFactory;
|
||||
import mage.server.game.GameFactory;
|
||||
import mage.server.game.GameManager;
|
||||
import mage.server.game.GamesRoom;
|
||||
import mage.server.game.GamesRoomManager;
|
||||
import mage.server.game.PlayerFactory;
|
||||
import mage.server.game.ReplayManager;
|
||||
import mage.server.services.LogKeys;
|
||||
import mage.server.services.impl.FeedbackServiceImpl;
|
||||
import mage.server.services.impl.LogServiceImpl;
|
||||
import mage.server.tournament.TournamentFactory;
|
||||
import mage.server.tournament.TournamentManager;
|
||||
import mage.server.util.ConfigSettings;
|
||||
import mage.server.util.ServerMessagesUtil;
|
||||
import mage.server.util.ThreadExecutor;
|
||||
import mage.utils.*;
|
||||
import mage.view.*;
|
||||
import mage.utils.ActionWithBooleanResult;
|
||||
import mage.utils.ActionWithNullNegativeResult;
|
||||
import mage.utils.ActionWithTableViewResult;
|
||||
import mage.utils.CompressUtil;
|
||||
import mage.utils.MageVersion;
|
||||
import mage.view.ChatMessage;
|
||||
import mage.view.ChatMessage.MessageColor;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.GameView;
|
||||
import mage.view.MatchView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.TournamentView;
|
||||
import mage.view.UserDataView;
|
||||
import mage.view.UserView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import mage.server.util.ConfigSettings;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com, noxx
|
||||
|
@ -133,7 +149,7 @@ public class MageServerImpl implements MageServer {
|
|||
public TableView execute() throws MageException {
|
||||
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||
TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTable(userId, options);
|
||||
logger.info("Table " + table.getTableId() + " created");
|
||||
logger.debug("Table " + table.getTableId() + " created");
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_TABLE_CREATED, sessionId, userId.toString(), table.getTableId().toString());
|
||||
return table;
|
||||
}
|
||||
|
@ -166,7 +182,7 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
}
|
||||
TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTournamentTable(userId, options);
|
||||
logger.info("Tournament table " + table.getTableId() + " created");
|
||||
logger.debug("Tournament table " + table.getTableId() + " created");
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_TOURNAMENT_TABLE_CREATED, sessionId, userId.toString(), table.getTableId().toString());
|
||||
return table;
|
||||
} catch (Exception ex) {
|
||||
|
@ -195,7 +211,7 @@ public class MageServerImpl implements MageServer {
|
|||
public Boolean execute() throws MageException {
|
||||
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTable(userId, tableId, name, playerType, skill, deckList);
|
||||
logger.info("Session " + sessionId + " joined table " + tableId);
|
||||
logger.debug("Session " + sessionId + " joined table " + tableId);
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
|
@ -208,7 +224,7 @@ public class MageServerImpl implements MageServer {
|
|||
public Boolean execute() throws MageException {
|
||||
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTournamentTable(userId, tableId, name, playerType, skill);
|
||||
logger.info("Session " + sessionId + " joined table " + tableId);
|
||||
logger.debug("Session " + sessionId + " joined table " + tableId);
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
|
@ -221,7 +237,7 @@ public class MageServerImpl implements MageServer {
|
|||
public Boolean execute() throws MageException {
|
||||
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||
boolean ret = TableManager.getInstance().submitDeck(userId, tableId, deckList);
|
||||
logger.info("Session " + sessionId + " submitted deck");
|
||||
logger.debug("Session " + sessionId + " submitted deck");
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
|
@ -318,7 +334,7 @@ public class MageServerImpl implements MageServer {
|
|||
@Override
|
||||
public void execute() {
|
||||
SessionManager.getInstance().disconnect(sessionId, true);
|
||||
logger.info("Client deregistered ...");
|
||||
logger.debug("Client deregistered ...");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -167,13 +167,13 @@ public class Main {
|
|||
} else {
|
||||
sessionName = session.getHost();
|
||||
}
|
||||
if (throwable instanceof ClientDisconnectedException) {
|
||||
if (throwable instanceof ClientDisconnectedException) {
|
||||
SessionManager.getInstance().disconnect(client.getSessionId(), true);
|
||||
logger.info("client disconnected - " + sessionName);
|
||||
logger.info("Client disconnected - " + sessionName);
|
||||
}
|
||||
else {
|
||||
SessionManager.getInstance().disconnect(client.getSessionId(), false);
|
||||
logger.info("connection to client lost - " + sessionName);
|
||||
logger.info("Connection to client lost - " + sessionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ public class Main {
|
|||
private static Class<?> loadPlugin(Plugin plugin) {
|
||||
try {
|
||||
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
|
||||
logger.info("Loading plugin: " + plugin.getClassName());
|
||||
logger.debug("Loading plugin: " + plugin.getClassName());
|
||||
return Class.forName(plugin.getClassName(), true, classLoader);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.warn("Plugin not Found:" + plugin.getJar() + " - check plugin folder");
|
||||
|
@ -262,7 +262,7 @@ public class Main {
|
|||
private static MatchType loadGameType(GamePlugin plugin) {
|
||||
try {
|
||||
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
|
||||
logger.info("Loading game type: " + plugin.getClassName());
|
||||
logger.debug("Loading game type: " + plugin.getClassName());
|
||||
return (MatchType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.warn("Game type not found:" + plugin.getJar() + " - check plugin folder");
|
||||
|
@ -275,7 +275,7 @@ public class Main {
|
|||
private static TournamentType loadTournamentType(GamePlugin plugin) {
|
||||
try {
|
||||
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
|
||||
logger.info("Loading tournament type: " + plugin.getClassName());
|
||||
logger.debug("Loading tournament type: " + plugin.getClassName());
|
||||
return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.warn("Tournament type not found:" + plugin.getJar() + " - check plugin folder");
|
||||
|
|
|
@ -82,7 +82,7 @@ public class Session {
|
|||
Pattern p = Pattern.compile(ConfigSettings.getInstance().getUserNamePattern(), Pattern.CASE_INSENSITIVE);
|
||||
Matcher m = p.matcher(userName);
|
||||
if (m.find()) {
|
||||
throw new MageException("User name includes not allowed characters: use a-z, A-Z and 0-9");
|
||||
throw new MageException("User name '" + userName + "' includes not allowed characters: use a-z, A-Z and 0-9");
|
||||
}
|
||||
User user = UserManager.getInstance().createUser(userName, host);
|
||||
if (user == null) { // user already exists
|
||||
|
@ -99,11 +99,11 @@ public class Session {
|
|||
}
|
||||
}
|
||||
else {
|
||||
throw new MageException("User name already in use");
|
||||
throw new MageException("User name " + userName + " already in use");
|
||||
}
|
||||
}
|
||||
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
|
||||
throw new MageException("Error connecting");
|
||||
throw new MageException("Error connecting " + userName);
|
||||
}
|
||||
this.userId = user.getId();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.server;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
@ -36,15 +35,14 @@ 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.TableState;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.cards.decks.InvalidDeckException;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.constants.TableState;
|
||||
import mage.game.GameException;
|
||||
import mage.game.GameOptions;
|
||||
import mage.game.GameState;
|
||||
import mage.game.Seat;
|
||||
import mage.game.Table;
|
||||
import mage.game.draft.Draft;
|
||||
|
@ -57,18 +55,20 @@ import mage.game.match.MatchPlayer;
|
|||
import mage.game.tournament.Tournament;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
import mage.game.tournament.TournamentPlayer;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.players.Player;
|
||||
import mage.server.challenge.ChallengeManager;
|
||||
import mage.server.draft.DraftManager;
|
||||
import mage.server.game.*;
|
||||
import mage.server.game.DeckValidatorFactory;
|
||||
import mage.server.game.GameFactory;
|
||||
import mage.server.game.GameManager;
|
||||
import mage.server.game.PlayerFactory;
|
||||
import mage.server.game.ReplayManager;
|
||||
import mage.server.services.LogKeys;
|
||||
import mage.server.services.impl.LogServiceImpl;
|
||||
import mage.server.tournament.TournamentFactory;
|
||||
import mage.server.tournament.TournamentManager;
|
||||
import mage.server.util.ServerMessagesUtil;
|
||||
import mage.server.util.ThreadExecutor;
|
||||
import mage.view.GameEndView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
|
@ -164,8 +164,12 @@ public class TableController {
|
|||
logger.fatal(new StringBuilder("couldn't get user ").append(name).append(" for join tornament userId = ").append(userId).toString());
|
||||
return false;
|
||||
}
|
||||
if (!player.canJoinTable(table)) {
|
||||
user.showUserMessage("Join Table", new StringBuilder("A ").append(seat.getPlayerType()).append(" player can't join this table.").toString());
|
||||
return false;
|
||||
}
|
||||
user.addTable(player.getId(), table);
|
||||
logger.info("player joined " + player.getId());
|
||||
logger.debug("player joined " + player.getId());
|
||||
//only inform human players and add them to sessionPlayerMap
|
||||
if (seat.getPlayer().isHuman()) {
|
||||
user.joinedTable(table.getRoomId(), table.getId(), true);
|
||||
|
@ -227,10 +231,14 @@ public class TableController {
|
|||
user.showUserMessage("Join Table",message);
|
||||
return false;
|
||||
}
|
||||
if (!player.canJoinTable(table)) {
|
||||
user.showUserMessage("Join Table", new StringBuilder("A ").append(seat.getPlayerType()).append(" player can't join this table.").toString());
|
||||
return false;
|
||||
}
|
||||
match.addPlayer(player, deck);
|
||||
table.joinTable(player, seat);
|
||||
user.addTable(player.getId(), table);
|
||||
logger.info("player joined " + player.getId());
|
||||
logger.debug("player joined " + player.getId());
|
||||
//only inform human players and add them to sessionPlayerMap
|
||||
if (seat.getPlayer().isHuman()) {
|
||||
user.joinedTable(table.getRoomId(), table.getId(), false);
|
||||
|
@ -348,7 +356,7 @@ public class TableController {
|
|||
player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill);
|
||||
}
|
||||
if (player != null) {
|
||||
logger.info("Player created " + player.getId());
|
||||
logger.debug("Player created " + player.getId());
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ public class TableManager {
|
|||
}
|
||||
|
||||
private void checkExpired() {
|
||||
logger.info("Table expire checking...");
|
||||
logger.debug("Table expire checking...");
|
||||
|
||||
Date now = new Date();
|
||||
List<UUID> toRemove = new ArrayList<UUID>();
|
||||
|
@ -318,7 +318,7 @@ public class TableManager {
|
|||
// remove all not finished tables created more than expire_time ago
|
||||
long diff = (now.getTime() - table.getCreateTime().getTime()) / EXPIRE_TIME_UNIT_VALUE;
|
||||
if (diff >= EXPIRE_TIME) {
|
||||
logger.info("Table expired: id = " + table.getId() + ", created_by=" + table.getControllerName() + ". Removing...");
|
||||
logger.warn("Table expired: id = " + table.getId() + ", created_by=" + table.getControllerName() + ". Removing...");
|
||||
toRemove.add(table.getId());
|
||||
}
|
||||
// remove immediately non tournament tables with no human players
|
||||
|
@ -326,7 +326,7 @@ public class TableManager {
|
|||
boolean canBeRemoved = true;
|
||||
for (MatchPlayer matchPlayer :table.getMatch().getPlayers()) {
|
||||
Player player = matchPlayer.getPlayer();
|
||||
if (player != null && player.isHuman()) {
|
||||
if (player != null && player.isHuman() && !player.hasLeft()) {
|
||||
canBeRemoved = false;
|
||||
}
|
||||
// tournament sub tables may not be removed as long the tournament is not finished
|
||||
|
@ -335,7 +335,7 @@ public class TableManager {
|
|||
}
|
||||
}
|
||||
if (canBeRemoved) {
|
||||
logger.info("Table with no human player: id = " + table.getId() + ", created_by=" + table.getControllerName() + ". Removing...");
|
||||
logger.warn("Table with no active human player: id = " + table.getId() + ", created_by=" + table.getControllerName() + ". Removing...");
|
||||
toRemove.add(table.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,8 @@ public class UserManager {
|
|||
if (userId != null) {
|
||||
ChatManager.getInstance().removeUser(userId, User.DisconnectReason.Disconnected);
|
||||
if (users.containsKey(userId)) {
|
||||
logger.info("user disconnected " + userId);
|
||||
User user = users.get(userId);
|
||||
logger.info(new StringBuilder("User ").append(user.getName()).append("disconnected id:").append(userId).toString());
|
||||
users.get(userId).setSessionId("");
|
||||
ChatManager.getInstance().broadcast(userId, "has lost connection", MessageColor.BLACK);
|
||||
}
|
||||
|
@ -122,7 +123,7 @@ public class UserManager {
|
|||
if (users.containsKey(userId)) {
|
||||
logger.info("Remove user " + users.get(userId).getName() + ": " + userId + " Reason: " + reason.toString());
|
||||
ChatManager.getInstance().removeUser(userId, reason);
|
||||
ChatManager.getInstance().broadcast(userId, "has disconnected", MessageColor.BLACK);
|
||||
ChatManager.getInstance().broadcast(userId, new StringBuilder("has disconnected (").append(reason.toString()).append(")").toString(), MessageColor.BLACK);
|
||||
users.get(userId).kill(reason);
|
||||
users.remove(userId);
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public class DraftController {
|
|||
for (DraftPlayer player: draft.getPlayers()) {
|
||||
if (!player.getPlayer().isHuman()) {
|
||||
player.setJoined();
|
||||
logger.info("player " + player.getPlayer().getId() + " has joined draft " + draft.getId());
|
||||
logger.debug("player " + player.getPlayer().getId() + " has joined draft " + draft.getId());
|
||||
}
|
||||
}
|
||||
checkStart();
|
||||
|
@ -125,7 +125,7 @@ public class DraftController {
|
|||
DraftSession draftSession = new DraftSession(draft, userId, playerId);
|
||||
draftSessions.put(playerId, draftSession);
|
||||
UserManager.getInstance().getUser(userId).addDraft(playerId, draftSession);
|
||||
logger.info("User " + UserManager.getInstance().getUser(userId).getName() + " has joined draft " + draft.getId());
|
||||
logger.debug("User " + UserManager.getInstance().getUser(userId).getName() + " has joined draft " + draft.getId());
|
||||
draft.getPlayer(playerId).setJoined();
|
||||
checkStart();
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public class DraftController {
|
|||
public void timeout(UUID userId) {
|
||||
if (userPlayerMap.containsKey(userId)) {
|
||||
draft.autoPick(userPlayerMap.get(userId));
|
||||
logger.info("Draft pick timeout - autopick for player: " + userPlayerMap.get(userId));
|
||||
logger.debug("Draft pick timeout - autopick for player: " + userPlayerMap.get(userId));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class DeckValidatorFactory {
|
|||
logger.fatal("DeckValidatorFactory error", ex);
|
||||
return null;
|
||||
}
|
||||
logger.info("Deck validator created: " + validator.getName());
|
||||
logger.debug("Deck validator created: " + validator.getName());
|
||||
|
||||
return validator;
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ public class GameController implements GameCallback {
|
|||
@Override
|
||||
public void execute() throws MageException {
|
||||
game.concede(initPlayerId);
|
||||
logger.info("Game timeout for player: " + initPlayerId + ". Conceding.");
|
||||
logger.debug("Game timeout for player: " + initPlayerId + ". Conceding.");
|
||||
}
|
||||
});
|
||||
timers.put(playerId, timer);
|
||||
|
@ -267,7 +267,7 @@ public class GameController implements GameCallback {
|
|||
User user = UserManager.getInstance().getUser(userId);
|
||||
gameSession.setUserData(user.getUserData());
|
||||
user.addGame(playerId, gameSession);
|
||||
logger.info(new StringBuilder("Player ").append(playerId).append(" has joined game ").append(game.getId()).toString());
|
||||
logger.debug(new StringBuilder("Player ").append(playerId).append(" has joined game ").append(game.getId()).toString());
|
||||
ChatManager.getInstance().broadcast(chatId, "", new StringBuilder(game.getPlayer(playerId).getName()).append(" has joined the game").toString(), MessageColor.BLACK);
|
||||
checkStart();
|
||||
}
|
||||
|
@ -694,7 +694,7 @@ public class GameController implements GameCallback {
|
|||
finally {
|
||||
output.close();
|
||||
}
|
||||
logger.info("Saved game:" + game.getId());
|
||||
logger.debug("Saved game:" + game.getId());
|
||||
}
|
||||
catch(IOException ex) {
|
||||
logger.fatal("Cannot save game.", ex);
|
||||
|
|
|
@ -70,7 +70,7 @@ public class GameFactory {
|
|||
logger.fatal("Error creating match - " + gameType, ex);
|
||||
return null;
|
||||
}
|
||||
logger.info("Game created: " + gameType); // + game.getId().toString());
|
||||
logger.debug("Game created: " + gameType); // + game.getId().toString());
|
||||
|
||||
return match;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class PlayerFactory {
|
|||
if (playerTypeClass != null) {
|
||||
con = playerTypeClass.getConstructor(new Class[]{String.class, RangeOfInfluence.class, int.class});
|
||||
player = (Player)con.newInstance(new Object[] {name, range, skill});
|
||||
logger.info("Player created: " + name + "-" + player.getId().toString());
|
||||
logger.debug("Player created: " + name + "-" + player.getId().toString());
|
||||
return player;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -136,7 +136,7 @@ public class TournamentController {
|
|||
for (TournamentPlayer player: tournament.getPlayers()) {
|
||||
if (!player.getPlayer().isHuman()) {
|
||||
player.setJoined();
|
||||
logger.info("player " + player.getPlayer().getId() + " has joined tournament " + tournament.getId());
|
||||
logger.debug("player " + player.getPlayer().getId() + " has joined tournament " + tournament.getId());
|
||||
ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getName() + " has joined the tournament", MessageColor.BLACK);
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public class TournamentController {
|
|||
UserManager.getInstance().getUser(userId).addTournament(playerId, tournamentSession);
|
||||
TournamentPlayer player = tournament.getPlayer(playerId);
|
||||
player.setJoined();
|
||||
logger.info("player " + playerId + " has joined tournament " + tournament.getId());
|
||||
logger.debug("player " + playerId + " has joined tournament " + tournament.getId());
|
||||
ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getName() + " has joined the tournament", MessageColor.BLACK);
|
||||
checkStart();
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ public class TournamentFactory {
|
|||
con = tournaments.get(tournamentType).getConstructor(new Class[]{TournamentOptions.class});
|
||||
tournament = con.newInstance(new Object[] {options});
|
||||
// transfer set information, create short info string for included sets
|
||||
tournament.setTournamentType(tournamentTypes.get(tournamentType));
|
||||
Map<String,Integer> setInfo = new LinkedHashMap<String,Integer>();
|
||||
for (String setCode: options.getLimitedOptions().getSetCodes()) {
|
||||
tournament.getSets().add(Sets.findSet(setCode));
|
||||
|
@ -82,7 +83,7 @@ public class TournamentFactory {
|
|||
logger.fatal("TournamentFactory error ", ex);
|
||||
return null;
|
||||
}
|
||||
logger.info("Tournament created: " + tournamentType); // + game.getId().toString());
|
||||
logger.debug("Tournament created: " + tournamentType); // + game.getId().toString());
|
||||
|
||||
return tournament;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#default levels
|
||||
log4j.rootLogger=info, console, logfile
|
||||
log4j.logger.com.j256.ormlite=warn
|
||||
#log4j.logger.mage.player.ai=TRACE
|
||||
#log4j.logger.mage.player.ai.ComputerPlayer6=debug
|
||||
#log4j.logger.mage.player.ai.ComputerPlayer7=debug
|
||||
|
|
|
@ -77,4 +77,7 @@ public interface Tournament {
|
|||
// tournament times
|
||||
Date getStartTime();
|
||||
Date getEndTime();
|
||||
// tournament type
|
||||
TournamentType getTournamentType();
|
||||
void setTournamentType(TournamentType tournamentType);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ public abstract class TournamentImpl implements Tournament {
|
|||
protected static Random rnd = new Random();
|
||||
protected String matchName;
|
||||
protected TournamentOptions options;
|
||||
protected TournamentType tournamentType;
|
||||
protected List<ExpansionSet> sets = new ArrayList<ExpansionSet>();
|
||||
protected String setsInfoShort;
|
||||
|
||||
|
@ -332,4 +333,14 @@ public abstract class TournamentImpl implements Tournament {
|
|||
return new Date(endTime.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TournamentType getTournamentType() {
|
||||
return tournamentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTournamentType(TournamentType tournamentType) {
|
||||
this.tournamentType = tournamentType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import mage.game.match.MatchOptions;
|
|||
public class TournamentOptions implements Serializable {
|
||||
|
||||
protected String name;
|
||||
protected String tournamentType;
|
||||
protected String tournamentType;;
|
||||
protected List<String> playerTypes = new ArrayList<String>();
|
||||
protected MatchOptions matchOptions = new MatchOptions("", "Two Player Duel");
|
||||
protected LimitedOptions limitedOptions;
|
||||
|
|
|
@ -28,19 +28,32 @@
|
|||
|
||||
package mage.players;
|
||||
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageItem;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.Modes;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.choices.Choice;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.Counters;
|
||||
import mage.game.Game;
|
||||
import mage.game.Table;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.game.match.Match;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -52,9 +65,6 @@ import mage.target.TargetCard;
|
|||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.util.Copyable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -322,4 +332,11 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
void setReachedNextTurnAfterLeaving(boolean reachedNextTurnAfterLeaving);
|
||||
boolean hasReachedNextTurnAfterLeaving();
|
||||
/**
|
||||
* Checks if a AI player is able to join a table
|
||||
* i.e. Draft - bot can not enter a table with constructed format
|
||||
* @param table
|
||||
* @return
|
||||
*/
|
||||
boolean canJoinTable(Table table);
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ import mage.filter.predicate.Predicates;
|
|||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.Table;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.events.DamagePlayerEvent;
|
||||
import mage.game.events.DamagedPlayerEvent;
|
||||
|
@ -2027,5 +2028,9 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
public boolean hasReachedNextTurnAfterLeaving() {
|
||||
return reachedNextTurnAfterLeaving;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canJoinTable(Table table) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue