info: Show last move

This commit is contained in:
Calcitem 2021-08-30 23:01:39 +08:00
parent 4bb560c24d
commit 52d59bbb1e
No known key found for this signature in database
GPG Key ID: F2F7C29E054CFB80
5 changed files with 43 additions and 7 deletions

View File

@ -1184,5 +1184,9 @@
"sideToMove": "Wer soll umziehen",
"@sideToMove": {
"description": "Side to move"
},
"lastMove": "Letzter Zug",
"@lastMove": {
"description": "Last move"
}
}

View File

@ -1184,5 +1184,9 @@
"sideToMove": "Side to move",
"@sideToMove": {
"description": "Side to move"
}
},
"lastMove": "Last move",
"@lastMove": {
"description": "Last move"
}
}

View File

@ -1184,5 +1184,9 @@
"sideToMove": "轮到",
"@sideToMove": {
"description": "Side to move"
},
"lastMove": "最后一着",
"@lastMove": {
"description": "Last move"
}
}

View File

@ -366,6 +366,8 @@ class GameRecorder {
get movesCount => _history.length;
get lastMove => movesCount == 0 ? null : moveAt(movesCount - 1);
String buildMoveHistoryText({cols = 2}) {
if (_history.length == 0) {
return '';

View File

@ -1453,20 +1453,42 @@ class _GamePageState extends State<GamePage>
"\n"
: "";
String sideToMove = "";
String us = "";
String them = "";
if (pos.side == PieceColor.white) {
sideToMove = S.of(context).player1;
us = S.of(context).player1;
them = S.of(context).player2;
} else if (pos.side == PieceColor.black) {
sideToMove = S.of(context).player2;
us = S.of(context).player2;
them = S.of(context).player1;
}
String tip = _tip == null ? "" : _tip!;
String tip = (_tip == null || !Config.screenReaderSupport) ? "" : "\n$_tip";
String lastMove = "";
if (pos.recorder != null &&
pos.recorder.lastMove != null &&
pos.recorder.lastMove.notation != null) {
String n1 = pos.recorder.lastMove.notation;
if (n1.startsWith("x")) {
String n2 = pos.recorder.moveAt(pos.recorder.movesCount - 2).notation;
lastMove = n2 + n1;
} else {
lastMove = n1;
}
if (Config.screenReaderSupport) {
lastMove = S.of(context).lastMove + ": " + them + " " + lastMove + "\n";
} else {
lastMove = S.of(context).lastMove + ": " + lastMove + "\n";
}
}
String ret = phase +
"\n" +
lastMove +
S.of(context).sideToMove +
sideToMove +
"\n" +
us +
tip +
"\n\n" +
S.of(context).pieceCount +