flutter: 解决 potison fen moves 的 mvoes 生成结果有时带吃子着法的问题

This commit is contained in:
Calcitem 2020-12-05 10:55:41 +08:00
parent 5a93e0d194
commit a75619b8e5
1 changed files with 12 additions and 3 deletions

View File

@ -1494,16 +1494,19 @@ class Position {
}
String movesSinceLastRemove() {
//
int i;
String moves = "";
int posAfterLastRemove = 0;
print("recorder.movesCount = ${recorder.movesCount}");
for (int i = recorder.movesCount - 1; i >= 0; i--) {
for (i = recorder.movesCount - 1; i >= 0; i--) {
//if (recorder.moveAt(i).type == MoveType.remove) break;
if (recorder.moveAt(i).move[0] == '-') break;
posAfterLastRemove = i;
}
if (i >= 0) {
posAfterLastRemove = i + 1;
}
print("[movesSinceLastRemove] posAfterLastRemove = $posAfterLastRemove");
@ -1514,6 +1517,12 @@ class Position {
print("moves = $moves");
var idx = moves.indexOf('-(');
if (idx != -1) {
print("moves[$idx] is -(");
assert(false);
}
return moves.length > 0 ? moves.substring(1) : '';
}