public static File createRandomSaveGame() { // start a server FreeColServer serv = startServer(false, true); // generate a random map Controller c = serv.getController(); assertNotNull(c); assertTrue(c instanceof PreGameController); PreGameController pgc = (PreGameController) c; try { pgc.startGame(); } catch (FreeColException e) { fail(e.getMessage()); } assertEquals(FreeColServer.GameState.IN_GAME, serv.getGameState()); assertNotNull(serv.getGame()); assertNotNull(serv.getGame().getMap()); // save the game as a file File file = new File(TEST_FILE); try { serv.saveGame(file, null); } catch (IOException e) { e.printStackTrace(); fail(e.toString()); } assertTrue(file.exists()); stopServer(); return file; }
public static FreeColServer startServer( File file, boolean publicServer, boolean singlePlayer, int port, String name) { stopServer(); try { server = new FreeColServer(new FreeColSavegameFile(file), null, port, name); } catch (Exception e) { fail(e.getMessage()); } assertNotNull(server); assertEquals(FreeColServer.GameState.IN_GAME, server.getGameState()); return server; }
public static FreeColServer startServer( boolean publicServer, boolean singlePlayer, Specification spec, int port, String name) { stopServer(); try { // FIXME: Pass tc server = new FreeColServer(publicServer, singlePlayer, spec, port, name); } catch (IOException ex) { fail(ex.getMessage()); } assertNotNull(server); assertEquals(FreeColServer.GameState.STARTING_GAME, server.getGameState()); return server; }