flutter: 重构 showTips()

This commit is contained in:
Calcitem 2020-11-29 23:51:40 +08:00
parent e6c3122e4c
commit 0e0540ecf5
1 changed files with 14 additions and 17 deletions

View File

@ -63,23 +63,20 @@ class _GamePageState extends State<GamePage> {
void showTips() { void showTips() {
final winner = Game.shared.position.winner; final winner = Game.shared.position.winner;
switch (winner) { Map<String, String> colorWinStrings = {
case Color.nobody: Color.black: S.of(context).blackWin,
if (Game.shared.position.phase == Phase.placing) { Color.white: S.of(context).whiteWin,
changeStatus(S.of(context).tipPlace); Color.draw: S.of(context).draw
} else if (Game.shared.position.phase == Phase.moving) { };
changeStatus(S.of(context).tipMove);
} if (winner == Color.nobody) {
break; if (Game.shared.position.phase == Phase.placing) {
case Color.black: changeStatus(S.of(context).tipPlace);
changeStatus(S.of(context).blackWin); } else if (Game.shared.position.phase == Phase.moving) {
break; changeStatus(S.of(context).tipMove);
case Color.white: }
changeStatus(S.of(context).whiteWin); } else {
break; changeStatus(colorWinStrings[winner]);
case Color.draw:
changeStatus(S.of(context).draw);
break;
} }
showGameResult(winner); showGameResult(winner);