flutter: Add tip for mayFly

This commit is contained in:
Calcitem 2021-05-02 07:58:24 +08:00
parent 04b05a9ff7
commit 13963a6a9b
2 changed files with 13 additions and 2 deletions

View File

@ -37,7 +37,7 @@
"tipThreePiecesInLine": "三颗棋子排成一线",
"tipSelectPieceToMove": "请选择要移动的己方棋子",
"tipHaveThreePiecesLeft": "只剩下3颗棋子了",
"tipCanMoveToAnyPoint": "可以移动棋子到任意空位",
"tipCanMoveToAnyPoint": "可子到任意空位",
"blackWin": "黑方胜",
"whiteWin": "白方胜",
"won": "胜",

View File

@ -27,6 +27,7 @@ import 'package:sanmill/generated/l10n.dart';
import 'package:sanmill/main.dart';
import 'package:sanmill/mill/game.dart';
import 'package:sanmill/mill/position.dart';
import 'package:sanmill/mill/rule.dart';
import 'package:sanmill/mill/types.dart';
import 'package:sanmill/services/audios.dart';
import 'package:sanmill/style/app_theme.dart';
@ -208,9 +209,19 @@ class _GamePageState extends State<GamePage> with RouteAware {
Game.instance.select(index);
ret = true;
print("selectPiece: [$sq]");
var us = Game.instance.sideToMove;
if (position.phase == Phase.moving &&
rule.mayFly &&
Game.instance.position.pieceOnBoardCount[us] == 3) {
print("May fly.");
if (mounted) {
changeStatus(S.of(context).tipCanMoveToAnyPoint);
}
} else if (mounted) {
changeStatus(S.of(context).tipPlace);
}
break;
case -2:
Audios.playTone(Audios.illegalSoundId);