flutter: 重构 showTips()
This commit is contained in:
parent
e6c3122e4c
commit
0e0540ecf5
|
@ -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,
|
||||||
|
Color.white: S.of(context).whiteWin,
|
||||||
|
Color.draw: S.of(context).draw
|
||||||
|
};
|
||||||
|
|
||||||
|
if (winner == Color.nobody) {
|
||||||
if (Game.shared.position.phase == Phase.placing) {
|
if (Game.shared.position.phase == Phase.placing) {
|
||||||
changeStatus(S.of(context).tipPlace);
|
changeStatus(S.of(context).tipPlace);
|
||||||
} else if (Game.shared.position.phase == Phase.moving) {
|
} else if (Game.shared.position.phase == Phase.moving) {
|
||||||
changeStatus(S.of(context).tipMove);
|
changeStatus(S.of(context).tipMove);
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
case Color.black:
|
changeStatus(colorWinStrings[winner]);
|
||||||
changeStatus(S.of(context).blackWin);
|
|
||||||
break;
|
|
||||||
case Color.white:
|
|
||||||
changeStatus(S.of(context).whiteWin);
|
|
||||||
break;
|
|
||||||
case Color.draw:
|
|
||||||
changeStatus(S.of(context).draw);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
showGameResult(winner);
|
showGameResult(winner);
|
||||||
|
|
Loading…
Reference in New Issue