This commit is contained in:
BetaSteward 2010-03-21 03:54:48 +00:00
parent 2aaa8312f4
commit 41d9cb30de
5 changed files with 20 additions and 5 deletions

View file

@ -50,7 +50,7 @@ javadoc.splitindex=true
javadoc.use=true javadoc.use=true
javadoc.version=false javadoc.version=false
javadoc.windowtitle= 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.gensrc.classpath=${libs.jaxb.classpath}
jaxbwiz.xjcdef.classpath=${libs.jaxb.classpath} jaxbwiz.xjcdef.classpath=${libs.jaxb.classpath}
jaxbwiz.xjcrun.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=\ run.classpath=\
${javac.classpath}:\ ${javac.classpath}:\
${build.classes.dir} ${build.classes.dir}
run.jvmargs=-server -Djava.security.policy=src/security.policy run.jvmargs=-server -Djava.security.policy=config/security.policy
run.test.classpath=\ run.test.classpath=\
${javac.test.classpath}:\ ${javac.test.classpath}:\
${build.test.classes.dir} ${build.test.classes.dir}

View file

@ -48,6 +48,8 @@ public class Main {
private static Logger logger = Logging.getLogger(Main.class.getName()); private static Logger logger = Logging.getLogger(Main.class.getName());
private final static String testModeArg = "-testMode=";
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
@ -61,7 +63,13 @@ public class Main {
for (Plugin plugin: config.getPlayerTypes()) { for (Plugin plugin: config.getPlayerTypes()) {
PlayerFactory.getInstance().addPlayerType(plugin.getName(), loadPlugin(plugin)); 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);
} }

View file

@ -62,13 +62,17 @@ public class ServerImpl implements Server {
private final static Logger logger = Logging.getLogger("Mage 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 { try {
System.setSecurityManager(null); System.setSecurityManager(null);
Registry reg = LocateRegistry.createRegistry(port); Registry reg = LocateRegistry.createRegistry(port);
Server server = (Server) UnicastRemoteObject.exportObject(this, 0); Server server = (Server) UnicastRemoteObject.exportObject(this, 0);
reg.rebind(name, server); reg.rebind(name, server);
this.testMode = testMode;
logger.info("Started MAGE server - listening on port " + port); logger.info("Started MAGE server - listening on port " + port);
logger.info("MAGE server running in test mode");
} catch (RemoteException ex) { } catch (RemoteException ex) {
logger.log(Level.SEVERE, "Failed to start RMI server at port " + port, ex); logger.log(Level.SEVERE, "Failed to start RMI server at port " + port, ex);
} }
@ -425,7 +429,8 @@ public class ServerImpl implements Server {
@Override @Override
public void cheat(UUID gameId, UUID sessionId, DeckCardLists deckList) throws MageException { public void cheat(UUID gameId, UUID sessionId, DeckCardLists deckList) throws MageException {
try { try {
// GameManager.getInstance().cheat(gameId, sessionId, deckList); if (testMode)
GameManager.getInstance().cheat(gameId, sessionId, deckList);
} }
catch (Exception ex) { catch (Exception ex) {
handleException(ex); handleException(ex);

View file

@ -347,6 +347,7 @@ public class GameController implements GameCallback {
return new CardsView(cards.values()); return new CardsView(cards.values());
} }
@Override
public void gameResult(String result) { public void gameResult(String result) {
endGame(result); endGame(result);
} }

View file

@ -57,6 +57,7 @@ public class GameWorker implements Callable {
result.gameResult(game.getWinner()); result.gameResult(game.getWinner());
} catch (Exception ex) { } catch (Exception ex) {
logger.log(Level.SEVERE, null, ex); logger.log(Level.SEVERE, null, ex);
result.gameResult("Server Error");
} }
return null; return null;
} }