Commit ac9a5a39 authored by 刘家荣's avatar 刘家荣 💬
Browse files

bugfix(存档 & 窗口切换)

parent f5f82127
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -4,7 +4,11 @@
    <CLASSES>
      <root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2/2.0.17/fastjson2-2.0.17.jar!/" />
    </CLASSES>
    <JAVADOC />
    <SOURCES />
    <JAVADOC>
      <root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2/2.0.17/fastjson2-2.0.17-javadoc.jar!/" />
    </JAVADOC>
    <SOURCES>
      <root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2/2.0.17/fastjson2-2.0.17-sources.jar!/" />
    </SOURCES>
  </library>
</component>
 No newline at end of file
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+13 −5
Original line number Diff line number Diff line
@@ -240,9 +240,10 @@ public class AppController {
    }
    
    public void backToStart() {
        if (status == AppStatus.ROOM)
        if (status == AppStatus.ROOM) {
            RoomFrame.instance.dispose();
        else if (status == AppStatus.GAME)
        }
        else if (status == AppStatus.GAME) {
            ChessGameFrame.instance.dispose();
            if (Game.instance != null && Game.instance.gameType != GameType.ONLINE) {
                try {
@@ -252,6 +253,7 @@ public class AppController {
                    JOptionPane.showMessageDialog(null, "阿哦,保存时发生错误了:" + e.getMessage(), "提示", JOptionPane.WARNING_MESSAGE);
                }
            }
        }
        else return;
        SwingUtilities.invokeLater(() -> {
            AppFrame.instance = new AppFrame();
@@ -260,10 +262,16 @@ public class AppController {
        status = AppStatus.START;
    }
    
    /**
     * 年度大无语事件之JSON能做的事JSONObject不能做
     * @param path
     * @throws IOException
     * @throws JSONException
     */
    public void read(String path) throws IOException, JSONException {
        JSONObject jsonObject = JSONObject.parse(Files.readString(Path.of(path)));
        savedGame = jsonObject.getObject("Game", Game.class);
        savedHistory = jsonObject.getObject("History", History.class);
        savedGame = JSON.parseObject(jsonObject.getJSONObject("Game").toString(), Game.class);
        savedHistory = JSON.parseObject(jsonObject.getJSONObject("History").toString(), History.class);
    }
    
    public void write(String path) throws IOException, JSONException {
+2 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ 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 (firstId == -1) {    //判断第一次点击
            if (square instanceof Chess chess) {
                if (!chess.isReversal()) {  //未翻开,翻之
@@ -57,7 +58,7 @@ public enum ChessClickController {
            }else {
                step = Game.instance.resolveStep(step);
                if(step != null) {
                    History.instance.steps.add(step);
                    History.instance.push(step);
                    firstId = -1;
                    if(Game.instance.gameType == GameType.LOCAL_AI){
                        AI.instance.start();
+73 −6

File changed.

Preview size limit exceeded, changes collapsed.

Loading