diff --git a/src/main/java/com/cse3310/Coordinate b/src/main/java/com/cse3310/Coordinate new file mode 100644 index 0000000..1f26f86 --- /dev/null +++ b/src/main/java/com/cse3310/Coordinate @@ -0,0 +1,15 @@ +package com.cse3310; + +class Coordinate { + public int x; + public int y; + + public void Coordinate(int x, int y){ + this.x = x; + this.y = y; + } + + public void getCoordinate(){ + return int[] location = new int[] {x, y}; + } +} \ No newline at end of file diff --git a/src/main/java/com/cse3310/Game.Java b/src/main/java/com/cse3310/Game.Java index 85a36e2..1c596c0 100644 --- a/src/main/java/com/cse3310/Game.Java +++ b/src/main/java/com/cse3310/Game.Java @@ -6,10 +6,11 @@ import java.utils.ArrayList; public class Game{ private ArrayList User users; public int GameId; - + public int[][] grid; + public Game() { - + } public boolean checkVertical(array selectedLetters, int length){ diff --git a/src/main/java/com/cse3310/Locations.java b/src/main/java/com/cse3310/Locations.java new file mode 100644 index 0000000..c3a0ff1 --- /dev/null +++ b/src/main/java/com/cse3310/Locations.java @@ -0,0 +1,15 @@ +package com.cse3310; + +import java.util.HashMap; + +class Locations { + static HashMap locationMap; + + public int[] getStart(String s){ + return (locationMap.get(s)[0]).getCoordinate; + } + + public int[] getEnd(String s){ + return (locationMap.get(s)[1]).getCoordinate; + } +} \ No newline at end of file diff --git a/src/main/java/com/cse3310/UserEvent.java b/src/main/java/com/cse3310/UserEvent.java index 8ef0b23..a208c98 100644 --- a/src/main/java/com/cse3310/UserEvent.java +++ b/src/main/java/com/cse3310/UserEvent.java @@ -4,4 +4,5 @@ public class UserEvent { int GameId; User UserId; int Button[][]; + String message; } diff --git a/src/main/java/com/cse3310/WebSocket.java b/src/main/java/com/cse3310/WebSocket.java index b52d9e7..5fd93b3 100644 --- a/src/main/java/com/cse3310/WebSocket.java +++ b/src/main/java/com/cse3310/WebSocket.java @@ -29,6 +29,26 @@ public void onClose(Connection conn, int code, String reason, boolean remote) { @Override public void onMessage(Connection conn, String message) { // TODO Auto-generated method stub + System.out.println(conn + ": " + message); // Log message in console + + // Bring in the data from the webpage + // A UserEvent is all that is allowed at this point + GsonBuilder builder = new GsonBuilder(); + Gson gson = builder.create(); + UserEvent U = gson.fromJson(message, UserEvent.class); + System.out.println(U.Button); + + // Get our Game Object + Game G = conn.getAttachment(); + G.Update(U); + + // send out the game state every time + // to everyone + String jsonString; + jsonString = gson.toJson(G); + + System.out.println(jsonString); + broadcast(jsonString); throw new UnsupportedOperationException("Unimplemented method 'onMessage'"); }