mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
changes for public server
This commit is contained in:
parent
1fdc50570f
commit
b81938210a
46 changed files with 218 additions and 281 deletions
|
|
@ -95,7 +95,7 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
private static Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
|
||||
private JLabel title;
|
||||
private Rectangle titleRectangle;
|
||||
private static MageVersion version = new MageVersion(0, 7, 2);
|
||||
private final static MageVersion version = new MageVersion(0, 7, 2);
|
||||
|
||||
/**
|
||||
* @return the session
|
||||
|
|
@ -728,6 +728,10 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
btnDeckEditor.setEnabled(true);
|
||||
}
|
||||
|
||||
public void hideTables() {
|
||||
this.tablesPane.hideTables();
|
||||
}
|
||||
|
||||
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) {
|
||||
try {
|
||||
DeckEditorPane deckEditorPane = new DeckEditorPane();
|
||||
|
|
|
|||
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
//package mage.client.chat;
|
||||
//
|
||||
//import java.io.Serializable;
|
||||
//import java.rmi.RemoteException;
|
||||
//import java.rmi.server.UnicastRemoteObject;
|
||||
//import java.util.UUID;
|
||||
//import java.util.logging.Level;
|
||||
//import java.util.logging.Logger;
|
||||
//import javax.swing.JTextArea;
|
||||
//import mage.interfaces.ChatClient;
|
||||
//import mage.util.Logging;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// * @author BetaSteward_at_googlemail.com
|
||||
// */
|
||||
//public class ChatClientImpl implements ChatClient, Serializable {
|
||||
//
|
||||
// private final static Logger logger = Logging.getLogger(ChatClientImpl.class.getName());
|
||||
//
|
||||
// private JTextArea textArea;
|
||||
// private String userName;
|
||||
// private UUID clientId;
|
||||
//
|
||||
// public ChatClientImpl(String userName, JTextArea textArea) {
|
||||
// this.clientId = UUID.randomUUID();
|
||||
// this.textArea = textArea;
|
||||
// try {
|
||||
// this.userName = userName;
|
||||
// UnicastRemoteObject.exportObject(this, 0);
|
||||
// } catch (RemoteException ex) {
|
||||
// logger.log(Level.SEVERE, null, ex);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void receiveMessage(String message) throws RemoteException {
|
||||
// this.textArea.append(message + "\n");
|
||||
// textArea.setCaretPosition(textArea.getText().length() - 1);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getName() throws RemoteException {
|
||||
// return userName;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public UUID getId() throws RemoteException {
|
||||
// return clientId;
|
||||
// }
|
||||
//
|
||||
// public UUID getIdLocal() {
|
||||
// return clientId;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
@ -59,6 +59,7 @@ public class JoinTableDialog extends MageDialog {
|
|||
/** Creates new form JoinTableDialog */
|
||||
public JoinTableDialog() {
|
||||
initComponents();
|
||||
newPlayerPanel.showLevel(false);
|
||||
}
|
||||
|
||||
public void showDialog(UUID roomId, UUID tableId) {
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ public class NewTableDialog extends MageDialog {
|
|||
/** Creates new form NewTableDialog */
|
||||
public NewTableDialog() {
|
||||
initComponents();
|
||||
player1Panel.showLevel(false);
|
||||
this.spnNumWins.setModel(new SpinnerNumberModel(1, 1, 5, 1));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jSplitPane1" pref="251" max="32767" attributes="0"/>
|
||||
<Component id="jSplitPane1" pref="255" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="btnMoveDown" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
|
|
|
|||
|
|
@ -79,29 +79,33 @@ public class TableWaitingDialog extends MageDialog implements Observer {
|
|||
|
||||
@Override
|
||||
public void update(Observable arg0, Object arg1) {
|
||||
TableView table = session.getTable(roomId, tableId);
|
||||
if (table != null) {
|
||||
switch (table.getTableState()) {
|
||||
case STARTING:
|
||||
this.btnStart.setEnabled(true);
|
||||
this.btnMoveDown.setEnabled(true);
|
||||
this.btnMoveUp.setEnabled(true);
|
||||
break;
|
||||
case WAITING:
|
||||
this.btnStart.setEnabled(false);
|
||||
this.btnMoveDown.setEnabled(false);
|
||||
this.btnMoveUp.setEnabled(false);
|
||||
break;
|
||||
default:
|
||||
closeDialog();
|
||||
return;
|
||||
try {
|
||||
TableView table = session.getTable(roomId, tableId);
|
||||
if (table != null) {
|
||||
switch (table.getTableState()) {
|
||||
case STARTING:
|
||||
this.btnStart.setEnabled(true);
|
||||
this.btnMoveDown.setEnabled(true);
|
||||
this.btnMoveUp.setEnabled(true);
|
||||
break;
|
||||
case WAITING:
|
||||
this.btnStart.setEnabled(false);
|
||||
this.btnMoveDown.setEnabled(false);
|
||||
this.btnMoveUp.setEnabled(false);
|
||||
break;
|
||||
default:
|
||||
closeDialog();
|
||||
return;
|
||||
}
|
||||
int row = this.tableSeats.getSelectedRow();
|
||||
tableWaitModel.loadData(table);
|
||||
this.tableSeats.repaint();
|
||||
this.tableSeats.getSelectionModel().setSelectionInterval(row, row);
|
||||
}
|
||||
int row = this.tableSeats.getSelectedRow();
|
||||
tableWaitModel.loadData(table);
|
||||
this.tableSeats.repaint();
|
||||
this.tableSeats.getSelectionModel().setSelectionInterval(row, row);
|
||||
}
|
||||
else {
|
||||
else {
|
||||
closeDialog();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ public class Session {
|
|||
JOptionPane.showMessageDialog(frame, "Unable to connect to server. " + ex.getMessage());
|
||||
} catch (RemoteException ex) {
|
||||
logger.log(Level.SEVERE, "Unable to connect to server - ", ex);
|
||||
disconnect();
|
||||
JOptionPane.showMessageDialog(frame, "Unable to connect to server. " + ex.getMessage());
|
||||
} catch (NotBoundException ex) {
|
||||
logger.log(Level.SEVERE, "Unable to connect to server - ", ex);
|
||||
}
|
||||
|
|
@ -120,9 +122,15 @@ public class Session {
|
|||
|
||||
if (isConnected()) {
|
||||
try {
|
||||
frame.hideTables();
|
||||
for (UUID chatId: chats.keySet()) {
|
||||
server.leaveChat(chatId, sessionId);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
//swallow all exceptions at this point
|
||||
}
|
||||
try {
|
||||
//TODO: stop daemon
|
||||
server.deregisterClient(sessionId);
|
||||
server = null;
|
||||
|
|
|
|||
|
|
@ -100,6 +100,11 @@ public class NewPlayerPanel extends javax.swing.JPanel {
|
|||
return Integer.valueOf((String)this.cbLevel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void showLevel(boolean show) {
|
||||
this.cbLevel.setVisible(show);
|
||||
this.lblLevel.setVisible(show);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
|
|
|
|||
|
|
@ -112,12 +112,10 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
|
|||
}
|
||||
} else if (state.equals("Watch")) {
|
||||
logger.info("Watching table " + tableId);
|
||||
if (!session.watchTable(roomId, tableId))
|
||||
hideTables();
|
||||
session.watchTable(roomId, tableId);
|
||||
} else if (state.equals("Replay")) {
|
||||
logger.info("Replaying game " + gameId);
|
||||
if (!session.replayGame(gameId))
|
||||
hideTables();
|
||||
session.replayGame(gameId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -146,7 +144,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
|
|||
try {
|
||||
tableModel.loadData(MageFrame.getSession().getTables(roomId));
|
||||
this.tableTables.repaint();
|
||||
} catch (MageRemoteException ex) {
|
||||
} catch (Exception ex) {
|
||||
hideTables();
|
||||
}
|
||||
}
|
||||
|
|
@ -313,7 +311,6 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
|
|||
table = session.createTable(roomId, options);
|
||||
session.joinTable(roomId, table.getTableId(), "Human", "Human", 1, Sets.loadDeck("test.dck"));
|
||||
session.joinTable(roomId, table.getTableId(), "Computer", "Computer - default", 1, Sets.loadDeck("test.dck"));
|
||||
hideTables();
|
||||
session.startGame(roomId, table.getTableId());
|
||||
} catch (Exception ex) {
|
||||
handleError(ex);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@
|
|||
<server serverAddress="localhost" serverName="mage-server" port="17171" maxGameThreads="10" maxSecondsIdle="600"/>
|
||||
<playerTypes>
|
||||
<playerType name="Human" jar="mage-player-human.jar" className="mage.player.human.HumanPlayer"/>
|
||||
<playerType name="Computer - default" jar="mage-player-ai.jar" className="mage.player.ai.ComputerPlayer"/>
|
||||
<playerType name="Computer - minimax" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer2"/>
|
||||
<playerType name="Computer - minimax hybrid" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>
|
||||
<playerType name="Computer - minimax" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>
|
||||
<playerType name="Computer - mad" jar="mage-player-ai-ma.jar" className="mage.player.ai.ComputerPlayer6"/>
|
||||
</playerTypes>
|
||||
<gameTypes>
|
||||
|
|
|
|||
14
Mage.Server/config/log4j.properties
Normal file
14
Mage.Server/config/log4j.properties
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#default levels
|
||||
log4j.rootLogger=debug, logfile
|
||||
|
||||
#console log
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
|
||||
log4j.appender.console.Threshold=info
|
||||
|
||||
#file log
|
||||
log4j.appender.logfile=org.apache.log4j.FileAppender
|
||||
log4j.appender.logfile.File=mageserver.log
|
||||
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.logfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
|
||||
14
Mage.Server/release/config/log4j.properties
Normal file
14
Mage.Server/release/config/log4j.properties
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#default levels
|
||||
log4j.rootLogger=info, logfile
|
||||
|
||||
#console log
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
|
||||
log4j.appender.console.Threshold=info
|
||||
|
||||
#file log
|
||||
log4j.appender.logfile=org.apache.log4j.FileAppender
|
||||
log4j.appender.logfile.File=mageserver.log
|
||||
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.logfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
|
||||
|
|
@ -1,8 +1,3 @@
|
|||
@ECHO OFF
|
||||
IF NOT EXIST "C:\Program Files\Java\jre6" GOTO NOJAVADIR
|
||||
set JAVA_HOME="C:\Program Files\Java\jre6"
|
||||
set CLASSPATH=%JAVA_HOME%/bin;%CLASSPATH%
|
||||
set PATH=%JAVA_HOME%/bin;%PATH%
|
||||
:NOJAVADIR
|
||||
java -Djava.security.policy=./config/security.policy -Djava.util.logging.config.file=./config/logging.config -jar ./Mage-Server-${project.version}.jar
|
||||
java -Djava.security.policy=./config/security.policy -Djava.util.logging.config.file=./config/logging.config -Dlog4j.configuration=file:./config/log4j.properties -jar ./Mage-Server-${project.version}.jar
|
||||
pause
|
||||
1
Mage.Server/release/startServer.sh
Normal file
1
Mage.Server/release/startServer.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
java -Djava.security.policy=./config/security.policy -Djava.util.logging.config.file=./config/logging.config -Dlog4j.configuration=file:./config/log4j.properties -jar ./Mage-Server-${project.version}.jar
|
||||
|
|
@ -34,11 +34,10 @@ import java.util.Calendar;
|
|||
import java.util.GregorianCalendar;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.util.Logging;
|
||||
import mage.view.ChatMessage;
|
||||
import mage.view.ChatMessage.MessageColor;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -46,7 +45,7 @@ import mage.view.ChatMessage.MessageColor;
|
|||
*/
|
||||
public class ChatSession {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(ChatSession.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(ChatSession.class);
|
||||
private ConcurrentHashMap<UUID, String> clients = new ConcurrentHashMap<UUID, String>();
|
||||
private UUID chatId;
|
||||
private DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import mage.server.util.config.GamePlugin;
|
|||
import mage.util.Copier;
|
||||
import mage.utils.MageVersion;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -67,7 +68,7 @@ public class Main {
|
|||
public static void main(String[] args) {
|
||||
|
||||
logger.info("Starting MAGE server version " + version);
|
||||
logger.info("Logging level: " + logger.getLevel());
|
||||
logger.info("Logging level: " + logger.getEffectiveLevel());
|
||||
deleteSavedGames();
|
||||
ConfigSettings config = ConfigSettings.getInstance();
|
||||
for (GamePlugin plugin: config.getGameTypes()) {
|
||||
|
|
@ -107,6 +108,7 @@ public class Main {
|
|||
ip = ipParam;
|
||||
}
|
||||
System.setProperty("java.rmi.server.hostname", ip);
|
||||
System.setProperty("sun.rmi.transport.tcp.readTimeout", "30000");
|
||||
logger.info("MAGE server - using address " + ip);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,13 +30,12 @@ package mage.server;
|
|||
|
||||
import java.util.logging.Level;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.interfaces.callback.CallbackServerSession;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.server.game.GameManager;
|
||||
import mage.util.Logging;
|
||||
import mage.view.TableClientMessage;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -44,7 +43,7 @@ import mage.view.TableClientMessage;
|
|||
*/
|
||||
public class Session {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(Session.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(Session.class);
|
||||
|
||||
private UUID sessionId;
|
||||
private UUID clientId;
|
||||
|
|
@ -63,6 +62,10 @@ public class Session {
|
|||
return sessionId;
|
||||
}
|
||||
|
||||
public UUID getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
SessionManager.getInstance().removeSession(sessionId);
|
||||
TableManager.getInstance().removeSession(sessionId);
|
||||
|
|
@ -74,19 +77,19 @@ public class Session {
|
|||
try {
|
||||
return callback.callback();
|
||||
} catch (InterruptedException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("Session callback error", ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized void fireCallback(final ClientCallback call) {
|
||||
call.setMessageId(messageId++);
|
||||
if (logger.isLoggable(Level.FINE))
|
||||
logger.fine(sessionId + " - " + call.getMessageId() + " - " + call.getMethod());
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug(sessionId + " - " + call.getMessageId() + " - " + call.getMethod());
|
||||
try {
|
||||
callback.setCallback(call);
|
||||
} catch (InterruptedException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("Session fireCallback error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ package mage.server;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import mage.interfaces.MageException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -38,6 +39,7 @@ import mage.interfaces.MageException;
|
|||
*/
|
||||
public class SessionManager {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(SessionManager.class);
|
||||
private final static SessionManager INSTANCE = new SessionManager();
|
||||
|
||||
public static SessionManager getInstance() {
|
||||
|
|
@ -51,24 +53,24 @@ public class SessionManager {
|
|||
}
|
||||
|
||||
public UUID createSession(String userName, UUID clientId) throws MageException {
|
||||
if (!isNameUsed(userName)) {
|
||||
Session session = new Session(userName, clientId);
|
||||
sessions.put(session.getId(), session);
|
||||
return session.getId();
|
||||
for (Session session: sessions.values()) {
|
||||
if (session.getUsername().equals(userName)) {
|
||||
if (session.getClientId().equals(clientId)) {
|
||||
logger.info("reconnecting session for " + userName);
|
||||
return session.getId();
|
||||
}
|
||||
else {
|
||||
throw new MageException("User name already in use");
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new MageException("User name already in use");
|
||||
Session session = new Session(userName, clientId);
|
||||
sessions.put(session.getId(), session);
|
||||
return session.getId();
|
||||
}
|
||||
|
||||
public void removeSession(UUID sessionId) {
|
||||
sessions.remove(sessionId);
|
||||
}
|
||||
|
||||
private boolean isNameUsed(String name) {
|
||||
for (Session session: sessions.values()) {
|
||||
if (session.getUsername().equals(name))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import mage.game.Table;
|
|||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.game.GameException;
|
||||
|
|
@ -41,8 +40,7 @@ import mage.game.match.Match;
|
|||
import mage.game.match.MatchOptions;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
import mage.players.Player;
|
||||
import mage.server.game.GameReplay;
|
||||
import mage.util.Logging;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -51,7 +49,7 @@ import mage.util.Logging;
|
|||
public class TableManager {
|
||||
|
||||
private final static TableManager INSTANCE = new TableManager();
|
||||
private final static Logger logger = Logging.getLogger(TableManager.class.getName());
|
||||
//private final static Logger logger = Logger.getLogger(TableManager.class);
|
||||
|
||||
private ConcurrentHashMap<UUID, TableController> controllers = new ConcurrentHashMap<UUID, TableController>();
|
||||
private ConcurrentHashMap<UUID, Table> tables = new ConcurrentHashMap<UUID, Table>();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import java.io.File;
|
|||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import mage.game.draft.Draft;
|
||||
import mage.game.draft.DraftPlayer;
|
||||
|
|
@ -42,9 +41,9 @@ import mage.game.events.TableEvent;
|
|||
import mage.server.game.GameController;
|
||||
import mage.server.TableManager;
|
||||
import mage.server.util.ThreadExecutor;
|
||||
import mage.util.Logging;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.DraftView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -52,7 +51,7 @@ import mage.view.DraftView;
|
|||
*/
|
||||
public class DraftController {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(GameController.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(GameController.class);
|
||||
public static final String INIT_FILE_PATH = "config" + File.separator + "init.txt";
|
||||
|
||||
private ConcurrentHashMap<UUID, DraftSession> draftSessions = new ConcurrentHashMap<UUID, DraftSession>();
|
||||
|
|
@ -122,7 +121,7 @@ public class DraftController {
|
|||
private synchronized void startDraft() {
|
||||
for (final Entry<UUID, DraftSession> entry: draftSessions.entrySet()) {
|
||||
if (!entry.getValue().init(getDraftView())) {
|
||||
logger.severe("Unable to initialize client");
|
||||
logger.fatal("Unable to initialize client");
|
||||
//TODO: generate client error message
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,17 +33,15 @@ import java.util.UUID;
|
|||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.server.Session;
|
||||
import mage.server.SessionManager;
|
||||
import mage.server.util.ThreadExecutor;
|
||||
import mage.util.Logging;
|
||||
import mage.view.DraftClientMessage;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.DraftView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -51,7 +49,7 @@ import mage.view.DraftView;
|
|||
*/
|
||||
public class DraftSession {
|
||||
|
||||
protected final static Logger logger = Logging.getLogger(DraftSession.class.getName());
|
||||
protected final static Logger logger = Logger.getLogger(DraftSession.class);
|
||||
|
||||
protected UUID sessionId;
|
||||
protected UUID playerId;
|
||||
|
|
@ -143,7 +141,7 @@ public class DraftSession {
|
|||
}
|
||||
|
||||
protected void handleRemoteException(RemoteException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("DraftSession error ", ex);
|
||||
DraftManager.getInstance().kill(draft.getId(), sessionId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,8 @@ import java.lang.reflect.Constructor;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import mage.cards.decks.*;
|
||||
import java.util.logging.Logger;
|
||||
import mage.Constants;
|
||||
import mage.util.Logging;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -45,7 +42,7 @@ import mage.util.Logging;
|
|||
public class DeckValidatorFactory {
|
||||
|
||||
private final static DeckValidatorFactory INSTANCE = new DeckValidatorFactory();
|
||||
private final static Logger logger = Logging.getLogger(DeckValidatorFactory.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(DeckValidatorFactory.class);
|
||||
|
||||
private Map<String, Class> deckTypes = new HashMap<String, Class>();
|
||||
|
||||
|
|
@ -63,7 +60,7 @@ public class DeckValidatorFactory {
|
|||
con = deckTypes.get(deckType).getConstructor(new Class[]{});
|
||||
validator = (DeckValidator)con.newInstance(new Object[] {});
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("DeckValidatorFactory error", ex);
|
||||
return null;
|
||||
}
|
||||
logger.info("Deck validator created: " + validator.getName());
|
||||
|
|
|
|||
|
|
@ -33,13 +33,11 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.game.match.Match;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.util.Logging;
|
||||
import mage.game.match.MatchType;
|
||||
import mage.view.GameTypeView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -48,7 +46,7 @@ import mage.view.GameTypeView;
|
|||
public class GameFactory {
|
||||
|
||||
private final static GameFactory INSTANCE = new GameFactory();
|
||||
private final static Logger logger = Logging.getLogger(GameFactory.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(GameFactory.class);
|
||||
|
||||
private Map<String, Class<Match>> games = new HashMap<String, Class<Match>>();
|
||||
private Map<String, MatchType> gameTypes = new HashMap<String, MatchType>();
|
||||
|
|
@ -69,7 +67,7 @@ public class GameFactory {
|
|||
con = games.get(gameType).getConstructor(new Class[]{MatchOptions.class});
|
||||
match = con.newInstance(new Object[] {options});
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("Error creating match - " + gameType, ex);
|
||||
return null;
|
||||
}
|
||||
logger.info("Game created: " + gameType); // + game.getId().toString());
|
||||
|
|
|
|||
|
|
@ -64,7 +64,9 @@ public class GameManager {
|
|||
}
|
||||
|
||||
public UUID getChatId(UUID gameId) {
|
||||
return gameControllers.get(gameId).getChatId();
|
||||
if (gameControllers.containsKey(gameId))
|
||||
return gameControllers.get(gameId).getChatId();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void sendPlayerUUID(UUID gameId, UUID sessionId, UUID data) {
|
||||
|
|
|
|||
|
|
@ -30,14 +30,12 @@ package mage.server.game;
|
|||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.server.Session;
|
||||
import mage.server.SessionManager;
|
||||
import mage.util.Logging;
|
||||
import mage.view.GameClientMessage;
|
||||
import mage.view.GameView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -45,7 +43,7 @@ import mage.view.GameView;
|
|||
*/
|
||||
public class GameWatcher {
|
||||
|
||||
protected final static Logger logger = Logging.getLogger(GameWatcher.class.getName());
|
||||
protected final static Logger logger = Logger.getLogger(GameWatcher.class);
|
||||
|
||||
protected UUID sessionId;
|
||||
protected UUID gameId;
|
||||
|
|
@ -102,7 +100,7 @@ public class GameWatcher {
|
|||
}
|
||||
|
||||
protected void handleRemoteException(RemoteException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("GameWatcher error", ex);
|
||||
GameManager.getInstance().kill(gameId, sessionId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,10 +30,8 @@ package mage.server.game;
|
|||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.game.Game;
|
||||
import mage.util.Logging;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -41,7 +39,7 @@ import mage.util.Logging;
|
|||
*/
|
||||
public class GameWorker implements Callable {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(GameWorker.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(GameWorker.class);
|
||||
|
||||
private GameCallback result;
|
||||
private Game game;
|
||||
|
|
@ -59,7 +57,7 @@ public class GameWorker implements Callable {
|
|||
game.start(choosingPlayerId);
|
||||
result.gameResult(game.getWinner());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("GameWorker error ", ex);
|
||||
result.gameResult("Server Error");
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -36,14 +36,12 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.game.GameException;
|
||||
import mage.game.draft.DraftOptions;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
import mage.util.Logging;
|
||||
import mage.view.TableView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -51,7 +49,7 @@ import mage.view.TableView;
|
|||
*/
|
||||
public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(GamesRoomImpl.class.getName());
|
||||
// private final static Logger logger = Logger.getLogger(GamesRoomImpl.class);
|
||||
|
||||
private ConcurrentHashMap<UUID, Table> tables = new ConcurrentHashMap<UUID, Table>();
|
||||
|
||||
|
|
@ -98,7 +96,9 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
|
||||
@Override
|
||||
public TableView getTable(UUID tableId) {
|
||||
return new TableView(tables.get(tableId));
|
||||
if (tables.containsKey(tableId))
|
||||
return new TableView(tables.get(tableId));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ package mage.server.game;
|
|||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
import mage.util.Logging;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -40,7 +39,7 @@ import mage.util.Logging;
|
|||
public class GamesRoomManager {
|
||||
|
||||
private final static GamesRoomManager INSTANCE = new GamesRoomManager();
|
||||
private final static Logger logger = Logging.getLogger(GamesRoomManager.class.getName());
|
||||
// private final static Logger logger = Logger.getLogger(GamesRoomManager.class);
|
||||
|
||||
private ConcurrentHashMap<UUID, GamesRoom> rooms = new ConcurrentHashMap<UUID, GamesRoom>();
|
||||
private UUID mainRoomId;
|
||||
|
|
|
|||
|
|
@ -29,16 +29,12 @@
|
|||
package mage.server.game;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.Constants.RangeOfInfluence;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.players.Player;
|
||||
import mage.util.Logging;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -47,7 +43,7 @@ import mage.util.Logging;
|
|||
public class PlayerFactory {
|
||||
|
||||
private final static PlayerFactory INSTANCE = new PlayerFactory();
|
||||
private final static Logger logger = Logging.getLogger(PlayerFactory.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(PlayerFactory.class);
|
||||
|
||||
private Map<String, Class> playerTypes = new LinkedHashMap<String, Class>();
|
||||
|
||||
|
|
@ -64,7 +60,7 @@ public class PlayerFactory {
|
|||
con = playerTypes.get(playerType).getConstructor(new Class[]{String.class, RangeOfInfluence.class});
|
||||
player = (Player)con.newInstance(new Object[] {name, range});
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("PlayerFactory error ", ex);
|
||||
return null;
|
||||
}
|
||||
logger.info("Player created: " + name + "-" + player.getId().toString());
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@ package mage.server.tournament;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.GameException;
|
||||
import mage.game.Table;
|
||||
|
|
@ -47,9 +45,9 @@ import mage.game.tournament.TournamentPlayer;
|
|||
import mage.server.ChatManager;
|
||||
import mage.server.TableManager;
|
||||
import mage.server.util.ThreadExecutor;
|
||||
import mage.util.Logging;
|
||||
import mage.view.ChatMessage.MessageColor;
|
||||
import mage.view.TournamentView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -57,7 +55,7 @@ import mage.view.TournamentView;
|
|||
*/
|
||||
public class TournamentController {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(TournamentController.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(TournamentController.class);
|
||||
|
||||
private UUID sessionId;
|
||||
private UUID chatId;
|
||||
|
|
@ -83,7 +81,7 @@ public class TournamentController {
|
|||
switch (event.getEventType()) {
|
||||
case INFO:
|
||||
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK);
|
||||
logger.finest(tournament.getId() + " " + event.getMessage());
|
||||
logger.debug(tournament.getId() + " " + event.getMessage());
|
||||
break;
|
||||
case START_DRAFT:
|
||||
startDraft(event.getDraft());
|
||||
|
|
@ -160,7 +158,7 @@ public class TournamentController {
|
|||
private synchronized void startTournament() {
|
||||
for (final Entry<UUID, TournamentSession> entry: tournamentSessions.entrySet()) {
|
||||
if (!entry.getValue().init(getTournamentView())) {
|
||||
logger.severe("Unable to initialize client");
|
||||
logger.fatal("Unable to initialize client");
|
||||
//TODO: generate client error message
|
||||
return;
|
||||
}
|
||||
|
|
@ -179,7 +177,7 @@ public class TournamentController {
|
|||
tableManager.startMatch(null, table.getId());
|
||||
pair.setMatch(tableManager.getMatch(table.getId()));
|
||||
} catch (GameException ex) {
|
||||
Logger.getLogger(TournamentController.class.getName()).log(Level.SEVERE, null, ex);
|
||||
logger.fatal("TournamentController startMatch error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,13 +33,11 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.game.tournament.Tournament;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
import mage.game.tournament.TournamentType;
|
||||
import mage.util.Logging;
|
||||
import mage.view.TournamentTypeView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -47,7 +45,7 @@ import mage.view.TournamentTypeView;
|
|||
*/
|
||||
public class TournamentFactory {
|
||||
private final static TournamentFactory INSTANCE = new TournamentFactory();
|
||||
private final static Logger logger = Logging.getLogger(TournamentFactory.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(TournamentFactory.class);
|
||||
|
||||
private Map<String, Class<Tournament>> tournaments = new HashMap<String, Class<Tournament>>();
|
||||
private Map<String, TournamentType> tournamentTypes = new HashMap<String, TournamentType>();
|
||||
|
|
@ -67,7 +65,7 @@ public class TournamentFactory {
|
|||
con = tournaments.get(tournamentType).getConstructor(new Class[]{TournamentOptions.class});
|
||||
tournament = con.newInstance(new Object[] {options});
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("TournamentFactory error ", ex);
|
||||
return null;
|
||||
}
|
||||
logger.info("Tournament created: " + tournamentType); // + game.getId().toString());
|
||||
|
|
|
|||
|
|
@ -33,23 +33,21 @@ import java.util.UUID;
|
|||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.tournament.Tournament;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.server.Session;
|
||||
import mage.server.SessionManager;
|
||||
import mage.server.util.ThreadExecutor;
|
||||
import mage.util.Logging;
|
||||
import mage.view.TournamentView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TournamentSession {
|
||||
protected final static Logger logger = Logging.getLogger(TournamentSession.class.getName());
|
||||
protected final static Logger logger = Logger.getLogger(TournamentSession.class);
|
||||
|
||||
protected UUID sessionId;
|
||||
protected UUID playerId;
|
||||
|
|
@ -119,7 +117,7 @@ public class TournamentSession {
|
|||
}
|
||||
|
||||
protected void handleRemoteException(RemoteException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("TournamentSession error ", ex);
|
||||
TournamentManager.getInstance().kill(tournament.getId(), sessionId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ package mage.server.util;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.util.Logging;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -40,14 +38,14 @@ import mage.util.Logging;
|
|||
*/
|
||||
public class Config {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(Config.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(Config.class);
|
||||
|
||||
static {
|
||||
Properties p = new Properties();
|
||||
try {
|
||||
p.load(Config.class.getResourceAsStream("resources/config.properties"));
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("Config error", ex);
|
||||
}
|
||||
port = Integer.parseInt(p.getProperty("port"));
|
||||
remoteServer = p.getProperty("remote-server");
|
||||
|
|
|
|||
|
|
@ -30,22 +30,21 @@ package mage.server.util;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import mage.server.util.config.Config;
|
||||
import mage.server.util.config.Plugin;
|
||||
import mage.server.util.config.GamePlugin;
|
||||
import mage.util.Logging;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ConfigSettings {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(ConfigSettings.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(ConfigSettings.class);
|
||||
private final static ConfigSettings INSTANCE = new ConfigSettings();
|
||||
|
||||
private Config config;
|
||||
|
|
@ -60,7 +59,7 @@ public class ConfigSettings {
|
|||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||
config = (Config) unmarshaller.unmarshal(new File("config/config.xml"));
|
||||
} catch (JAXBException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
logger.fatal("ConfigSettings error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@
|
|||
<artifactId>Mage</artifactId>
|
||||
<version>${mage-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.14</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -32,10 +32,7 @@ import java.io.File;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import mage.Constants.CardType;
|
||||
|
|
@ -46,7 +43,7 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.util.Logging;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -54,7 +51,7 @@ import mage.util.Logging;
|
|||
*/
|
||||
public class Sets extends HashMap<String, ExpansionSet> {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(Sets.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(Sets.class);
|
||||
private static final Sets fINSTANCE = new Sets();
|
||||
private static Set<String> names;
|
||||
private static List<Card> cards;
|
||||
|
|
@ -222,7 +219,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
Constructor<?> con = clazz.getConstructor(new Class[]{UUID.class});
|
||||
return (Card) con.newInstance(new Object[] {null});
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Error creating card:" + clazz.getName(), ex);
|
||||
logger.fatal("Error creating card:" + clazz.getName(), ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,14 @@
|
|||
<packaging>jar</packaging>
|
||||
<name>Mage Framework</name>
|
||||
|
||||
<dependencies />
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.14</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ package mage.abilities;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
import mage.Constants.AbilityType;
|
||||
import mage.Constants.EffectType;
|
||||
import mage.Constants.Outcome;
|
||||
|
|
@ -52,7 +51,7 @@ import mage.choices.Choices;
|
|||
import mage.game.Game;
|
||||
import mage.target.Target;
|
||||
import mage.target.Targets;
|
||||
import mage.util.Logging;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -60,7 +59,7 @@ import mage.util.Logging;
|
|||
*/
|
||||
public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||
|
||||
private final static transient Logger logger = Logging.getLogger(AbilityImpl.class.getName());
|
||||
private final static transient Logger logger = Logger.getLogger(AbilityImpl.class);
|
||||
|
||||
protected UUID id;
|
||||
protected UUID originalId;
|
||||
|
|
@ -153,12 +152,12 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
public boolean activate(Game game, boolean noMana) {
|
||||
//20100716 - 601.2b
|
||||
if (choices.size() > 0 && choices.choose(game, this) == false) {
|
||||
logger.fine("activate failed - choice");
|
||||
logger.debug("activate failed - choice");
|
||||
return false;
|
||||
}
|
||||
//20100716 - 601.2b
|
||||
if (targets.size() > 0 && targets.chooseTargets(effects.get(0).getOutcome(), this.controllerId, this, game) == false) {
|
||||
logger.fine("activate failed - target");
|
||||
logger.debug("activate failed - target");
|
||||
return false;
|
||||
}
|
||||
//20100716 - 601.2e
|
||||
|
|
@ -170,13 +169,13 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
|
||||
//20100716 - 601.2f
|
||||
if (!manaCostsToPay.pay(game, sourceId, controllerId, noMana)) {
|
||||
logger.fine("activate failed - mana");
|
||||
logger.debug("activate failed - mana");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//20100716 - 601.2g
|
||||
if (!costs.pay(game, sourceId, controllerId, noMana)) {
|
||||
logger.fine("activate failed - non mana costs");
|
||||
logger.debug("activate failed - non mana costs");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
|
|
@ -50,12 +48,12 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.util.Logging;
|
||||
import mage.watchers.Watchers;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T> implements Card {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(CardImpl.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(CardImpl.class);
|
||||
|
||||
protected UUID ownerId;
|
||||
protected int cardNumber;
|
||||
|
|
@ -109,7 +107,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
return card;
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.log(Level.SEVERE, "Error loading card: " + name, e);
|
||||
logger.fatal("Error loading card: " + name, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ package mage.cards;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.SetType;
|
||||
import mage.util.Logging;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
|
@ -44,15 +43,14 @@ import java.net.URLDecoder;
|
|||
import java.util.*;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarInputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public abstract class ExpansionSet implements Serializable {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(ExpansionSet.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(ExpansionSet.class);
|
||||
|
||||
protected static Random rnd = new Random();
|
||||
|
||||
|
|
@ -112,8 +110,7 @@ public abstract class ExpansionSet implements Serializable {
|
|||
Constructor<?> con = clazz.getConstructor(new Class[]{UUID.class});
|
||||
return (Card) con.newInstance(new Object[]{null});
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Error creating card:" + clazz.getName(), ex);
|
||||
ex.printStackTrace();
|
||||
logger.fatal("Error creating card:" + clazz.getName(), ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -165,7 +162,7 @@ public abstract class ExpansionSet implements Serializable {
|
|||
try {
|
||||
resources = classLoader.getResources(path);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.fatal("Error loading resource - " + path, e);
|
||||
}
|
||||
List<File> dirs = new ArrayList<File>();
|
||||
boolean isLoadingFromJar = false;
|
||||
|
|
@ -180,8 +177,7 @@ public abstract class ExpansionSet implements Serializable {
|
|||
try {
|
||||
dirs.add(new File(URLDecoder.decode(resource.getFile(), "UTF-8")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.log(Level.SEVERE, "Error decoding director - " + resource.getFile(), e);
|
||||
e.printStackTrace();
|
||||
logger.fatal("Error decoding director - " + resource.getFile(), e);
|
||||
}
|
||||
}
|
||||
List<Class> classes = new ArrayList<Class>();
|
||||
|
|
@ -193,21 +189,20 @@ public abstract class ExpansionSet implements Serializable {
|
|||
try {
|
||||
jarPath = URLDecoder.decode(jarPath.substring(jarPath.indexOf("file:/") + "file:/".length()), "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.log(Level.SEVERE, "Error decoding file - " + jarPath, e);
|
||||
e.printStackTrace();
|
||||
logger.fatal("Error decoding file - " + jarPath, e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
classes.addAll(findClassesInJar(new File(jarPath), path));
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
logger.fatal("Error loading classes - " + jarPath, e);
|
||||
}
|
||||
} else { // faster but doesn't work for jars
|
||||
for (File directory : dirs) {
|
||||
try {
|
||||
classes.addAll(findClasses(directory, packageName));
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
logger.fatal("Error loading classes - " + jarPath, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -270,10 +265,9 @@ public abstract class ExpansionSet implements Serializable {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.fatal("Error loading classes - " + file, e);
|
||||
}
|
||||
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,18 +57,17 @@ import mage.players.Player;
|
|||
import mage.players.PlayerList;
|
||||
import mage.players.Players;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.util.Logging;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import mage.game.permanent.PermanentImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializable {
|
||||
|
||||
private final static transient Logger logger = Logging.getLogger(GameImpl.class.getName());
|
||||
private final static transient Logger logger = Logger.getLogger(GameImpl.class);
|
||||
|
||||
private static FilterPlaneswalkerPermanent filterPlaneswalker = new FilterPlaneswalkerPermanent();
|
||||
private static FilterLegendaryPermanent filterLegendary = new FilterLegendaryPermanent();
|
||||
|
|
@ -285,7 +284,8 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
public void bookmarkState() {
|
||||
if (!simulation) {
|
||||
saveState();
|
||||
logger.fine("Bookmarking state: " + gameStates.getSize());
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Bookmarking state: " + gameStates.getSize());
|
||||
savedStates.push(gameStates.getSize() - 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -317,10 +317,8 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
PlayerList players = state.getPlayerList(startingPlayerId);
|
||||
Player player = getPlayer(players.get());
|
||||
while (!isGameOver()) {
|
||||
//if (player.getId().equals(startingPlayerId)) {
|
||||
state.setTurnNum(state.getTurnNum() + 1);
|
||||
fireInformEvent("Turn " + Integer.toString(state.getTurnNum()));
|
||||
//}
|
||||
state.setTurnNum(state.getTurnNum() + 1);
|
||||
fireInformEvent("Turn " + Integer.toString(state.getTurnNum()));
|
||||
if (checkStopOnTurnOption(options)) return;
|
||||
state.setActivePlayerId(player.getId());
|
||||
state.getTurn().play(this, player.getId());
|
||||
|
|
@ -1021,7 +1019,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
player.setLife(amount, this);
|
||||
logger.info("Setting player's life: ");
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
logger.fatal("error setting life", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,8 @@ package mage.game;
|
|||
import java.io.Serializable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
import mage.util.Copier;
|
||||
import mage.util.Logging;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -41,7 +40,7 @@ import mage.util.Logging;
|
|||
*/
|
||||
public class GameStates implements Serializable {
|
||||
|
||||
private final static transient Logger logger = Logging.getLogger(GameStates.class.getName());
|
||||
private final static transient Logger logger = Logger.getLogger(GameStates.class);
|
||||
|
||||
// private List<byte[]> states = new LinkedList<byte[]>();
|
||||
private List<GameState> states = new LinkedList<GameState>();
|
||||
|
|
@ -49,7 +48,7 @@ public class GameStates implements Serializable {
|
|||
public void save(GameState gameState) {
|
||||
// states.add(new Copier<GameState>().copyCompressed(gameState));
|
||||
states.add(gameState.copy());
|
||||
logger.fine("Saved game state: " + states.size());
|
||||
logger.debug("Saved game state: " + states.size());
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
|
|
@ -62,7 +61,7 @@ public class GameStates implements Serializable {
|
|||
states.remove(states.size() - 1);
|
||||
}
|
||||
// return new Copier<GameState>().uncompressCopy(states.get(index));
|
||||
logger.fine("Rolling back state: " + index);
|
||||
logger.debug("Rolling back state: " + index);
|
||||
return states.get(index);
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
package mage.game;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.logging.Logger;
|
||||
import mage.players.Player;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -38,7 +38,7 @@ import mage.players.Player;
|
|||
*/
|
||||
public class Seat implements Serializable {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(Seat.class.getName());
|
||||
// private final static Logger logger = Logger.getLogger(Seat.class);
|
||||
|
||||
private String playerType;
|
||||
private Player player;
|
||||
|
|
|
|||
|
|
@ -157,8 +157,12 @@ public class Table implements Serializable {
|
|||
|
||||
public void leaveTable(UUID playerId) {
|
||||
for (int i = 0; i < numSeats; i++ ) {
|
||||
if (seats[i].getPlayer().getId().equals(playerId))
|
||||
if (seats[i].getPlayer().getId().equals(playerId)) {
|
||||
seats[i].setPlayer(null);
|
||||
if (state == TableState.STARTING)
|
||||
state = TableState.WAITING;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import mage.game.events.TableEvent;
|
|||
import mage.game.events.TableEvent.EventType;
|
||||
import mage.game.events.TableEventSource;
|
||||
import mage.players.Player;
|
||||
import mage.util.Logging;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -48,7 +47,7 @@ import mage.util.Logging;
|
|||
*/
|
||||
public abstract class MatchImpl implements Match {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(MatchImpl.class.getName());
|
||||
// private final static Logger logger = Logging.getLogger(MatchImpl.class.getName());
|
||||
private static final int SIDEBOARD_TIME = 180;
|
||||
|
||||
protected UUID id = UUID.randomUUID();
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@ import java.util.Map;
|
|||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.decks.Deck;
|
||||
|
|
@ -49,6 +47,7 @@ import mage.game.events.TableEvent.EventType;
|
|||
import mage.game.events.TableEventSource;
|
||||
import mage.game.match.Match;
|
||||
import mage.players.Player;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -145,7 +144,7 @@ public abstract class TournamentImpl implements Tournament {
|
|||
//TODO: improve this
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(TournamentImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(TournamentImpl.class).warn("TournamentImpl playRound error ", ex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue