diff --git a/client/src/top/dreamcenter/go/client/DataUtil.java b/client/src/top/dreamcenter/go/client/DataUtil.java index c1468e5..7b4bc06 100644 --- a/client/src/top/dreamcenter/go/client/DataUtil.java +++ b/client/src/top/dreamcenter/go/client/DataUtil.java @@ -4,26 +4,10 @@ import top.dreamcenter.go.msg.Cross; public class DataUtil { - public static String parseData(Cross[][] map){ - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < map.length; i++) { - for (int j = 0; j < map.length; j++) { - sb.append(i).append(j); - if (map[i][j] == Cross.NONE) { - sb.append(0); - } else if (map[i][j] == Cross.BLACK) { - sb.append(1); - } else { - sb.append(2); - } - } - } - return sb.toString(); - } public static Cross[][] rawData(String data){ Cross[][] cross = new Cross[9][9]; - Cross[] colors = new Cross[]{Cross.NONE, Cross.BLACK, Cross.WHITE}; + Cross[] colors = new Cross[]{Cross.NONE, Cross.BLACK, Cross.WHITE, Cross.BLACK_CUR, Cross.WHITE_CUR}; for (int i = 0; i < data.length(); ) { int row = data.charAt(i) - '0'; int col = data.charAt(i + 1) - '0'; diff --git a/client/src/top/dreamcenter/go/client/MainFrame.java b/client/src/top/dreamcenter/go/client/MainFrame.java index faf8315..adfcba0 100644 --- a/client/src/top/dreamcenter/go/client/MainFrame.java +++ b/client/src/top/dreamcenter/go/client/MainFrame.java @@ -139,7 +139,23 @@ public class MainFrame extends JFrame { drawOval(g, col * BASE_FROM , row * BASE_FROM + BASE_HEIGHT, BASE_FROM / 2 - 1); drawOval(g, col * BASE_FROM , row * BASE_FROM + BASE_HEIGHT, BASE_FROM / 2 - 2); } + + if (cross == Cross.BLACK_CUR) { + fillOval(g, col * BASE_FROM , row * BASE_FROM + BASE_HEIGHT, BASE_FROM / 2); + drawPlus(g, col * BASE_FROM , row * BASE_FROM + BASE_HEIGHT, BASE_FROM>>2, Color.WHITE); + } + if (cross == Cross.WHITE_CUR) { + drawOval(g, col * BASE_FROM , row * BASE_FROM + BASE_HEIGHT, BASE_FROM / 2 - 1); + drawOval(g, col * BASE_FROM , row * BASE_FROM + BASE_HEIGHT, BASE_FROM / 2 - 2); + drawPlus(g, col * BASE_FROM , row * BASE_FROM + BASE_HEIGHT, BASE_FROM>>2, Color.BLACK); + } } + private void drawPlus(Graphics g, int cx, int cy, int r, Color color){ + g.setColor(color); + g.fillRect(cx- r, cy - 1, r * 2 + 1, 3); + g.fillRect(cx - 1, cy - r, 3, r * 2 + 1); + g.setColor(Color.BLACK); + } } diff --git a/client/src/top/dreamcenter/go/msg/Cross.java b/client/src/top/dreamcenter/go/msg/Cross.java index 8380627..4376794 100644 --- a/client/src/top/dreamcenter/go/msg/Cross.java +++ b/client/src/top/dreamcenter/go/msg/Cross.java @@ -1,5 +1,7 @@ package top.dreamcenter.go.msg; public enum Cross { - NONE, BLACK, WHITE + NONE, BLACK, WHITE, + + BLACK_CUR, WHITE_CUR } diff --git a/server/src/top/dreamcenter/go/server/DataUtil.java b/server/src/top/dreamcenter/go/server/DataUtil.java index 89a7cd4..2c2110b 100644 --- a/server/src/top/dreamcenter/go/server/DataUtil.java +++ b/server/src/top/dreamcenter/go/server/DataUtil.java @@ -1,37 +1,32 @@ package top.dreamcenter.go.server; import top.dreamcenter.go.msg.Cross; +import top.dreamcenter.go.msg.NewClick; public class DataUtil { - public static String parseData(Cross[][] map){ + public static String parseData(Cross[][] map, NewClick newClick){ StringBuilder sb = new StringBuilder(); for (int i = 0; i < map.length; i++) { for (int j = 0; j < map.length; j++) { + + int magnification = 1; + + if (i == newClick.pos.k - 1 && j == newClick.pos.v - 1) magnification = 3; + sb.append(i).append(j); if (map[i][j] == Cross.NONE) { sb.append(0); } else if (map[i][j] == Cross.BLACK) { - sb.append(1); + sb.append(magnification); // 1 3 } else { - sb.append(2); + sb.append(magnification+1); // 2 4 } } } + + return sb.toString(); } - public static Cross[][] rawData(String data){ - Cross[][] cross = new Cross[9][9]; - Cross[] colors = new Cross[]{Cross.NONE, Cross.BLACK, Cross.WHITE}; - for (int i = 0; i < data.length();) { - int row = data.charAt(i) - '0'; - int col = data.charAt(i + 1) - '0'; - Cross color = colors[data.charAt(i + 2) - '0']; - cross[row][col] = color; - i += 3; - } - - return cross; - } } diff --git a/server/src/top/dreamcenter/go/server/UserThread.java b/server/src/top/dreamcenter/go/server/UserThread.java index 86817b7..44072af 100644 --- a/server/src/top/dreamcenter/go/server/UserThread.java +++ b/server/src/top/dreamcenter/go/server/UserThread.java @@ -67,7 +67,7 @@ public class UserThread extends Thread{ users.forEach(u -> { try { - if (u.isAlive) u.sendMsg(DataUtil.parseData(map)); + if (u.isAlive) u.sendMsg(DataUtil.parseData(map, newClick)); } catch (IOException e) { e.printStackTrace(); }