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

bugfix(instance问题) feat(Site新构造函数, ChessColor.opponent)

parent c3ef4fc2
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -11,5 +11,14 @@
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="io.vavr" level="project" />
    <orderEntry type="library" name="alibaba.fastjson2" level="project" />
    <orderEntry type="module-library">
      <library>
        <CLASSES>
          <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/23.0.0/annotations-23.0.0.jar!/" />
        </CLASSES>
        <JAVADOC />
        <SOURCES />
      </library>
    </orderEntry>
  </component>
</module>
 No newline at end of file
+2 −5
Original line number Diff line number Diff line
@@ -2,10 +2,7 @@ package controller;


import model.History;
import model.dataType.FlipStep;
import model.dataType.GameType;
import model.dataType.MoveStep;
import model.dataType.Step;
import model.dataType.*;
import model.game.*;
import network.Client;
import view.ChessGameFrame;
@@ -49,7 +46,7 @@ public enum ChessClickController {
                squareCom.repaint();
                firstId = -1;
            } else {
                step = new MoveStep(firstId, square.id);
                step = square instanceof Chess ? new EatStep(firstId, square.id, -1) : new MoveStep(firstId, square.id);
            }
        }
        if(step != null){
+4 −0
Original line number Diff line number Diff line
@@ -22,4 +22,8 @@ public enum ChessColor {
    public Color getColor() {
        return color;
    }
    
    public ChessColor opponent(){
        return this == BLACK ? RED : (this == RED ? BLACK : NONE);
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ package model.dataType;

import model.game.Chess;
import model.game.Chessboard;
import model.game.Game;

/**
 * 记录一步行棋
@@ -14,7 +15,7 @@ public class FlipStep extends Step {
    public final int srcChessId;
    
    public FlipStep(int srcChessId) {
        if (Chessboard.getInstance().getSquareById(srcChessId) instanceof Chess) {
        if (Game.instance.chessboard.getSquareById(srcChessId) instanceof Chess) {
            this.srcChessId = srcChessId;
        }else {
            throw new IllegalArgumentException(String.format(
+3 −2
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ package model.dataType;

import model.game.Chess;
import model.game.Chessboard;
import model.game.Game;

/**
 * 记录一步行棋
@@ -19,8 +20,8 @@ public class MoveStep extends Step {
    public final int dstSquareId;
    
    public MoveStep(int srcChessId, int dstSquareId) {
        if (Chessboard.getInstance().getSquareById(srcChessId) instanceof Chess
            && !(Chessboard.getInstance().getSquareById(dstSquareId) instanceof Chess)) {
        if (Game.instance.chessboard.getSquareById(srcChessId) instanceof Chess
            && !(Game.instance.chessboard.getSquareById(dstSquareId) instanceof Chess)) {
            this.srcChessId = srcChessId;
            this.dstSquareId = dstSquareId;
        }else {
Loading