diff --git a/DataManager/.idea/.name b/DataManager/.idea/.name old mode 100755 new mode 100644 diff --git a/DataManager/.idea/compiler.xml b/DataManager/.idea/compiler.xml deleted file mode 100755 index 9a8b7e5..0000000 --- a/DataManager/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - \ No newline at end of file diff --git a/DataManager/.idea/copyright/profiles_settings.xml b/DataManager/.idea/copyright/profiles_settings.xml deleted file mode 100755 index c7d1c5a..0000000 --- a/DataManager/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/DataManager/.idea/encodings.xml b/DataManager/.idea/encodings.xml deleted file mode 100755 index d821048..0000000 --- a/DataManager/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/DataManager/.idea/libraries/mysql_connector_java_5_1_34_bin.xml b/DataManager/.idea/libraries/mysql_connector_java_5_1_34_bin.xml deleted file mode 100755 index 8e97f94..0000000 --- a/DataManager/.idea/libraries/mysql_connector_java_5_1_34_bin.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/DataManager/.idea/misc.xml b/DataManager/.idea/misc.xml deleted file mode 100755 index f4b2d7b..0000000 --- a/DataManager/.idea/misc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/DataManager/.idea/modules.xml b/DataManager/.idea/modules.xml deleted file mode 100755 index ef9347e..0000000 --- a/DataManager/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/DataManager/.idea/scopes/scope_settings.xml b/DataManager/.idea/scopes/scope_settings.xml deleted file mode 100755 index 0d5175c..0000000 --- a/DataManager/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/DataManager/.idea/vcs.xml b/DataManager/.idea/vcs.xml deleted file mode 100755 index 6564d52..0000000 --- a/DataManager/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DataManager/.idea/workspace.xml b/DataManager/.idea/workspace.xml deleted file mode 100755 index 255c894..0000000 --- a/DataManager/.idea/workspace.xml +++ /dev/null @@ -1,620 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1421226772200 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No facets are configured - - - - - - - - - - - - - - - Android API 15 Platform - - - - - - - - DataManager - - - - - - - - mysql-connector-java-5.1.34-bin - - - - - - - - \ No newline at end of file diff --git a/DataManager/DataManager.iml b/DataManager/DataManager.iml old mode 100755 new mode 100644 diff --git a/DataManager/out/production/DataManager/DataManager.class b/DataManager/out/production/DataManager/DataManager.class old mode 100755 new mode 100644 diff --git a/DataManager/src/DataManager.java b/DataManager/src/DataManager.java old mode 100755 new mode 100644 index 2a05959..2e03e8a --- a/DataManager/src/DataManager.java +++ b/DataManager/src/DataManager.java @@ -1,119 +1,119 @@ -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.sql.*; -import java.util.Scanner; - -/** - * Created by 정인중 on 2015-01-14. - */ -public class DataManager { - - private static Connection connection = null; - private static Statement statement = null; - - public static void main(String[] args) { - System.out.println("데이터베이스와 연결합니다.."); - try { - connectMySQL("jdbc:mysql://localhost:3306/danbi?useUnicode=true&characterEncoding=utf8", "root", "projectDanbi"); - System.out.println("데이터베이스 연결 성공"); - - Scanner sc = new Scanner(System.in); - String command; - ResultSet rs; - BufferedWriter bw; - while (!(command = sc.nextLine()).equals("-1")) { - switch (command) { - case "0": - // 아이템 - rs = statement.executeQuery("SELECT * FROM `setting_item`"); - bw = new BufferedWriter(new FileWriter("./item.txt")); - bw.write("0||||0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0"); - while (rs.next()) { - bw.write("\n" - + rs.getInt("no") + "|" - + rs.getString("name") + "|" - + rs.getString("description") + "|" - + rs.getString("image") + "|" - + rs.getInt("job") + "|" - + rs.getInt("limit_level") + "|" - + rs.getInt("type") + "|" - + rs.getInt("price") + "|" - + rs.getInt("damage") + "|" - + rs.getInt("magic_damage") + "|" - + rs.getInt("defense") + "|" - + rs.getInt("magic_defense") + "|" - + rs.getInt("str") + "|" - + rs.getInt("dex") + "|" - + rs.getInt("agi") + "|" - + rs.getInt("hp") + "|" - + rs.getInt("mp") + "|" - + rs.getInt("critical") + "|" - + rs.getInt("avoid") + "|" - + rs.getInt("hit") + "|" - + rs.getInt("delay") + "|" - + rs.getInt("consume") + "|" - + rs.getInt("max_load") + "|" - + rs.getInt("trade")); - bw.flush(); - } - bw.close(); - System.out.println("아이템 데이터 추출 완료"); - break; - case "1": - // 스킬 - rs = statement.executeQuery("SELECT * FROM `setting_skill`"); - bw = new BufferedWriter(new FileWriter("./skill.txt")); - while (rs.next()) { - bw.write("\n" - + rs.getInt("no") + "|" - + rs.getString("name") + "|" - + rs.getString("description") + "|" - + rs.getString("type") + "|" - + rs.getInt("job") + "|" - + rs.getInt("delay") + "|" - + rs.getInt("limit_level") + "|" - + rs.getInt("max_rank") + "|" - + rs.getInt("user_animation") + "|" - + rs.getInt("target_animation") + "|" - + rs.getString("image") + "|" - + rs.getString("function")); - bw.flush(); - } - bw.close(); - System.out.println("스킬 데이터 추출 완료"); - break; - } - } - - connection.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static void connectMySQL(String host, String id, String pass) throws Exception { - try { - Class.forName("com.mysql.jdbc.Driver"); - connection = DriverManager.getConnection(host, id, pass); - statement = connection.createStatement(); - } catch (SQLException e) { - e.printStackTrace(); - } - return; - } - - // Select - public static ResultSet executeQuery(String query) throws SQLException { - return statement.executeQuery(query); - } - - public static void insertShop(String name, String category, String desc, String phone, String add, String roadAdd, int x, int y) { - try { - statement.executeUpdate("INSERT INTO `shop` (`name`, `category`, `description`, `telephone`, `address`, `road_address`, `map_x`, `map_y`) VALUES ('" + - name + "', '" + category + "', '" + desc + "', '" + phone + "', '" + add + "', '" + roadAdd + "', '" + x + "', '" + y + "');"); - } catch (SQLException e) { - e.printStackTrace(); - } - } - -} +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.sql.*; +import java.util.Scanner; + +/** + * Created by 정인중 on 2015-01-14. + */ +public class DataManager { + + private static Connection connection = null; + private static Statement statement = null; + + public static void main(String[] args) { + System.out.println("데이터베이스와 연결합니다.."); + try { + connectMySQL("jdbc:mysql://localhost:3306/danbi?useUnicode=true&characterEncoding=utf8", "root", "projectDanbi"); + System.out.println("데이터베이스 연결 성공"); + + Scanner sc = new Scanner(System.in); + String command; + ResultSet rs; + BufferedWriter bw; + while (!(command = sc.nextLine()).equals("-1")) { + switch (command) { + case "0": + // 아이템 + rs = statement.executeQuery("SELECT * FROM `setting_item`"); + bw = new BufferedWriter(new FileWriter("./item.txt")); + bw.write("0||||0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0"); + while (rs.next()) { + bw.write("\n" + + rs.getInt("no") + "|" + + rs.getString("name") + "|" + + rs.getString("description") + "|" + + rs.getString("image") + "|" + + rs.getInt("job") + "|" + + rs.getInt("limit_level") + "|" + + rs.getInt("type") + "|" + + rs.getInt("price") + "|" + + rs.getInt("damage") + "|" + + rs.getInt("magic_damage") + "|" + + rs.getInt("defense") + "|" + + rs.getInt("magic_defense") + "|" + + rs.getInt("str") + "|" + + rs.getInt("dex") + "|" + + rs.getInt("agi") + "|" + + rs.getInt("hp") + "|" + + rs.getInt("mp") + "|" + + rs.getInt("critical") + "|" + + rs.getInt("avoid") + "|" + + rs.getInt("hit") + "|" + + rs.getInt("delay") + "|" + + rs.getInt("consume") + "|" + + rs.getInt("max_load") + "|" + + rs.getInt("trade")); + bw.flush(); + } + bw.close(); + System.out.println("아이템 데이터 추출 완료"); + break; + case "1": + // 스킬 + rs = statement.executeQuery("SELECT * FROM `setting_skill`"); + bw = new BufferedWriter(new FileWriter("./skill.txt")); + while (rs.next()) { + bw.write("\n" + + rs.getInt("no") + "|" + + rs.getString("name") + "|" + + rs.getString("description") + "|" + + rs.getString("type") + "|" + + rs.getInt("job") + "|" + + rs.getInt("delay") + "|" + + rs.getInt("limit_level") + "|" + + rs.getInt("max_rank") + "|" + + rs.getInt("user_animation") + "|" + + rs.getInt("target_animation") + "|" + + rs.getString("image") + "|" + + rs.getString("function")); + bw.flush(); + } + bw.close(); + System.out.println("스킬 데이터 추출 완료"); + break; + } + } + + connection.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static void connectMySQL(String host, String id, String pass) throws Exception { + try { + Class.forName("com.mysql.jdbc.Driver"); + connection = DriverManager.getConnection(host, id, pass); + statement = connection.createStatement(); + } catch (SQLException e) { + e.printStackTrace(); + } + return; + } + + // Select + public static ResultSet executeQuery(String query) throws SQLException { + return statement.executeQuery(query); + } + + public static void insertShop(String name, String category, String desc, String phone, String add, String roadAdd, int x, int y) { + try { + statement.executeUpdate("INSERT INTO `shop` (`name`, `category`, `description`, `telephone`, `address`, `road_address`, `map_x`, `map_y`) VALUES ('" + + name + "', '" + category + "', '" + desc + "', '" + phone + "', '" + add + "', '" + roadAdd + "', '" + x + "', '" + y + "');"); + } catch (SQLException e) { + e.printStackTrace(); + } + } + +} diff --git a/Server/.classpath b/Server/.classpath old mode 100755 new mode 100644 diff --git a/Server/.idea/artifacts/Server_jar.xml b/Server/.idea/artifacts/Server_jar.xml deleted file mode 100644 index 432cd8d..0000000 --- a/Server/.idea/artifacts/Server_jar.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - $PROJECT_DIR$/classes/artifacts/Server_jar - - - - - - - - - - - \ No newline at end of file diff --git a/Server/.idea/compiler.xml b/Server/.idea/compiler.xml deleted file mode 100644 index 8e650cc..0000000 --- a/Server/.idea/compiler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Server/.idea/copyright/profiles_settings.xml b/Server/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/Server/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Server/.idea/dictionaries/.xml b/Server/.idea/dictionaries/.xml deleted file mode 100644 index ae00efc..0000000 --- a/Server/.idea/dictionaries/.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Server/.idea/encodings.xml b/Server/.idea/encodings.xml deleted file mode 100644 index f758959..0000000 --- a/Server/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Server/.idea/libraries/JSON.xml b/Server/.idea/libraries/JSON.xml deleted file mode 100644 index d51bb79..0000000 --- a/Server/.idea/libraries/JSON.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Server/.idea/libraries/Jackson_JSON.xml b/Server/.idea/libraries/Jackson_JSON.xml deleted file mode 100644 index faaf416..0000000 --- a/Server/.idea/libraries/Jackson_JSON.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Server/.idea/libraries/MySQL.xml b/Server/.idea/libraries/MySQL.xml deleted file mode 100644 index edb5a86..0000000 --- a/Server/.idea/libraries/MySQL.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Server/.idea/libraries/Netty_4.xml b/Server/.idea/libraries/Netty_4.xml deleted file mode 100644 index 23cbb65..0000000 --- a/Server/.idea/libraries/Netty_4.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Server/.idea/misc.xml b/Server/.idea/misc.xml deleted file mode 100644 index 4e745f6..0000000 --- a/Server/.idea/misc.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Server/.idea/modules.xml b/Server/.idea/modules.xml deleted file mode 100644 index 7ec00e1..0000000 --- a/Server/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Server/.idea/scopes/scope_settings.xml b/Server/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/Server/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/Server/.idea/uiDesigner.xml b/Server/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/Server/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Server/.idea/vcs.xml b/Server/.idea/vcs.xml deleted file mode 100644 index 6c0b863..0000000 --- a/Server/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Server/.idea/workspace.xml b/Server/.idea/workspace.xml deleted file mode 100644 index 78673e0..0000000 --- a/Server/.idea/workspace.xml +++ /dev/null @@ -1,1423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - get - dropGold - chat( - CHAT - cOOLTIME - SET_COOLTIME - lastTime - setCooltime - update( - SELECT - update - coolDown - chat - getNo() - chatWhisper - .replace - startShowingBalloon - startShowingBalloo - balloon - - - - - - - - - - - - - - true - - - - - - - - - - - - Android Lint - - - CSS - - - Code style issues - - - Code style issuesCSS - - - GeneralJavaScript - - - JavaScript - - - Plugin DevKit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $USER_HOME$/.subversion - 125 - - - - - 1418924503477 - - - 1418927646178 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Server:jar - - - - - - - - No facets are configured - - - - - - - - - - - - - - - 1.8 - - - - - - - - Server - - - - - - - - 1.8 - - - - - - - - Jackson JSON - - - - - - - - \ No newline at end of file diff --git a/Server/.project b/Server/.project old mode 100755 new mode 100644 diff --git a/Server/.settings/org.eclipse.jdt.core.prefs b/Server/.settings/org.eclipse.jdt.core.prefs old mode 100755 new mode 100644 diff --git a/Server/Map/MAP1.map b/Server/Map/MAP1.map old mode 100755 new mode 100644 diff --git a/Server/Map/MAP2.map b/Server/Map/MAP2.map old mode 100755 new mode 100644 diff --git a/Server/bin/.idea/artifacts/Server_jar.xml b/Server/bin/.idea/artifacts/Server_jar.xml deleted file mode 100644 index 432cd8d..0000000 --- a/Server/bin/.idea/artifacts/Server_jar.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - $PROJECT_DIR$/classes/artifacts/Server_jar - - - - - - - - - - - \ No newline at end of file diff --git a/Server/bin/.idea/compiler.xml b/Server/bin/.idea/compiler.xml deleted file mode 100644 index 8e650cc..0000000 --- a/Server/bin/.idea/compiler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Server/bin/.idea/copyright/profiles_settings.xml b/Server/bin/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/Server/bin/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Server/bin/.idea/dictionaries/.xml b/Server/bin/.idea/dictionaries/.xml deleted file mode 100644 index ae00efc..0000000 --- a/Server/bin/.idea/dictionaries/.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Server/bin/.idea/encodings.xml b/Server/bin/.idea/encodings.xml deleted file mode 100644 index f758959..0000000 --- a/Server/bin/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Server/bin/.idea/libraries/JSON.xml b/Server/bin/.idea/libraries/JSON.xml deleted file mode 100644 index d51bb79..0000000 --- a/Server/bin/.idea/libraries/JSON.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Server/bin/.idea/libraries/Jackson_JSON.xml b/Server/bin/.idea/libraries/Jackson_JSON.xml deleted file mode 100644 index faaf416..0000000 --- a/Server/bin/.idea/libraries/Jackson_JSON.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Server/bin/.idea/libraries/MySQL.xml b/Server/bin/.idea/libraries/MySQL.xml deleted file mode 100644 index edb5a86..0000000 --- a/Server/bin/.idea/libraries/MySQL.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Server/bin/.idea/libraries/Netty_4.xml b/Server/bin/.idea/libraries/Netty_4.xml deleted file mode 100644 index 23cbb65..0000000 --- a/Server/bin/.idea/libraries/Netty_4.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Server/bin/.idea/misc.xml b/Server/bin/.idea/misc.xml deleted file mode 100644 index 4e745f6..0000000 --- a/Server/bin/.idea/misc.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Server/bin/.idea/modules.xml b/Server/bin/.idea/modules.xml deleted file mode 100644 index 7ec00e1..0000000 --- a/Server/bin/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Server/bin/.idea/scopes/scope_settings.xml b/Server/bin/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/Server/bin/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/Server/bin/.idea/uiDesigner.xml b/Server/bin/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/Server/bin/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Server/bin/.idea/vcs.xml b/Server/bin/.idea/vcs.xml deleted file mode 100644 index 6c0b863..0000000 --- a/Server/bin/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Server/bin/.idea/workspace.xml b/Server/bin/.idea/workspace.xml deleted file mode 100644 index bcffd5c..0000000 --- a/Server/bin/.idea/workspace.xml +++ /dev/null @@ -1,1423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - get - dropGold - chat( - CHAT - cOOLTIME - SET_COOLTIME - lastTime - setCooltime - update( - SELECT - update - coolDown - chat - getNo() - chatWhisper - .replace - startShowingBalloon - startShowingBalloo - balloon - - - - - - - - - - - - - - true - - - - - - - - - - - - Android Lint - - - CSS - - - Code style issues - - - Code style issuesCSS - - - GeneralJavaScript - - - JavaScript - - - Plugin DevKit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $USER_HOME$/.subversion - 125 - - - - - 1418924503477 - - - 1418927646178 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Server:jar - - - - - - - - No facets are configured - - - - - - - - - - - - - - - 1.8 - - - - - - - - Server - - - - - - - - 1.8 - - - - - - - - Jackson JSON - - - - - - - - \ No newline at end of file diff --git a/Server/src/database/DataBase.java b/Server/src/database/DataBase.java old mode 100755 new mode 100644 diff --git a/Server/src/network/Handler.java b/Server/src/network/Handler.java old mode 100755 new mode 100644 diff --git a/Server/src/network/Initializer.java b/Server/src/network/Initializer.java old mode 100755 new mode 100644 diff --git a/Server/src/network/Server.java b/Server/src/network/Server.java old mode 100755 new mode 100644 diff --git a/Server/src/packet/CTSHeader.java b/Server/src/packet/CTSHeader.java old mode 100755 new mode 100644 diff --git a/Server/src/packet/JsonDecoder.java b/Server/src/packet/JsonDecoder.java index 21bb1f2..19817dc 100644 --- a/Server/src/packet/JsonDecoder.java +++ b/Server/src/packet/JsonDecoder.java @@ -1,55 +1,55 @@ -package packet; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.CorruptedFrameException; -import io.netty.handler.codec.string.StringDecoder; - -import java.io.IOException; -import java.util.List; - -import org.json.simple.JSONObject; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class JsonDecoder extends StringDecoder { - - @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List out) throws Exception { - if (msg.readableBytes() < 4) { - return; - } - - msg.markReaderIndex(); - - int dataLength = msg.readInt(); - if (msg.readableBytes() < dataLength) { - msg.resetReaderIndex(); - return; - } - - byte[] decoded = new byte[dataLength]; - msg.readBytes(decoded); - out.add(deserialize(decoded)); - } - - private Object deserialize(byte[] buf) throws CorruptedFrameException { - ObjectMapper mapper = new ObjectMapper(); - - Throwable t; - try { - return mapper.readValue(buf, JSONObject.class); - } catch (JsonParseException e) { - t = e; - } catch (JsonMappingException e) { - t = e; - } catch (IOException e) { - t = e; - } - - throw new CorruptedFrameException("Error deserializing json: " + t.getMessage()); - } - +package packet; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.CorruptedFrameException; +import io.netty.handler.codec.string.StringDecoder; + +import java.io.IOException; +import java.util.List; + +import org.json.simple.JSONObject; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class JsonDecoder extends StringDecoder { + + @Override + protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List out) throws Exception { + if (msg.readableBytes() < 4) { + return; + } + + msg.markReaderIndex(); + + int dataLength = msg.readInt(); + if (msg.readableBytes() < dataLength) { + msg.resetReaderIndex(); + return; + } + + byte[] decoded = new byte[dataLength]; + msg.readBytes(decoded); + out.add(deserialize(decoded)); + } + + private Object deserialize(byte[] buf) throws CorruptedFrameException { + ObjectMapper mapper = new ObjectMapper(); + + Throwable t; + try { + return mapper.readValue(buf, JSONObject.class); + } catch (JsonParseException e) { + t = e; + } catch (JsonMappingException e) { + t = e; + } catch (IOException e) { + t = e; + } + + throw new CorruptedFrameException("Error deserializing json: " + t.getMessage()); + } + } \ No newline at end of file diff --git a/Server/src/packet/JsonEncoder.java b/Server/src/packet/JsonEncoder.java index c5beb3d..643a88e 100644 --- a/Server/src/packet/JsonEncoder.java +++ b/Server/src/packet/JsonEncoder.java @@ -1,48 +1,48 @@ -package packet; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.CorruptedFrameException; -import io.netty.handler.codec.MessageToMessageEncoder; -import io.netty.util.CharsetUtil; - -import java.io.IOException; -import java.util.List; - -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -@SuppressWarnings("unchecked") -public class JsonEncoder extends MessageToMessageEncoder { - - @Override - protected void encode(ChannelHandlerContext ctx, Object msg, List out) throws Exception { - String json = serialize(msg); - byte[] data = json.getBytes(CharsetUtil.UTF_8); - int dataLength = data.length; - - ByteBuf buf = Unpooled.buffer(); - //buf.writeInt(dataLength); - buf.writeBytes(data); - out.add(buf); - } - - private String serialize(Object msg) throws CorruptedFrameException { - ObjectMapper mapper = new ObjectMapper(); - Throwable t; - try { - return mapper.writeValueAsString(msg); - } catch (JsonGenerationException e) { - t = e; - } catch (JsonMappingException e) { - t = e; - } catch (IOException e) { - t = e; - } - - throw new CorruptedFrameException("Error while serializing message: " + t.getMessage()); - } - -} +package packet; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.CorruptedFrameException; +import io.netty.handler.codec.MessageToMessageEncoder; +import io.netty.util.CharsetUtil; + +import java.io.IOException; +import java.util.List; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@SuppressWarnings("unchecked") +public class JsonEncoder extends MessageToMessageEncoder { + + @Override + protected void encode(ChannelHandlerContext ctx, Object msg, List out) throws Exception { + String json = serialize(msg); + byte[] data = json.getBytes(CharsetUtil.UTF_8); + int dataLength = data.length; + + ByteBuf buf = Unpooled.buffer(); + //buf.writeInt(dataLength); + buf.writeBytes(data); + out.add(buf); + } + + private String serialize(Object msg) throws CorruptedFrameException { + ObjectMapper mapper = new ObjectMapper(); + Throwable t; + try { + return mapper.writeValueAsString(msg); + } catch (JsonGenerationException e) { + t = e; + } catch (JsonMappingException e) { + t = e; + } catch (IOException e) { + t = e; + } + + throw new CorruptedFrameException("Error while serializing message: " + t.getMessage()); + } + +} diff --git a/Server/src/packet/Packet.java b/Server/src/packet/Packet.java index ebe1f96..69504e2 100644 --- a/Server/src/packet/Packet.java +++ b/Server/src/packet/Packet.java @@ -1,745 +1,745 @@ -package packet; - -import database.Type; -import game.Field; -import game.Guild; -import game.User; -import game.Character; - -import org.json.simple.JSONObject; - -import database.GameData; - -@SuppressWarnings("unchecked") -public final class Packet { - - // success(0), id/pass error(1), sql error(2) - public static JSONObject loginMessage(int type) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.LOGIN); - packet.put("type", type); - - return packet; - } - - public static JSONObject loginMessage(User user) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.LOGIN); - packet.put("type", 0); - packet.put("no", user.getNo()); - packet.put("id", user.getID()); - packet.put("name", user.getName()); - packet.put("title", user.getTitle()); - packet.put("image", user.getImage()); - packet.put("job", user.getJob()); - packet.put("guild", Guild.get(user.getGuild()) != null ? Guild.get(user.getGuild()).getName() : "길드 없음"); - packet.put("guildNo", user.getGuild()); - packet.put("str", user.getStr()); - packet.put("dex", user.getDex()); - packet.put("agi", user.getAgi()); - packet.put("statPoint", user.getStatPoint()); - packet.put("skillPoint", user.getSkillPoint()); - packet.put("critical", user.getCritical()); - packet.put("avoid", user.getAvoid()); - packet.put("hit", user.getHit()); - packet.put("hp", user.getHp()); - packet.put("maxHp", user.getMaxHp()); - packet.put("mp", user.getMp()); - packet.put("maxMp", user.getMaxMp()); - packet.put("level", user.getLevel()); - packet.put("exp", user.getExp()); - packet.put("maxExp", user.getMaxExp()); - packet.put("gold", user.getGold()); - packet.put("map", user.getMap()); - packet.put("x", user.getX()); - packet.put("y", user.getY()); - packet.put("direction", user.getDirection()); - - packet.put("weapon", user.getWeapon()); - packet.put("shield", user.getShield()); - packet.put("helmet", user.getHelmet()); - packet.put("armor", user.getArmor()); - packet.put("cape", user.getCape()); - packet.put("shoes", user.getShoes()); - packet.put("accessory", user.getAccessory()); - - return packet; - } - - // success(0), id exists(1), nick exists(2), SQL error(3) - public static JSONObject registerMessage(int type) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.REGISTER); - packet.put("type", type); - - return packet; - } - - public static JSONObject createCharacter(int type, Character c) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CREATE_CHARACTER); - packet.put("type", type); - packet.put("no", c.getNo()); - packet.put("name", c.getName()); - packet.put("image", c.getImage()); - packet.put("speed", c.getMoveSpeed()); - packet.put("hp", c.getHp()); - packet.put("maxHp", c.getMaxHp()); - packet.put("x", c.getX()); - packet.put("y", c.getY()); - packet.put("d", c.getDirection()); - - if (type == Type.Character.USER) { - User u = (User) c; - packet.put("guild", Guild.get(u.getGuild()) != null ? Guild.get(u.getGuild()).getName() : "길드 없음"); - packet.put("title", u.getTitle()); - } - - return packet; - } - - public static JSONObject removeCharacter(int type, int no) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.REMOVE_CHARACTER); - packet.put("type", type); - packet.put("no", no); - - return packet; - } - - public static JSONObject refreshCharacter(int type, int no, int x, int y, int d) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.REFRESH_CHARACTER); - packet.put("type", type); - packet.put("no", no); - packet.put("x", x); - packet.put("y", y); - packet.put("d", d); - - return packet; - } - - public static JSONObject moveCharacter(int type, int no, int x, int y, int d) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.MOVE_CHARACTER); - packet.put("type", type); - packet.put("no", no); - packet.put("x", x); - packet.put("y", y); - packet.put("d", d); - - return packet; - } - - public static JSONObject turnCharacter(int type, int no, int d) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.TURN_CHARACTER); - packet.put("type", type); - packet.put("no", no); - packet.put("d", d); - - return packet; - } - - public static JSONObject jumpCharacter(int type, int no, int x, int y) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.JUMP_CHARACTER); - packet.put("type", type); - packet.put("no", no); - packet.put("x", x); - packet.put("y", y); - - return packet; - } - - public static JSONObject animationCharacter(int type, int no, int ani) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.ANIMATION_CHARACTER); - packet.put("type", type); - packet.put("no", no); - packet.put("ani", ani); - - return packet; - } - - public static JSONObject updateCharacter(int type, int no, int[] keys, Object[] values) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.UPDATE_CHARACTER); - packet.put("type", type); - packet.put("no", no); - for (int i = 0; i < keys.length; i++) - packet.put(keys[i], values[i]); - - return packet; - } - - public static JSONObject damageCharacter(int type, int no, int value, boolean critical) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.DAMAGE_CHARACTER); - packet.put("type", type); - packet.put("no", no); - packet.put("value", value); - if (critical) packet.put("critical", 1); - - return packet; - } - - public static JSONObject loadDropItem(Field.DropItem item) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.LOAD_DROP_ITEM); - packet.put("no", item.getNo()); - packet.put("x", item.getX()); - packet.put("y", item.getY()); - packet.put("image", item.getImage()); - - return packet; - } - - public static JSONObject loadDropGold(Field.DropGold gold) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.LOAD_DROP_GOLD); - packet.put("no", gold.getNo()); - packet.put("x", gold.getX()); - packet.put("y", gold.getY()); - packet.put("amount", gold.getAmount()); - - return packet; - } - - public static JSONObject removeDropItem(Field.DropItem item) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.REMOVE_DROP_ITEM); - packet.put("no", item.getNo()); - - return packet; - } - - public static JSONObject removeDropGold(Field.DropGold gold) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.REMOVE_DROP_GOLD); - packet.put("no", gold.getNo()); - - return packet; - } - - public static JSONObject notify(String message) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.NOTIFY); - packet.put("message", message); - - return packet; - } - - public static JSONObject notify(String message, int r, int g, int b) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.NOTIFY); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - - return packet; - } - - public static JSONObject notify(String message, int r, int g, int b, int r2, int g2, int b2) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.NOTIFY); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - packet.put("r2", r2); - packet.put("g2", g2); - packet.put("b2", b2); - - return packet; - } - - public static JSONObject moveMap(User u) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.MOVE_MAP); - packet.put("map", u.getMap()); - packet.put("x", u.getX()); - packet.put("y", u.getY()); - - return packet; - } - - public static JSONObject chatNormal(int no, String message) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_NORMAL); - packet.put("no", no); - packet.put("message", message); - return packet; - }public static JSONObject chatNormal(int no, String message, int r, int g, int b) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_NORMAL); - packet.put("no", no); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - return packet; - }public static JSONObject chatNormal(int no, String message, int r, int g, int b, int r2, int g2, int b2) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_NORMAL); - packet.put("no", no); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - packet.put("r2", r2); - packet.put("g2", g2); - packet.put("b2", b2); - return packet; - } - - public static JSONObject chatWhisper(String message) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_WHISPER); - packet.put("message", message); - return packet; - }public static JSONObject chatWhisper(String message, int r, int g, int b) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_WHISPER); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - return packet; - }public static JSONObject chatWhisper(String message, int r, int g, int b, int r2, int g2, int b2) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_WHISPER); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - packet.put("r2", r2); - packet.put("g2", g2); - packet.put("b2", b2); - return packet; - } - - public static JSONObject chatParty(String message) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_PARTY); - packet.put("message", message); - return packet; - }public static JSONObject chatParty(String message, int r, int g, int b) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_PARTY); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - return packet; - }public static JSONObject chatParty(String message, int r, int g, int b, int r2, int g2, int b2) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_PARTY); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - packet.put("r2", r2); - packet.put("g2", g2); - packet.put("b2", b2); - return packet; - } - - public static JSONObject chatGuild(String message) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_GUILD); - packet.put("message", message); - return packet; - }public static JSONObject chatGuild(String message, int r, int g, int b) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_GUILD); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - return packet; - }public static JSONObject chatGuild(String message, int r, int g, int b, int r2, int g2, int b2) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_GUILD); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - packet.put("r2", r2); - packet.put("g2", g2); - packet.put("b2", b2); - return packet; - } - - public static JSONObject chatAll(int no, String message) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_ALL); - packet.put("no", no); - packet.put("message", message); - return packet; - }public static JSONObject chatAll(int no, String message, int r, int g, int b) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_ALL); - packet.put("no", no); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - return packet; - }public static JSONObject chatAll(int no, String message, int r, int g, int b, int r2, int g2, int b2) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_ALL); - packet.put("no", no); - packet.put("message", message); - packet.put("r", r); - packet.put("g", g); - packet.put("b", b); - packet.put("r2", r2); - packet.put("g2", g2); - packet.put("b2", b2); - return packet; - } - - public static JSONObject openRegisterWindow() { - String[] image = new String[GameData.register.size()]; - int[] job = new int[GameData.register.size()]; - for (int i = 0; i < GameData.register.size(); i++) { - image[i] = GameData.register.get(i + 1).getImage(); - job[i] = GameData.register.get(i + 1).getJob(); - } - - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.OPEN_REGISTER_WINDOW); - packet.put("image", image); - packet.put("job", job); - - return packet; - } - - public static JSONObject updateStatus(int[] keys, Object[] values) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.UPDATE_STATUS); - for (int i = 0; i < keys.length; i++) - packet.put(keys[i], values[i]); - - return packet; - } - - public static JSONObject setItem(GameData.Item item) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.SET_ITEM); - packet.put("userNo", item.getUserNo()); - packet.put("itemNo", item.getNo()); - packet.put("amount", item.getAmount()); - packet.put("index", item.getIndex()); - packet.put("damage", item.getDamage()); - packet.put("magicDamage", item.getMagicDamage()); - packet.put("defense", item.getDefense()); - packet.put("magicDefense", item.getMagicDefense()); - packet.put("str", item.getStr()); - packet.put("dex", item.getDex()); - packet.put("agi", item.getAgi()); - packet.put("hp", item.getHp()); - packet.put("mp", item.getMp()); - packet.put("critical", item.getCritical()); - packet.put("avoid", item.getAvoid()); - packet.put("hit", item.getHit()); - packet.put("reinforce", item.getReinforce()); - packet.put("trade", item.isTradeable() ? 1 : 0); - packet.put("equipped", item.isEquipped() ? 1 : 0); - - return packet; - } - - // 삭제(0), 갯수(1) - public static JSONObject updateItem(int type, GameData.Item item) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.UPDATE_ITEM); - packet.put("type", type); - packet.put("index", item.getIndex()); - packet.put("amount", item.getAmount()); - packet.put("damage", item.getDamage()); - packet.put("magicDamage", item.getMagicDamage()); - packet.put("defense", item.getDefense()); - packet.put("magicDefense", item.getMagicDefense()); - packet.put("str", item.getStr()); - packet.put("dex", item.getDex()); - packet.put("agi", item.getAgi()); - packet.put("hp", item.getHp()); - packet.put("mp", item.getMp()); - packet.put("critical", item.getCritical()); - packet.put("avoid", item.getAvoid()); - packet.put("hit", item.getHit()); - packet.put("reinforce", item.getReinforce()); - packet.put("trade", item.isTradeable() ? 1 : 0); - packet.put("equipped", item.isEquipped() ? 1 : 0); - - return packet; - } - - public static JSONObject setSkill(GameData.Skill skill) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.SET_SKILL); - packet.put("no", skill.getNo()); - packet.put("rank", skill.getRank()); - - return packet; - } - - // 삭제(0), 랭크(1) - public static JSONObject updateSkill(int type, GameData.Skill skill) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.UPDATE_SKILL); - packet.put("type", type); - packet.put("no", skill.getNo()); - packet.put("rank", skill.getRank()); - - return packet; - } - - public static JSONObject requestTrade(int partnerNo) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.REQUEST_TRADE); - packet.put("partnerNo", partnerNo); - - return packet; - } - - public static JSONObject openTradeWindow(int partnerNo) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.OPEN_TRADE_WINDOW); - packet.put("partnerNo", partnerNo); - - return packet; - } - - public static JSONObject loadTradeItem(GameData.Item item) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.LOAD_TRADE_ITEM); - packet.put("userNo", item.getUserNo()); - packet.put("itemNo", item.getNo()); - packet.put("amount", item.getAmount()); - packet.put("index", item.getIndex()); - packet.put("damage", item.getDamage()); - packet.put("magicDamage", item.getMagicDamage()); - packet.put("defense", item.getDefense()); - packet.put("magicDefense", item.getMagicDefense()); - packet.put("str", item.getStr()); - packet.put("dex", item.getDex()); - packet.put("agi", item.getAgi()); - packet.put("hp", item.getHp()); - packet.put("mp", item.getMp()); - packet.put("critical", item.getCritical()); - packet.put("avoid", item.getAvoid()); - packet.put("hit", item.getHit()); - packet.put("reinforce", item.getReinforce()); - - return packet; - } - - public static JSONObject dropTradeItem(int no, int index) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.DROP_TRADE_ITEM); - packet.put("no", no); - packet.put("index", index); - - return packet; - } - - public static JSONObject changeTradeGold(int no, int amount) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHANGE_TRADE_GOLD); - packet.put("no", no); - packet.put("amount", amount); - - return packet; - } - - public static JSONObject acceptTrade(int no) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.FINISH_TRADE); - packet.put("no", no); - - return packet; - } - - public static JSONObject cancelTrade() { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CANCEL_TRADE); - - return packet; - } - - // 닫기(-1), 다음(0), 선택지 갯수 (1~) - public static JSONObject openMessageWindow(int no, int message, int select) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.OPEN_MESSAGE_WINDOW); - packet.put("no", no); - packet.put("message", message); - packet.put("select", select); - - return packet; - } - - public static JSONObject closeMessageWindow() { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CLOSE_MESSAGE_WINDOW); - - return packet; - } - - public static JSONObject openShopWindow(int no) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.OPEN_SHOP_WINDOW); - packet.put("no", no); - - return packet; - } - - public static JSONObject setShopItem(int no, int price) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.SET_SHOP_ITEM); - packet.put("no", no); - packet.put("price", price); - - return packet; - } - - public static JSONObject setParty(int no) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.SET_PARTY); - packet.put("no", no); - - return packet; - } - - public static JSONObject inviteParty(int partyNo, String master) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.INVITE_PARTY); - packet.put("master", master); - packet.put("partyNo", partyNo); - - return packet; - } - - public static JSONObject setPartyMember(User user) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.SET_PARTY_MEMBER); - packet.put("no", user.getNo()); - packet.put("name", user.getName()); - packet.put("image", user.getImage()); - packet.put("level", user.getLevel()); - packet.put("job", user.getJob()); - packet.put("hp", user.getHp()); - packet.put("maxHp", user.getMaxHp()); - - return packet; - } - - public static JSONObject removePartyMember(int no) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.REMOVE_PARTY_MEMBER); - packet.put("no", no); - - return packet; - } - - public static JSONObject createGuild(int amount) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CREATE_GUILD); - packet.put("amount", amount); - - return packet; - } - - public static JSONObject setGuild(int no) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.SET_GUILD); - packet.put("no", no); - - return packet; - } - - public static JSONObject inviteGuild(int guildNo, String master) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.INVITE_GUILD); - packet.put("master", master); - packet.put("guildNo", guildNo); - - return packet; - } - - public static JSONObject setGuildMember(User user) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.SET_GUILD_MEMBER); - packet.put("no", user.getNo()); - packet.put("name", user.getName()); - packet.put("image", user.getImage()); - packet.put("level", user.getLevel()); - packet.put("job", user.getJob()); - packet.put("hp", user.getHp()); - packet.put("maxHp", user.getMaxHp()); - - return packet; - } - - public static JSONObject setGuildMember(int no, String name, String image, int level, int job, int hp, int maxHp) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.SET_GUILD_MEMBER); - packet.put("no", no); - packet.put("name", name); - packet.put("image", image); - packet.put("level", level); - packet.put("job", job); - packet.put("hp", hp); - packet.put("maxHp", maxHp); - - return packet; - } - - public static JSONObject removeGuildMember(int no) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.REMOVE_GUILD_MEMBER); - packet.put("no", no); - - return packet; - } - - public static JSONObject playMusic(int type, String name) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.PLAY_MUSIC); - packet.put("type", type); - packet.put("name", name); - - return packet; - } - - public static JSONObject removeChattingBalloon(int no) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.CHAT_BALLOON_END); - packet.put("no", no); - - return packet; - } - - public static JSONObject setCooltime(int nowCooltime, int fullCooltime, int idx) - { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.SET_COOLTIME); - packet.put("index", idx); - packet.put("nowCooltime", nowCooltime); - packet.put("fullCooltime", fullCooltime); - - return packet; - } - - public static JSONObject setSlot(int index, int slot) { - JSONObject packet = new JSONObject(); - packet.put("header", STCHeader.SET_SLOT); - packet.put("index", index); - packet.put("slot", slot); - - return packet; - } -} +package packet; + +import database.Type; +import game.Field; +import game.Guild; +import game.User; +import game.Character; + +import org.json.simple.JSONObject; + +import database.GameData; + +@SuppressWarnings("unchecked") +public final class Packet { + + // success(0), id/pass error(1), sql error(2) + public static JSONObject loginMessage(int type) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.LOGIN); + packet.put("type", type); + + return packet; + } + + public static JSONObject loginMessage(User user) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.LOGIN); + packet.put("type", 0); + packet.put("no", user.getNo()); + packet.put("id", user.getID()); + packet.put("name", user.getName()); + packet.put("title", user.getTitle()); + packet.put("image", user.getImage()); + packet.put("job", user.getJob()); + packet.put("guild", Guild.get(user.getGuild()) != null ? Guild.get(user.getGuild()).getName() : "길드 없음"); + packet.put("guildNo", user.getGuild()); + packet.put("str", user.getStr()); + packet.put("dex", user.getDex()); + packet.put("agi", user.getAgi()); + packet.put("statPoint", user.getStatPoint()); + packet.put("skillPoint", user.getSkillPoint()); + packet.put("critical", user.getCritical()); + packet.put("avoid", user.getAvoid()); + packet.put("hit", user.getHit()); + packet.put("hp", user.getHp()); + packet.put("maxHp", user.getMaxHp()); + packet.put("mp", user.getMp()); + packet.put("maxMp", user.getMaxMp()); + packet.put("level", user.getLevel()); + packet.put("exp", user.getExp()); + packet.put("maxExp", user.getMaxExp()); + packet.put("gold", user.getGold()); + packet.put("map", user.getMap()); + packet.put("x", user.getX()); + packet.put("y", user.getY()); + packet.put("direction", user.getDirection()); + + packet.put("weapon", user.getWeapon()); + packet.put("shield", user.getShield()); + packet.put("helmet", user.getHelmet()); + packet.put("armor", user.getArmor()); + packet.put("cape", user.getCape()); + packet.put("shoes", user.getShoes()); + packet.put("accessory", user.getAccessory()); + + return packet; + } + + // success(0), id exists(1), nick exists(2), SQL error(3) + public static JSONObject registerMessage(int type) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.REGISTER); + packet.put("type", type); + + return packet; + } + + public static JSONObject createCharacter(int type, Character c) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CREATE_CHARACTER); + packet.put("type", type); + packet.put("no", c.getNo()); + packet.put("name", c.getName()); + packet.put("image", c.getImage()); + packet.put("speed", c.getMoveSpeed()); + packet.put("hp", c.getHp()); + packet.put("maxHp", c.getMaxHp()); + packet.put("x", c.getX()); + packet.put("y", c.getY()); + packet.put("d", c.getDirection()); + + if (type == Type.Character.USER) { + User u = (User) c; + packet.put("guild", Guild.get(u.getGuild()) != null ? Guild.get(u.getGuild()).getName() : "길드 없음"); + packet.put("title", u.getTitle()); + } + + return packet; + } + + public static JSONObject removeCharacter(int type, int no) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.REMOVE_CHARACTER); + packet.put("type", type); + packet.put("no", no); + + return packet; + } + + public static JSONObject refreshCharacter(int type, int no, int x, int y, int d) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.REFRESH_CHARACTER); + packet.put("type", type); + packet.put("no", no); + packet.put("x", x); + packet.put("y", y); + packet.put("d", d); + + return packet; + } + + public static JSONObject moveCharacter(int type, int no, int x, int y, int d) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.MOVE_CHARACTER); + packet.put("type", type); + packet.put("no", no); + packet.put("x", x); + packet.put("y", y); + packet.put("d", d); + + return packet; + } + + public static JSONObject turnCharacter(int type, int no, int d) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.TURN_CHARACTER); + packet.put("type", type); + packet.put("no", no); + packet.put("d", d); + + return packet; + } + + public static JSONObject jumpCharacter(int type, int no, int x, int y) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.JUMP_CHARACTER); + packet.put("type", type); + packet.put("no", no); + packet.put("x", x); + packet.put("y", y); + + return packet; + } + + public static JSONObject animationCharacter(int type, int no, int ani) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.ANIMATION_CHARACTER); + packet.put("type", type); + packet.put("no", no); + packet.put("ani", ani); + + return packet; + } + + public static JSONObject updateCharacter(int type, int no, int[] keys, Object[] values) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.UPDATE_CHARACTER); + packet.put("type", type); + packet.put("no", no); + for (int i = 0; i < keys.length; i++) + packet.put(keys[i], values[i]); + + return packet; + } + + public static JSONObject damageCharacter(int type, int no, int value, boolean critical) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.DAMAGE_CHARACTER); + packet.put("type", type); + packet.put("no", no); + packet.put("value", value); + if (critical) packet.put("critical", 1); + + return packet; + } + + public static JSONObject loadDropItem(Field.DropItem item) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.LOAD_DROP_ITEM); + packet.put("no", item.getNo()); + packet.put("x", item.getX()); + packet.put("y", item.getY()); + packet.put("image", item.getImage()); + + return packet; + } + + public static JSONObject loadDropGold(Field.DropGold gold) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.LOAD_DROP_GOLD); + packet.put("no", gold.getNo()); + packet.put("x", gold.getX()); + packet.put("y", gold.getY()); + packet.put("amount", gold.getAmount()); + + return packet; + } + + public static JSONObject removeDropItem(Field.DropItem item) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.REMOVE_DROP_ITEM); + packet.put("no", item.getNo()); + + return packet; + } + + public static JSONObject removeDropGold(Field.DropGold gold) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.REMOVE_DROP_GOLD); + packet.put("no", gold.getNo()); + + return packet; + } + + public static JSONObject notify(String message) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.NOTIFY); + packet.put("message", message); + + return packet; + } + + public static JSONObject notify(String message, int r, int g, int b) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.NOTIFY); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + + return packet; + } + + public static JSONObject notify(String message, int r, int g, int b, int r2, int g2, int b2) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.NOTIFY); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + packet.put("r2", r2); + packet.put("g2", g2); + packet.put("b2", b2); + + return packet; + } + + public static JSONObject moveMap(User u) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.MOVE_MAP); + packet.put("map", u.getMap()); + packet.put("x", u.getX()); + packet.put("y", u.getY()); + + return packet; + } + + public static JSONObject chatNormal(int no, String message) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_NORMAL); + packet.put("no", no); + packet.put("message", message); + return packet; + }public static JSONObject chatNormal(int no, String message, int r, int g, int b) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_NORMAL); + packet.put("no", no); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + return packet; + }public static JSONObject chatNormal(int no, String message, int r, int g, int b, int r2, int g2, int b2) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_NORMAL); + packet.put("no", no); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + packet.put("r2", r2); + packet.put("g2", g2); + packet.put("b2", b2); + return packet; + } + + public static JSONObject chatWhisper(String message) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_WHISPER); + packet.put("message", message); + return packet; + }public static JSONObject chatWhisper(String message, int r, int g, int b) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_WHISPER); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + return packet; + }public static JSONObject chatWhisper(String message, int r, int g, int b, int r2, int g2, int b2) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_WHISPER); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + packet.put("r2", r2); + packet.put("g2", g2); + packet.put("b2", b2); + return packet; + } + + public static JSONObject chatParty(String message) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_PARTY); + packet.put("message", message); + return packet; + }public static JSONObject chatParty(String message, int r, int g, int b) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_PARTY); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + return packet; + }public static JSONObject chatParty(String message, int r, int g, int b, int r2, int g2, int b2) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_PARTY); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + packet.put("r2", r2); + packet.put("g2", g2); + packet.put("b2", b2); + return packet; + } + + public static JSONObject chatGuild(String message) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_GUILD); + packet.put("message", message); + return packet; + }public static JSONObject chatGuild(String message, int r, int g, int b) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_GUILD); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + return packet; + }public static JSONObject chatGuild(String message, int r, int g, int b, int r2, int g2, int b2) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_GUILD); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + packet.put("r2", r2); + packet.put("g2", g2); + packet.put("b2", b2); + return packet; + } + + public static JSONObject chatAll(int no, String message) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_ALL); + packet.put("no", no); + packet.put("message", message); + return packet; + }public static JSONObject chatAll(int no, String message, int r, int g, int b) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_ALL); + packet.put("no", no); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + return packet; + }public static JSONObject chatAll(int no, String message, int r, int g, int b, int r2, int g2, int b2) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_ALL); + packet.put("no", no); + packet.put("message", message); + packet.put("r", r); + packet.put("g", g); + packet.put("b", b); + packet.put("r2", r2); + packet.put("g2", g2); + packet.put("b2", b2); + return packet; + } + + public static JSONObject openRegisterWindow() { + String[] image = new String[GameData.register.size()]; + int[] job = new int[GameData.register.size()]; + for (int i = 0; i < GameData.register.size(); i++) { + image[i] = GameData.register.get(i + 1).getImage(); + job[i] = GameData.register.get(i + 1).getJob(); + } + + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.OPEN_REGISTER_WINDOW); + packet.put("image", image); + packet.put("job", job); + + return packet; + } + + public static JSONObject updateStatus(int[] keys, Object[] values) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.UPDATE_STATUS); + for (int i = 0; i < keys.length; i++) + packet.put(keys[i], values[i]); + + return packet; + } + + public static JSONObject setItem(GameData.Item item) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.SET_ITEM); + packet.put("userNo", item.getUserNo()); + packet.put("itemNo", item.getNo()); + packet.put("amount", item.getAmount()); + packet.put("index", item.getIndex()); + packet.put("damage", item.getDamage()); + packet.put("magicDamage", item.getMagicDamage()); + packet.put("defense", item.getDefense()); + packet.put("magicDefense", item.getMagicDefense()); + packet.put("str", item.getStr()); + packet.put("dex", item.getDex()); + packet.put("agi", item.getAgi()); + packet.put("hp", item.getHp()); + packet.put("mp", item.getMp()); + packet.put("critical", item.getCritical()); + packet.put("avoid", item.getAvoid()); + packet.put("hit", item.getHit()); + packet.put("reinforce", item.getReinforce()); + packet.put("trade", item.isTradeable() ? 1 : 0); + packet.put("equipped", item.isEquipped() ? 1 : 0); + + return packet; + } + + // 삭제(0), 갯수(1) + public static JSONObject updateItem(int type, GameData.Item item) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.UPDATE_ITEM); + packet.put("type", type); + packet.put("index", item.getIndex()); + packet.put("amount", item.getAmount()); + packet.put("damage", item.getDamage()); + packet.put("magicDamage", item.getMagicDamage()); + packet.put("defense", item.getDefense()); + packet.put("magicDefense", item.getMagicDefense()); + packet.put("str", item.getStr()); + packet.put("dex", item.getDex()); + packet.put("agi", item.getAgi()); + packet.put("hp", item.getHp()); + packet.put("mp", item.getMp()); + packet.put("critical", item.getCritical()); + packet.put("avoid", item.getAvoid()); + packet.put("hit", item.getHit()); + packet.put("reinforce", item.getReinforce()); + packet.put("trade", item.isTradeable() ? 1 : 0); + packet.put("equipped", item.isEquipped() ? 1 : 0); + + return packet; + } + + public static JSONObject setSkill(GameData.Skill skill) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.SET_SKILL); + packet.put("no", skill.getNo()); + packet.put("rank", skill.getRank()); + + return packet; + } + + // 삭제(0), 랭크(1) + public static JSONObject updateSkill(int type, GameData.Skill skill) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.UPDATE_SKILL); + packet.put("type", type); + packet.put("no", skill.getNo()); + packet.put("rank", skill.getRank()); + + return packet; + } + + public static JSONObject requestTrade(int partnerNo) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.REQUEST_TRADE); + packet.put("partnerNo", partnerNo); + + return packet; + } + + public static JSONObject openTradeWindow(int partnerNo) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.OPEN_TRADE_WINDOW); + packet.put("partnerNo", partnerNo); + + return packet; + } + + public static JSONObject loadTradeItem(GameData.Item item) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.LOAD_TRADE_ITEM); + packet.put("userNo", item.getUserNo()); + packet.put("itemNo", item.getNo()); + packet.put("amount", item.getAmount()); + packet.put("index", item.getIndex()); + packet.put("damage", item.getDamage()); + packet.put("magicDamage", item.getMagicDamage()); + packet.put("defense", item.getDefense()); + packet.put("magicDefense", item.getMagicDefense()); + packet.put("str", item.getStr()); + packet.put("dex", item.getDex()); + packet.put("agi", item.getAgi()); + packet.put("hp", item.getHp()); + packet.put("mp", item.getMp()); + packet.put("critical", item.getCritical()); + packet.put("avoid", item.getAvoid()); + packet.put("hit", item.getHit()); + packet.put("reinforce", item.getReinforce()); + + return packet; + } + + public static JSONObject dropTradeItem(int no, int index) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.DROP_TRADE_ITEM); + packet.put("no", no); + packet.put("index", index); + + return packet; + } + + public static JSONObject changeTradeGold(int no, int amount) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHANGE_TRADE_GOLD); + packet.put("no", no); + packet.put("amount", amount); + + return packet; + } + + public static JSONObject acceptTrade(int no) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.FINISH_TRADE); + packet.put("no", no); + + return packet; + } + + public static JSONObject cancelTrade() { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CANCEL_TRADE); + + return packet; + } + + // 닫기(-1), 다음(0), 선택지 갯수 (1~) + public static JSONObject openMessageWindow(int no, int message, int select) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.OPEN_MESSAGE_WINDOW); + packet.put("no", no); + packet.put("message", message); + packet.put("select", select); + + return packet; + } + + public static JSONObject closeMessageWindow() { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CLOSE_MESSAGE_WINDOW); + + return packet; + } + + public static JSONObject openShopWindow(int no) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.OPEN_SHOP_WINDOW); + packet.put("no", no); + + return packet; + } + + public static JSONObject setShopItem(int no, int price) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.SET_SHOP_ITEM); + packet.put("no", no); + packet.put("price", price); + + return packet; + } + + public static JSONObject setParty(int no) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.SET_PARTY); + packet.put("no", no); + + return packet; + } + + public static JSONObject inviteParty(int partyNo, String master) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.INVITE_PARTY); + packet.put("master", master); + packet.put("partyNo", partyNo); + + return packet; + } + + public static JSONObject setPartyMember(User user) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.SET_PARTY_MEMBER); + packet.put("no", user.getNo()); + packet.put("name", user.getName()); + packet.put("image", user.getImage()); + packet.put("level", user.getLevel()); + packet.put("job", user.getJob()); + packet.put("hp", user.getHp()); + packet.put("maxHp", user.getMaxHp()); + + return packet; + } + + public static JSONObject removePartyMember(int no) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.REMOVE_PARTY_MEMBER); + packet.put("no", no); + + return packet; + } + + public static JSONObject createGuild(int amount) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CREATE_GUILD); + packet.put("amount", amount); + + return packet; + } + + public static JSONObject setGuild(int no) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.SET_GUILD); + packet.put("no", no); + + return packet; + } + + public static JSONObject inviteGuild(int guildNo, String master) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.INVITE_GUILD); + packet.put("master", master); + packet.put("guildNo", guildNo); + + return packet; + } + + public static JSONObject setGuildMember(User user) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.SET_GUILD_MEMBER); + packet.put("no", user.getNo()); + packet.put("name", user.getName()); + packet.put("image", user.getImage()); + packet.put("level", user.getLevel()); + packet.put("job", user.getJob()); + packet.put("hp", user.getHp()); + packet.put("maxHp", user.getMaxHp()); + + return packet; + } + + public static JSONObject setGuildMember(int no, String name, String image, int level, int job, int hp, int maxHp) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.SET_GUILD_MEMBER); + packet.put("no", no); + packet.put("name", name); + packet.put("image", image); + packet.put("level", level); + packet.put("job", job); + packet.put("hp", hp); + packet.put("maxHp", maxHp); + + return packet; + } + + public static JSONObject removeGuildMember(int no) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.REMOVE_GUILD_MEMBER); + packet.put("no", no); + + return packet; + } + + public static JSONObject playMusic(int type, String name) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.PLAY_MUSIC); + packet.put("type", type); + packet.put("name", name); + + return packet; + } + + public static JSONObject removeChattingBalloon(int no) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.CHAT_BALLOON_END); + packet.put("no", no); + + return packet; + } + + public static JSONObject setCooltime(int nowCooltime, int fullCooltime, int idx) + { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.SET_COOLTIME); + packet.put("index", idx); + packet.put("nowCooltime", nowCooltime); + packet.put("fullCooltime", fullCooltime); + + return packet; + } + + public static JSONObject setSlot(int index, int slot) { + JSONObject packet = new JSONObject(); + packet.put("header", STCHeader.SET_SLOT); + packet.put("index", index); + packet.put("slot", slot); + + return packet; + } +} diff --git a/Server/src/packet/STCHeader.java b/Server/src/packet/STCHeader.java old mode 100755 new mode 100644