flutter: 走子阶段可以走动了

但是走完马上死循环。
This commit is contained in:
Calcitem 2020-11-18 02:06:03 +08:00
parent 5096494372
commit dfb5d47afc
2 changed files with 22 additions and 3 deletions

View File

@ -104,6 +104,24 @@ class Battle {
//Audios.playTone('click.mp3');
}
bool move(int from, int to) {
//
position.move(from, to);
_blurIndex = from;
_focusIndex = to;
/*
if (ChessRules.checked(position)) {
//Audios.playTone('check.mp3');
} else {
//Audios.playTone(captured != Piece.Empty ? 'capture.mp3' : 'move.mp3');
}
*/
return true;
}
bool regret({steps = 2}) {
//
//

View File

@ -194,8 +194,8 @@ class Position {
}
bool movePiece(int fromSq, int toSq) {
if (selectPieceSQ(fromSq)) {
return putPieceSQ(toSq);
if (selectPiece(fromSq)) {
return putPiece(toSq);
}
return false;
@ -670,7 +670,8 @@ class Position {
rule50++;
board[s] = _grid[squareToIndex[s]] = board[currentSquare];
board[currentSquare] = _grid[squareToIndex[s]] = Piece.noPiece;
board[currentSquare] =
_grid[squareToIndex[currentSquare]] = Piece.noPiece;
currentSquare = s;
int n = addMills(currentSquare);