Loading src/controller/AppController.java +0 −2 Changes for src/controller/AppController.java: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -21,8 +21,6 @@ import view.Frame.RoomFrame; import view.Frame.RoomFrameReturnType.goOnline; import javax.swing.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.io.IOException; import java.net.UnknownHostException; Loading src/controller/BulletAnim.java +3 −1 Changes for src/controller/BulletAnim.java: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ public class BulletAnim extends Thread { /** * 创建新的弹幕,需要传入这个弹幕所显示的消息对象 * * @param msg 消息 */ private JLabel newBulletLabel(Msg msg) { Loading Loading @@ -118,6 +119,7 @@ public class BulletAnim extends Thread { * <br/>设某个消息的发出时间为T0,当前时间为T,屏幕宽度为w, * <br/>那么弹幕在T0时刻的左端x坐标为w; * <br/>左端x坐标关于T的函数:x - w = -v * (T - T0) * * @param msg 消息 * @return 左端x坐标 */ Loading @@ -131,13 +133,13 @@ public class BulletAnim extends Thread { * <br/>计算弹幕的像素长度 * <br/> * <br/>不确定这种方式对不对,早晚有一天会要修改的 * * @param msg 消息 * @return 长度 */ // String.length -> byte // BULLET_FONT_SIZE -> px // 在 RGB 下 1 px = 3 byte private int evalLength(Msg msg) { return msg.content().length() * BULLET_FONT_SIZE * 3; //不确定这种长度计算方式对不对 } Loading src/controller/ChessClickController.java +7 −4 Changes for src/controller/ChessClickController.java: 7 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -4,14 +4,15 @@ package controller; import model.AI; import model.History; import model.dataType.*; import model.game.*; import model.game.Chess; import model.game.Game; import model.game.Square; import network.Client; import network.OnlineInfo; import network.dataType.OnlineStatus; import view.Frame.ChessGameFrame; import view.Com.ChessboardCom; import view.Com.SquareCom; import view.Frame.GameFrameReturnType.exitGame; import view.Frame.ChessGameFrame; import javax.swing.*; Loading @@ -35,6 +36,7 @@ public enum ChessClickController { /** * 响应click事件,棋盘的交互逻辑 * * @param squareCom 点中的方格 */ public void onClick(SquareCom squareCom) { Loading @@ -42,7 +44,8 @@ public enum ChessClickController { Square square = squareCom.getBackSquare(); Step step = null; //处理一番,结果写到step,否则step为null即无结果 if(Game.instance.gameType == GameType.LOCAL_AI && Game.instance.getCurrentColor() != Game.instance.hostColor) return; if (Game.instance.gameType == GameType.LOCAL_AI && Game.instance.getCurrentColor() != Game.instance.hostColor) return; if (Game.instance.gameType == GameType.ONLINE) { if (OnlineInfo.status == OnlineStatus.SERVER_WAITING) { return; Loading src/model/Account.java +5 −3 Changes for src/model/Account.java: 5 added lines, 3 removed lines. Original line number Diff line number Diff line package model; import com.alibaba.fastjson2.JSON; import network.Client; import view.Theme; import java.io.IOException; Loading Loading @@ -50,6 +49,7 @@ public class Account { public Account(String name) throws IllegalArgumentException { this(name, Theme.DEFAULT); } public Account(String name, Theme theme) throws IllegalArgumentException { if (name == null || name.length() == 0) { throw new IllegalArgumentException("名称不能为空"); Loading Loading @@ -90,14 +90,16 @@ public class Account { res = tmp; } } } catch (IOException | IllegalArgumentException ignored){} } catch (IOException | IllegalArgumentException ignored) { } return res; } private void writeAccount() { try { Files.writeString(Path.of(SELF_ACCOUNT_PATH), JSON.toJSONString(this)); }catch (Exception ignored){} } catch (Exception ignored) { } } } src/model/History.java +15 −3 Changes for src/model/History.java: 15 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -41,9 +41,21 @@ public class History{ int type = 0; int i = -1; switch (step) { case FlipStep flipStep -> {type = 0; i = flipSteps.size(); flipSteps.add(flipStep);} case MoveStep moveStep -> {type = 1; i = moveSteps.size(); moveSteps.add(moveStep);} case EatStep eatStep -> {type = 2; i = eatSteps.size(); eatSteps.add(eatStep);} case FlipStep flipStep -> { type = 0; i = flipSteps.size(); flipSteps.add(flipStep); } case MoveStep moveStep -> { type = 1; i = moveSteps.size(); moveSteps.add(moveStep); } case EatStep eatStep -> { type = 2; i = eatSteps.size(); eatSteps.add(eatStep); } default -> { return; } Loading Loading
src/controller/AppController.java +0 −2 Changes for src/controller/AppController.java: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -21,8 +21,6 @@ import view.Frame.RoomFrame; import view.Frame.RoomFrameReturnType.goOnline; import javax.swing.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.io.IOException; import java.net.UnknownHostException; Loading
src/controller/BulletAnim.java +3 −1 Changes for src/controller/BulletAnim.java: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ public class BulletAnim extends Thread { /** * 创建新的弹幕,需要传入这个弹幕所显示的消息对象 * * @param msg 消息 */ private JLabel newBulletLabel(Msg msg) { Loading Loading @@ -118,6 +119,7 @@ public class BulletAnim extends Thread { * <br/>设某个消息的发出时间为T0,当前时间为T,屏幕宽度为w, * <br/>那么弹幕在T0时刻的左端x坐标为w; * <br/>左端x坐标关于T的函数:x - w = -v * (T - T0) * * @param msg 消息 * @return 左端x坐标 */ Loading @@ -131,13 +133,13 @@ public class BulletAnim extends Thread { * <br/>计算弹幕的像素长度 * <br/> * <br/>不确定这种方式对不对,早晚有一天会要修改的 * * @param msg 消息 * @return 长度 */ // String.length -> byte // BULLET_FONT_SIZE -> px // 在 RGB 下 1 px = 3 byte private int evalLength(Msg msg) { return msg.content().length() * BULLET_FONT_SIZE * 3; //不确定这种长度计算方式对不对 } Loading
src/controller/ChessClickController.java +7 −4 Changes for src/controller/ChessClickController.java: 7 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -4,14 +4,15 @@ package controller; import model.AI; import model.History; import model.dataType.*; import model.game.*; import model.game.Chess; import model.game.Game; import model.game.Square; import network.Client; import network.OnlineInfo; import network.dataType.OnlineStatus; import view.Frame.ChessGameFrame; import view.Com.ChessboardCom; import view.Com.SquareCom; import view.Frame.GameFrameReturnType.exitGame; import view.Frame.ChessGameFrame; import javax.swing.*; Loading @@ -35,6 +36,7 @@ public enum ChessClickController { /** * 响应click事件,棋盘的交互逻辑 * * @param squareCom 点中的方格 */ public void onClick(SquareCom squareCom) { Loading @@ -42,7 +44,8 @@ public enum ChessClickController { Square square = squareCom.getBackSquare(); Step step = null; //处理一番,结果写到step,否则step为null即无结果 if(Game.instance.gameType == GameType.LOCAL_AI && Game.instance.getCurrentColor() != Game.instance.hostColor) return; if (Game.instance.gameType == GameType.LOCAL_AI && Game.instance.getCurrentColor() != Game.instance.hostColor) return; if (Game.instance.gameType == GameType.ONLINE) { if (OnlineInfo.status == OnlineStatus.SERVER_WAITING) { return; Loading
src/model/Account.java +5 −3 Changes for src/model/Account.java: 5 added lines, 3 removed lines. Original line number Diff line number Diff line package model; import com.alibaba.fastjson2.JSON; import network.Client; import view.Theme; import java.io.IOException; Loading Loading @@ -50,6 +49,7 @@ public class Account { public Account(String name) throws IllegalArgumentException { this(name, Theme.DEFAULT); } public Account(String name, Theme theme) throws IllegalArgumentException { if (name == null || name.length() == 0) { throw new IllegalArgumentException("名称不能为空"); Loading Loading @@ -90,14 +90,16 @@ public class Account { res = tmp; } } } catch (IOException | IllegalArgumentException ignored){} } catch (IOException | IllegalArgumentException ignored) { } return res; } private void writeAccount() { try { Files.writeString(Path.of(SELF_ACCOUNT_PATH), JSON.toJSONString(this)); }catch (Exception ignored){} } catch (Exception ignored) { } } }
src/model/History.java +15 −3 Changes for src/model/History.java: 15 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -41,9 +41,21 @@ public class History{ int type = 0; int i = -1; switch (step) { case FlipStep flipStep -> {type = 0; i = flipSteps.size(); flipSteps.add(flipStep);} case MoveStep moveStep -> {type = 1; i = moveSteps.size(); moveSteps.add(moveStep);} case EatStep eatStep -> {type = 2; i = eatSteps.size(); eatSteps.add(eatStep);} case FlipStep flipStep -> { type = 0; i = flipSteps.size(); flipSteps.add(flipStep); } case MoveStep moveStep -> { type = 1; i = moveSteps.size(); moveSteps.add(moveStep); } case EatStep eatStep -> { type = 2; i = eatSteps.size(); eatSteps.add(eatStep); } default -> { return; } Loading