package pylos;

import java.io.File;
import java.util.logging.Logger;

import pylos.controller.Controller;
import pylos.model.Model;
import pylos.model.Position;
import pylos.network.Network;
import pylos.view.View;

public class Pylos {
	public static View view;
	public static Network network;

	// Ugly hack to get root path: this is Java ...
	public static final String rootPath = new File(Pylos.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent();
	public static final String assetsPath = rootPath + "/assets";
	public static final Logger logger = Logger.getLogger("pylos");
	public static final Logger AIlogger = Logger.getLogger("pylos.ai");

	/**
	 * Initialize the environment.
	 * This should be called first.
	 */
	public static void initialize() {
		Position.initialize();
	}

	/**
	 * Pylos' Main: Start the game
	 */
	public static void main(String[] args) {
		initialize();
		System.out.println("Welcome to Pylos!");
		logger.config("root path is " + rootPath);

		Config.configureProject();

		Model.initialize();

		view = new View();
		Controller.initialize(view);
		view.show();

		network = new Network();
	}

	public static void stop() {
		view.stop();
		network.stop();
	}
}

@@ -30,16 +30,89 @@
 o.File;%0A
+import java.io.UnsupportedEncodingException;%0Aimport java.net.URLDecoder;%0A
 import j
@@ -136,16 +136,16 @@
 Logger;%0A
-
 %0Aimport 
@@ -455,101 +455,26 @@
 h = 
-new File(Pylos.class.
 getPro
-tectionDomain().getCodeSource().getLocation().getPath()).getParent
+jectRootPath
 ();%0A
@@ -1194,16 +1194,16 @@
 stop();%0A
-
 %09%09networ
@@ -1214,11 +1214,431 @@
 op();%0A%09%7D
+%0A%0A%09public static String getProjectRootPath() %7B%0A%09%09String pylosClassPath = Pylos.class.getProtectionDomain().getCodeSource().getLocation().getPath();%0A%09%09String rootPath = new File(pylosClassPath).getParent();%0A%09%09try %7B%0A%09%09%09rootPath = URLDecoder.decode(rootPath, %22UTF-8%22);%0A%09%09%7D catch (UnsupportedEncodingException e) %7B%0A%09%09%09System.err.println(%22Could not decode root project url: %22 + rootPath + %22%5Cn%22 + e);%0A%09%09%7D%0A%09%09return rootPath;%0A%09%7D
 %0A%7D%0A

handle spaces within path