Commit 6830f23a authored by unknown's avatar unknown
Browse files

add maphandler

parent b602b364
......@@ -66,6 +66,7 @@ class Client implements Runnable {
JSONObject array = (JSONObject) obj;
username = (String) array.get("username");
String feed = username+Long.toString(System.currentTimeMillis());
MapHandler.load();
try {
this.generateToken(feed);
tokenMap.put(feed,username);
......
......@@ -207,7 +207,7 @@ public class EndpointMethod {
int curX = (int) posJson.get("x");
int curY = (int) posJson.get("y");
if(x!=curX && y!=curY) {
if(true) { //NANTI DIGANTI JADI PENGECEKAN APAKAH X Y ADA DI MAP ATAU GA
if(x<=MapHandler.width && y<=MapHandler.height) {
//Ganti data di database
posJson.put("x",x);
posJson.put("y",y);
......
......@@ -19,7 +19,7 @@ import org.json.simple.parser.ParseException;
*
* @author Fauzan Hilmi
*/
public class Map {
public class MapHandler {
public static String name;
public static long width;
public static long height;
......@@ -52,20 +52,20 @@ public class Map {
}
} catch (IOException ex) {
Logger.getLogger(Map.class.getName()).log(Level.SEVERE, null, ex);
Logger.getLogger(MapHandler.class.getName()).log(Level.SEVERE, null, ex);
} catch (ParseException ex) {
Logger.getLogger(Map.class.getName()).log(Level.SEVERE, null, ex);
Logger.getLogger(MapHandler.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void main(String argv[]) {
Map.load();
System.out.println(Map.name);
System.out.println(Map.height);
System.out.println(Map.width);
for(int i=0; i<Map.height; i++) {
for(int j=0; j<Map.width; j++) {
System.out.print(Map.matrix[i][j]+" ");
MapHandler.load();
System.out.println(MapHandler.name);
System.out.println(MapHandler.height);
System.out.println(MapHandler.width);
for(int i=0; i<MapHandler.height; i++) {
for(int j=0; j<MapHandler.width; j++) {
System.out.print(MapHandler.matrix[i][j]+" ");
}
System.out.println("");
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment