Loading src/controller/CheckRule.java +11 −7 Changes for src/controller/CheckRule.java: 11 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -48,16 +48,20 @@ public class CheckRule { * 此处利用 enum 的 compareTo 方法 判断吃棋是否合规 */ public static boolean checkRank(Chess handleChess, Chess dstChess) { //已翻转的情况 ChessType srcType = handleChess.getChessType(); ChessType dstType = dstChess.getChessType(); if (dstChess.isReversal()) { return handleChess.getChessColor() != dstChess.getChessColor() && ( (handleChess.getChessType() == ChessType.SOLDIER && (dstChess.getChessType() == ChessType.CANNON || dstChess.getChessType() == ChessType.GENERAL) ) || dstChess.getChessType().compareTo(handleChess.getChessType()) >= 0 return handleChess.getChessColor() != dstChess.getChessColor() // 颜色不相等 && !(srcType == ChessType.GENERAL && dstType == ChessType.SOLDIER) //将->兵,不可 && ( dstType.compareTo(srcType) >= 0 //高级 || ( //兵->炮/将 srcType == ChessType.SOLDIER && (dstType == ChessType.CANNON || dstType == ChessType.GENERAL) ) ); } else { return (handleChess.getChessType() == ChessType.CANNON); return (srcType == ChessType.CANNON); } } Loading src/model/Chessboard.java +0 −3 Changes for src/model/Chessboard.java: 0 added lines, 3 removed lines. Original line number Diff line number Diff line package model; import com.sun.source.tree.SynchronizedTree; import model.chess.Chess; import model.chess.EmptySlot; import model.chess.Square; Loading Loading @@ -38,7 +36,6 @@ public class Chessboard implements Serializable, Cloneable { * 初始化整个棋盘,包括所有棋子和亡子堆 */ public Chessboard() { History.init(this); Random random = new Random(); //此列表的元素是元组,每个元组存储的是对应棋子的部分参数(颜色和类别) ArrayList<Tuple2<ChessColor, ChessType>> paramsList = new ArrayList<>(); Loading Loading
src/controller/CheckRule.java +11 −7 Changes for src/controller/CheckRule.java: 11 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -48,16 +48,20 @@ public class CheckRule { * 此处利用 enum 的 compareTo 方法 判断吃棋是否合规 */ public static boolean checkRank(Chess handleChess, Chess dstChess) { //已翻转的情况 ChessType srcType = handleChess.getChessType(); ChessType dstType = dstChess.getChessType(); if (dstChess.isReversal()) { return handleChess.getChessColor() != dstChess.getChessColor() && ( (handleChess.getChessType() == ChessType.SOLDIER && (dstChess.getChessType() == ChessType.CANNON || dstChess.getChessType() == ChessType.GENERAL) ) || dstChess.getChessType().compareTo(handleChess.getChessType()) >= 0 return handleChess.getChessColor() != dstChess.getChessColor() // 颜色不相等 && !(srcType == ChessType.GENERAL && dstType == ChessType.SOLDIER) //将->兵,不可 && ( dstType.compareTo(srcType) >= 0 //高级 || ( //兵->炮/将 srcType == ChessType.SOLDIER && (dstType == ChessType.CANNON || dstType == ChessType.GENERAL) ) ); } else { return (handleChess.getChessType() == ChessType.CANNON); return (srcType == ChessType.CANNON); } } Loading
src/model/Chessboard.java +0 −3 Changes for src/model/Chessboard.java: 0 added lines, 3 removed lines. Original line number Diff line number Diff line package model; import com.sun.source.tree.SynchronizedTree; import model.chess.Chess; import model.chess.EmptySlot; import model.chess.Square; Loading Loading @@ -38,7 +36,6 @@ public class Chessboard implements Serializable, Cloneable { * 初始化整个棋盘,包括所有棋子和亡子堆 */ public Chessboard() { History.init(this); Random random = new Random(); //此列表的元素是元组,每个元组存储的是对应棋子的部分参数(颜色和类别) ArrayList<Tuple2<ChessColor, ChessType>> paramsList = new ArrayList<>(); Loading