flutter: 解决 score 经常被清空的问题

This commit is contained in:
Calcitem 2020-11-30 01:05:38 +08:00
parent e9a4d80918
commit ef06033e16
1 changed files with 4 additions and 3 deletions

View File

@ -176,7 +176,7 @@ class Position {
} }
Position() { Position() {
score[Color.black] = score[Color.white] = score[Color.draw] = nPlayed = 0; //score[Color.black] = score[Color.white] = score[Color.draw] = nPlayed = 0;
init(); init();
} }
@ -715,8 +715,6 @@ class Position {
setGameOver(Color.opponent(loser), GameOverReason.loseReasonResign); setGameOver(Color.opponent(loser), GameOverReason.loseReasonResign);
updateScore();
return true; return true;
} }
@ -729,6 +727,7 @@ class Position {
gameOverReason = reason; gameOverReason = reason;
winner = w; winner = w;
print("Game over, $w win, becase of $reason"); print("Game over, $w win, becase of $reason");
updateScore();
} }
void updateScore() { void updateScore() {
@ -1502,6 +1501,8 @@ class Position {
moves += " ${recorder.moveAt(i).move}"; moves += " ${recorder.moveAt(i).move}";
} }
print("moves = $moves");
return moves.length > 0 ? moves.substring(1) : ''; return moves.length > 0 ? moves.substring(1) : '';
} }