flutter: Do not add difficulty level if level is 20

This commit is contained in:
Calcitem 2021-05-02 10:43:41 +08:00
parent 447d7c2b87
commit 8de5fe6515
1 changed files with 13 additions and 7 deletions

View File

@ -556,6 +556,17 @@ class _GamePageState extends State<GamePage> with RouteAware {
if (result == GameResult.win &&
Game.instance.engineType == EngineType.humanVsAi) {
bool isTopLevel = (Config.skillLevel == 20); // TODO: 20
var contentStr = getGameOverReasonString(
Game.instance.position.gameOverReason, Game.instance.position.winner);
if (!isTopLevel) {
contentStr += "\n\n" +
S.of(context).challengeHarderLevel +
(Config.skillLevel + 1).toString() +
"!";
}
showDialog(
context: context,
barrierDismissible: true,
@ -563,17 +574,12 @@ class _GamePageState extends State<GamePage> with RouteAware {
return AlertDialog(
title: Text(dialogTitle,
style: TextStyle(color: AppTheme.dialogTitleColor)),
content: Text(getGameOverReasonString(
Game.instance.position.gameOverReason,
Game.instance.position.winner) +
S.of(context).challengeHarderLevel +
(Config.skillLevel + 1).toString() +
"!"),
content: Text(contentStr),
actions: <Widget>[
TextButton(
child: Text(S.of(context).yes),
onPressed: () {
Config.skillLevel++;
if (!isTopLevel) Config.skillLevel++;
Config.save();
Navigator.of(context).pop();
}),