我正在创建的国际象棋中的运动有一个问题。下面是一个检查,如果一招是有效的方法:国际象棋比赛中的典当运动 - 爪哇
public boolean isMove(int row, int col, Pawn[][] board){
Pawn p = board[row][col];
int direction = 1;
if (this.color=='w') {
direction = -1;
}
if (p == null && this.col == col && ((this.row + direction) == row) || (this.row + 2 * direction) == row && ! this.hasMoved) { //can move
return true;
}
else if (p != null && p.color != this.color && row == (this.row + direction) && (col == (this.col - 1) || col == (this.col + 1))) { // can capture
return true;
}
return false;
}
这里有一些产出,我越来越:
此举不应该是有效的,但还没有它允许移动到那个广场。我在考虑上面发布的方法存在问题。
你有调试过吗? –