From 41d9cb30de1e66034b634b6a4e87d327034c1c5e Mon Sep 17 00:00:00 2001 From: BetaSteward Date: Sun, 21 Mar 2010 03:54:48 +0000 Subject: [PATCH] ... --- Mage.Server/nbproject/project.properties | 4 ++-- Mage.Server/src/mage/server/Main.java | 10 +++++++++- Mage.Server/src/mage/server/ServerImpl.java | 9 +++++++-- Mage.Server/src/mage/server/game/GameController.java | 1 + Mage.Server/src/mage/server/game/GameWorker.java | 1 + 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Mage.Server/nbproject/project.properties b/Mage.Server/nbproject/project.properties index 810bafcdbd..ef909b2002 100644 --- a/Mage.Server/nbproject/project.properties +++ b/Mage.Server/nbproject/project.properties @@ -50,7 +50,7 @@ javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= -jaxbwiz.endorsed.dirs="${netbeans.home}/../ide9/modules/ext/jaxb/api" +jaxbwiz.endorsed.dirs=${netbeans.home}/../ide9/modules/ext/jaxb/api jaxbwiz.gensrc.classpath=${libs.jaxb.classpath} jaxbwiz.xjcdef.classpath=${libs.jaxb.classpath} jaxbwiz.xjcrun.classpath=${libs.jaxb.classpath} @@ -73,7 +73,7 @@ run-sys-prop.java.endorsed.dirs=${jaxbwiz.endorsed.dirs} run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} -run.jvmargs=-server -Djava.security.policy=src/security.policy +run.jvmargs=-server -Djava.security.policy=config/security.policy run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} diff --git a/Mage.Server/src/mage/server/Main.java b/Mage.Server/src/mage/server/Main.java index 0d97793425..8ad7ffac51 100644 --- a/Mage.Server/src/mage/server/Main.java +++ b/Mage.Server/src/mage/server/Main.java @@ -48,6 +48,8 @@ public class Main { private static Logger logger = Logging.getLogger(Main.class.getName()); + private final static String testModeArg = "-testMode="; + /** * @param args the command line arguments */ @@ -61,7 +63,13 @@ public class Main { for (Plugin plugin: config.getPlayerTypes()) { PlayerFactory.getInstance().addPlayerType(plugin.getName(), loadPlugin(plugin)); } - Server server = new ServerImpl(config.getPort(), config.getServerName()); + boolean testMode = false; + for (String arg: args) { + if (arg.startsWith(testModeArg)) { + testMode = Boolean.valueOf(arg.replace(testModeArg, "")); + } + } + Server server = new ServerImpl(config.getPort(), config.getServerName(), testMode); } diff --git a/Mage.Server/src/mage/server/ServerImpl.java b/Mage.Server/src/mage/server/ServerImpl.java index dd25630269..d910148b1a 100644 --- a/Mage.Server/src/mage/server/ServerImpl.java +++ b/Mage.Server/src/mage/server/ServerImpl.java @@ -62,13 +62,17 @@ public class ServerImpl implements Server { private final static Logger logger = Logging.getLogger("Mage Server"); - public ServerImpl(int port, String name) { + private boolean testMode; + + public ServerImpl(int port, String name, boolean testMode) { try { System.setSecurityManager(null); Registry reg = LocateRegistry.createRegistry(port); Server server = (Server) UnicastRemoteObject.exportObject(this, 0); reg.rebind(name, server); + this.testMode = testMode; logger.info("Started MAGE server - listening on port " + port); + logger.info("MAGE server running in test mode"); } catch (RemoteException ex) { logger.log(Level.SEVERE, "Failed to start RMI server at port " + port, ex); } @@ -425,7 +429,8 @@ public class ServerImpl implements Server { @Override public void cheat(UUID gameId, UUID sessionId, DeckCardLists deckList) throws MageException { try { -// GameManager.getInstance().cheat(gameId, sessionId, deckList); + if (testMode) + GameManager.getInstance().cheat(gameId, sessionId, deckList); } catch (Exception ex) { handleException(ex); diff --git a/Mage.Server/src/mage/server/game/GameController.java b/Mage.Server/src/mage/server/game/GameController.java index e36443085f..18c12167bb 100644 --- a/Mage.Server/src/mage/server/game/GameController.java +++ b/Mage.Server/src/mage/server/game/GameController.java @@ -347,6 +347,7 @@ public class GameController implements GameCallback { return new CardsView(cards.values()); } + @Override public void gameResult(String result) { endGame(result); } diff --git a/Mage.Server/src/mage/server/game/GameWorker.java b/Mage.Server/src/mage/server/game/GameWorker.java index 124df4e996..7566ab1dc1 100644 --- a/Mage.Server/src/mage/server/game/GameWorker.java +++ b/Mage.Server/src/mage/server/game/GameWorker.java @@ -57,6 +57,7 @@ public class GameWorker implements Callable { result.gameResult(game.getWinner()); } catch (Exception ex) { logger.log(Level.SEVERE, null, ex); + result.gameResult("Server Error"); } return null; }