flutter: 完成 updateScore() 函数
This commit is contained in:
parent
37cd709ff0
commit
96df3db067
|
@ -67,9 +67,7 @@ class Position {
|
|||
Phase phase = Phase.none;
|
||||
Act action = Act.none;
|
||||
|
||||
int scoreBlack = 0;
|
||||
int scoreWhite = 0;
|
||||
int scoreDraw = 0;
|
||||
Map<String, int> score = {Color.black: 0, Color.white: 0, Color.draw: 0};
|
||||
|
||||
int currentSquare;
|
||||
int nPlayed = 0;
|
||||
|
@ -143,9 +141,7 @@ class Position {
|
|||
phase = other.phase;
|
||||
action = other.action;
|
||||
|
||||
scoreBlack = other.scoreBlack;
|
||||
scoreWhite = other.scoreWhite;
|
||||
scoreDraw = other.scoreDraw;
|
||||
score = other.score;
|
||||
|
||||
currentSquare = other.currentSquare;
|
||||
nPlayed = other.nPlayed;
|
||||
|
@ -158,8 +154,6 @@ class Position {
|
|||
|
||||
String sideToMove() => _sideToMove;
|
||||
|
||||
void updateScore() {}
|
||||
|
||||
void setSideToMove(String color) {
|
||||
_sideToMove = color;
|
||||
}
|
||||
|
@ -735,6 +729,17 @@ class Position {
|
|||
winner = w;
|
||||
}
|
||||
|
||||
void updateScore() {
|
||||
if (phase == Phase.gameOver) {
|
||||
if (winner == Color.draw) {
|
||||
score[Color.draw]++;
|
||||
return;
|
||||
}
|
||||
|
||||
score[winner]++;
|
||||
}
|
||||
}
|
||||
|
||||
bool checkGameOverCondition() {
|
||||
if (phase == Phase.ready || phase == Phase.gameOver) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue