diff --git a/Mage.Client/config/config.properties b/Mage.Client/config/config.properties index f292f0f5b7..5ea15e1b0c 100644 --- a/Mage.Client/config/config.properties +++ b/Mage.Client/config/config.properties @@ -12,6 +12,6 @@ hand-scaling-factor=1.3 # parameters for debugging and testing faster default-deck-path=C:\\Users\\836D~1\\AppData\\Local\\Temp\\tempDeck1577fd51-f098-420e-8794-c22d2c0602d99142449166006085381.dck -# 0: Human, 1: Computer - default, 2: Computer - minimax, 3: Computer - minimax hybrid -default-other-player-index=3 +# 0: Human, 1: Computer - minimax, 2: Computer - mad, 3: Computer - Monte Carlo +default-other-player-index=2 default-computer-name=computer diff --git a/Mage.Client/config/config.xml b/Mage.Client/config/config.xml new file mode 100644 index 0000000000..3703d1642a --- /dev/null +++ b/Mage.Client/config/config.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mage.Client/config/log4j.properties b/Mage.Client/config/log4j.properties new file mode 100644 index 0000000000..f1f6e4f3db --- /dev/null +++ b/Mage.Client/config/log4j.properties @@ -0,0 +1,14 @@ +#default levels +log4j.rootLogger=debug, console, 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 \ No newline at end of file diff --git a/Mage.Client/config/security.policy b/Mage.Client/config/security.policy new file mode 100644 index 0000000000..dda47ba918 --- /dev/null +++ b/Mage.Client/config/security.policy @@ -0,0 +1,3 @@ +grant { + permission java.security.AllPermission; +}; \ No newline at end of file diff --git a/Mage.Client/plugins/AIMinimax.properties b/Mage.Client/plugins/AIMinimax.properties new file mode 100644 index 0000000000..96b5480294 --- /dev/null +++ b/Mage.Client/plugins/AIMinimax.properties @@ -0,0 +1,7 @@ +maxDepth=10 +maxNodes=5000 +evaluatorLifeFactor=2 +evaluatorPermanentFactor=1 +evaluatorCreatureFactor=1 +evaluatorHandFactor=1 +maxThinkSeconds=30 \ No newline at end of file diff --git a/Mage.Client/plugins/mage-deck-constructed.jar b/Mage.Client/plugins/mage-deck-constructed.jar new file mode 100644 index 0000000000..8ea92082fa Binary files /dev/null and b/Mage.Client/plugins/mage-deck-constructed.jar differ diff --git a/Mage.Client/plugins/mage-deck-limited.jar b/Mage.Client/plugins/mage-deck-limited.jar new file mode 100644 index 0000000000..fd7b0a98b9 Binary files /dev/null and b/Mage.Client/plugins/mage-deck-limited.jar differ diff --git a/Mage.Client/plugins/mage-draft-8playerbooster.jar b/Mage.Client/plugins/mage-draft-8playerbooster.jar new file mode 100644 index 0000000000..ca6baadb66 Binary files /dev/null and b/Mage.Client/plugins/mage-draft-8playerbooster.jar differ diff --git a/Mage.Client/plugins/mage-game-freeforall.jar b/Mage.Client/plugins/mage-game-freeforall.jar new file mode 100644 index 0000000000..a10ff5eeaf Binary files /dev/null and b/Mage.Client/plugins/mage-game-freeforall.jar differ diff --git a/Mage.Client/plugins/mage-game-twoplayerduel.jar b/Mage.Client/plugins/mage-game-twoplayerduel.jar new file mode 100644 index 0000000000..abcc67cc6c Binary files /dev/null and b/Mage.Client/plugins/mage-game-twoplayerduel.jar differ diff --git a/Mage.Client/plugins/mage-player-ai-ma.jar b/Mage.Client/plugins/mage-player-ai-ma.jar new file mode 100644 index 0000000000..083c03e4e5 Binary files /dev/null and b/Mage.Client/plugins/mage-player-ai-ma.jar differ diff --git a/Mage.Client/plugins/mage-player-ai.jar b/Mage.Client/plugins/mage-player-ai.jar new file mode 100644 index 0000000000..43361e204b Binary files /dev/null and b/Mage.Client/plugins/mage-player-ai.jar differ diff --git a/Mage.Client/plugins/mage-player-aimcts.jar b/Mage.Client/plugins/mage-player-aimcts.jar new file mode 100644 index 0000000000..5203fa31e9 Binary files /dev/null and b/Mage.Client/plugins/mage-player-aimcts.jar differ diff --git a/Mage.Client/plugins/mage-player-aiminimax.jar b/Mage.Client/plugins/mage-player-aiminimax.jar new file mode 100644 index 0000000000..a6e82de320 Binary files /dev/null and b/Mage.Client/plugins/mage-player-aiminimax.jar differ diff --git a/Mage.Client/plugins/mage-player-human.jar b/Mage.Client/plugins/mage-player-human.jar new file mode 100644 index 0000000000..e65c01d65d Binary files /dev/null and b/Mage.Client/plugins/mage-player-human.jar differ diff --git a/Mage.Client/plugins/mage-tournament-booster-draft.jar b/Mage.Client/plugins/mage-tournament-booster-draft.jar new file mode 100644 index 0000000000..6729138bfb Binary files /dev/null and b/Mage.Client/plugins/mage-tournament-booster-draft.jar differ diff --git a/Mage.Client/plugins/mage-tournament-sealed.jar b/Mage.Client/plugins/mage-tournament-sealed.jar new file mode 100644 index 0000000000..cec9fec81b Binary files /dev/null and b/Mage.Client/plugins/mage-tournament-sealed.jar differ diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml index d09e4245df..6d24ac3d05 100644 --- a/Mage.Client/pom.xml +++ b/Mage.Client/pom.xml @@ -30,6 +30,12 @@ mage-sets ${project.version} + + + ${project.groupId} + mage-server + ${mage-version} + com.googlecode.jspf jspf-core diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index 12173e1798..a0cfcf465f 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -61,12 +61,13 @@ import mage.client.util.SettingsManager; import mage.client.util.gui.ArrowBuilder; import mage.components.ImagePanel; import mage.game.match.MatchOptions; -import mage.interfaces.MageClient; +import mage.interfaces.*; import mage.interfaces.callback.CallbackClient; import mage.interfaces.callback.ClientCallback; import mage.remote.Connection; import mage.remote.Connection.ProxyType; import mage.remote.Session; +import mage.server.Main; import mage.sets.Sets; import mage.utils.MageVersion; import mage.view.TableView; @@ -180,6 +181,12 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { this.setExtendedState(JFrame.MAXIMIZED_BOTH); session = new Session(this); + session.setEmbeddedMageServerAction(new mage.interfaces.Action() { + @Override + public void execute() { + Main.main(new String[] {}); + } + }); callbackClient = new CallbackClientImpl(this); connectDialog = new ConnectDialog(); desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER); diff --git a/Mage.Common/src/mage/constants/Constants.java b/Mage.Common/src/mage/constants/Constants.java index 8ae7439c03..42eadbe52c 100644 --- a/Mage.Common/src/mage/constants/Constants.java +++ b/Mage.Common/src/mage/constants/Constants.java @@ -71,7 +71,7 @@ public final class Constants { public static final String PLUGINS_DIRECTORY = "plugins/"; public enum SessionState { - DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_UNAVAILABLE; + DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_UNAVAILABLE, SERVER_STARTING; } } diff --git a/Mage.Common/src/mage/interfaces/Action.java b/Mage.Common/src/mage/interfaces/Action.java new file mode 100644 index 0000000000..3ead56d4c2 --- /dev/null +++ b/Mage.Common/src/mage/interfaces/Action.java @@ -0,0 +1,10 @@ +package mage.interfaces; + +/** + * Action interface + * + * @author ayratn + */ +public interface Action { + public void execute(); +} diff --git a/Mage.Common/src/mage/remote/Session.java b/Mage.Common/src/mage/remote/Session.java index b2ad5db8b5..66c2f1d6bb 100644 --- a/Mage.Common/src/mage/remote/Session.java +++ b/Mage.Common/src/mage/remote/Session.java @@ -28,23 +28,13 @@ package mage.remote; -import java.net.Authenticator; -import java.net.ConnectException; -import java.net.MalformedURLException; -import java.net.PasswordAuthentication; -import java.net.SocketException; -import java.net.SocketTimeoutException; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import mage.cards.decks.DeckCardLists; -import mage.game.GameException; import mage.MageException; +import mage.cards.decks.DeckCardLists; import mage.constants.Constants.SessionState; +import mage.game.GameException; import mage.game.match.MatchOptions; import mage.game.tournament.TournamentOptions; +import mage.interfaces.Action; import mage.interfaces.MageClient; import mage.interfaces.MageServer; import mage.interfaces.ServerState; @@ -52,12 +42,7 @@ import mage.interfaces.callback.ClientCallback; import mage.utils.CompressUtil; import mage.view.*; import org.apache.log4j.Logger; -import org.jboss.remoting.CannotConnectException; -import org.jboss.remoting.Client; -import org.jboss.remoting.ConnectionListener; -import org.jboss.remoting.ConnectionValidator; -import org.jboss.remoting.InvokerLocator; -import org.jboss.remoting.Remoting; +import org.jboss.remoting.*; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; @@ -65,6 +50,9 @@ import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.remoting.transport.socket.SocketWrapper; import org.jboss.remoting.transporter.TransporterClient; +import java.net.*; +import java.util.*; + /** * * @author BetaSteward_at_googlemail.com @@ -81,11 +69,18 @@ public class Session { private SessionState sessionState = SessionState.DISCONNECTED; private Connection connection; + private Action embeddedMageServerAction; + private static boolean debugMode = false; - private boolean canceled = false; + private static boolean standalone = true; + + private boolean canceled = false; static { debugMode = System.getProperty("debug.mage") != null; + if (System.getProperty("skip.standalone") != null) { + standalone = false; + } } public Session(MageClient client) { @@ -107,6 +102,11 @@ public class Session { } public boolean connect() { + + if (standalone && connection.getHost().equals("localhost")) { + runEmbeddedMageServer(); + } + sessionState = SessionState.CONNECTING; try { System.setProperty("http.nonProxyHosts", "code.google.com"); @@ -199,7 +199,13 @@ public class Session { } return false; } - + + private void runEmbeddedMageServer() { + if (embeddedMageServerAction != null) { + embeddedMageServerAction.execute(); + } + } + private void handleCannotConnectException(CannotConnectException ex) { logger.warn("Cannot connect", ex); Throwable t = ex.getCause(); @@ -986,6 +992,9 @@ public class Session { return false; } + public void setEmbeddedMageServerAction(Action embeddedMageServerAction) { + this.embeddedMageServerAction = embeddedMageServerAction; + } } class MageAuthenticator extends Authenticator { diff --git a/Mage.Server/src/main/java/mage/server/Main.java b/Mage.Server/src/main/java/mage/server/Main.java index 214d09c636..d20f2820bf 100644 --- a/Mage.Server/src/main/java/mage/server/Main.java +++ b/Mage.Server/src/main/java/mage/server/Main.java @@ -207,8 +207,15 @@ public class Main { @Override public Object invoke(final InvocationRequest invocation) throws Throwable { String sessionId = invocation.getSessionId(); - InetAddress clientAddress = (InetAddress) invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS); - SessionManager.getInstance().getSession(sessionId).setHost(clientAddress.getHostAddress()); + Map map = invocation.getRequestPayload(); + String host; + if (map != null) { + InetAddress clientAddress = (InetAddress) invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS); + host = clientAddress.getHostAddress(); + } else { + host = "localhost"; + } + SessionManager.getInstance().getSession(sessionId).setHost(host); return null; }