fultter: putPiece() 只传递 sq 参数

This commit is contained in:
Calcitem 2020-11-15 10:27:52 +08:00
parent caa0d28560
commit 98e9d2e8c9
2 changed files with 6 additions and 2 deletions

View File

@ -157,6 +157,8 @@ class Position {
bool empty(int sq) => pieceOn(sq) == Piece.noPiece; bool empty(int sq) => pieceOn(sq) == Piece.noPiece;
String sideToMove() => _sideToMove;
void updateScore() {} void updateScore() {}
void setSideToMove(String color) { void setSideToMove(String color) {
@ -171,7 +173,7 @@ class Position {
return selectPieceSQ(makeSquare(file, rank)); return selectPieceSQ(makeSquare(file, rank));
} }
bool putPiece(var pt, int sq) { bool putPiece(int sq) {
var index = squareToIndex[sq]; var index = squareToIndex[sq];
if (sq == null) { if (sq == null) {
@ -179,6 +181,8 @@ class Position {
return false; return false;
} }
String pt = _sideToMove;
_grid[index] = pt; _grid[index] = pt;
_board[sq] = pt; _board[sq] = pt;

View File

@ -73,7 +73,7 @@ class _BattlePageState extends State<BattlePage> {
//position //position
//flag++; //flag++;
//position.putPiece(flag % 2 == 0 ? '@' : 'O', index); //position.putPiece(flag % 2 == 0 ? '@' : 'O', index);
if (position.putPiece('@', indexToSquare[index]) == false) { if (position.putPiece(indexToSquare[index]) == false) {
return; return;
} }