diff --git a/android/gradle.properties b/android/gradle.properties index f93f18117d4c15658c5fde830d19bde8e341f150..fe70351baba23052bea76e9ed912c871addf8cdd 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -app.versionName=0.1.0 -app.versionCode=30 +app.versionName=0.1.1 +app.versionCode=31 diff --git a/fastlane/metadata/android/en-US/changelogs/31.txt b/fastlane/metadata/android/en-US/changelogs/31.txt new file mode 100644 index 0000000000000000000000000000000000000000..120738ee1134ee30e2961e664795fab9e23a6249 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/31.txt @@ -0,0 +1 @@ +Fix game end. diff --git a/fastlane/metadata/android/fr-FR/changelogs/31.txt b/fastlane/metadata/android/fr-FR/changelogs/31.txt new file mode 100644 index 0000000000000000000000000000000000000000..d7891f0af70d51260244809eb5deb16ef47fbbe4 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/31.txt @@ -0,0 +1 @@ +Corrections sur fin de partie. diff --git a/lib/cubit/game_cubit.dart b/lib/cubit/game_cubit.dart index d20827451e20451c4216185b43bc749221696b2a..b11d40002359305d8197527c30257802165a66af 100644 --- a/lib/cubit/game_cubit.dart +++ b/lib/cubit/game_cubit.dart @@ -2,7 +2,6 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:hydrated_bloc/hydrated_bloc.dart'; -import 'package:momomotus/config/default_game_settings.dart'; import 'package:momomotus/models/game/game.dart'; import 'package:momomotus/models/settings/settings_game.dart'; import 'package:momomotus/models/settings/settings_global.dart'; @@ -30,7 +29,6 @@ class GameCubit extends HydratedCubit<GameState> { // State isRunning: state.currentGame.isRunning, isStarted: state.currentGame.isStarted, - isFinished: state.currentGame.isFinished, animationInProgress: state.currentGame.animationInProgress, // Base data word: state.currentGame.word, @@ -73,7 +71,6 @@ class GameCubit extends HydratedCubit<GameState> { void deleteSavedGame() { state.currentGame.isRunning = false; - state.currentGame.isFinished = true; refresh(); } @@ -171,15 +168,6 @@ class GameCubit extends HydratedCubit<GameState> { return tips; } - bool isGameFinished() { - if (state.currentGame.foundWord || - (state.currentGame.guesses.length >= DefaultGameSettings.maxGuessesCount)) { - return true; - } - - return false; - } - @override GameState? fromJson(Map<String, dynamic> json) { final Game currentGame = json['currentGame'] as Game; diff --git a/lib/models/game/game.dart b/lib/models/game/game.dart index 347702273e31c3b4ebb9fb3116cd71293916fb14..aa36706f01cadb0d2a798bcfcd5213d8bee2a7a4 100644 --- a/lib/models/game/game.dart +++ b/lib/models/game/game.dart @@ -1,3 +1,4 @@ +import 'package:momomotus/config/default_game_settings.dart'; import 'package:momomotus/data/fetch_data_helper.dart'; import 'package:momomotus/models/settings/settings_game.dart'; import 'package:momomotus/models/settings/settings_global.dart'; @@ -12,7 +13,6 @@ class Game { // State this.isRunning = false, this.isStarted = false, - this.isFinished = false, this.animationInProgress = false, // Base data @@ -33,7 +33,6 @@ class Game { // State bool isRunning; bool isStarted; - bool isFinished; bool animationInProgress; // Base data @@ -97,6 +96,13 @@ class Game { bool get canBeResumed => isStarted && !isFinished; bool get gameWon => isRunning && isStarted && isFinished; + bool get isFinished { + if (foundWord || (guesses.length >= DefaultGameSettings.maxGuessesCount)) { + return true; + } + + return false; + } bool checkWordIsValid(String candidate) { final int length = int.parse(gameSettings.length); diff --git a/lib/ui/game/game_end.dart b/lib/ui/game/game_end.dart index eb53af9ca8d7023935e7897fab28756c3e980c13..6c1c8b59be292caabc5879ac534226045ddf5089 100644 --- a/lib/ui/game/game_end.dart +++ b/lib/ui/game/game_end.dart @@ -20,31 +20,27 @@ class GameEndWidget extends StatelessWidget { fit: BoxFit.fill, ); - return Container( - margin: const EdgeInsets.all(2), - padding: const EdgeInsets.all(2), - child: Table( - defaultColumnWidth: const IntrinsicColumnWidth(), - children: [ - TableRow( - children: [ - Column( - children: [decorationImage], - ), - Column( - children: [ - currentGame.animationInProgress == true - ? decorationImage - : const QuitGameButton() - ], - ), - Column( - children: [decorationImage], - ), - ], - ), - ], - ), + return Table( + defaultColumnWidth: const IntrinsicColumnWidth(), + children: [ + TableRow( + children: [ + Column( + children: [decorationImage], + ), + Column( + children: [ + currentGame.animationInProgress == true + ? decorationImage + : const QuitGameButton() + ], + ), + Column( + children: [decorationImage], + ), + ], + ), + ], ); }, ); diff --git a/lib/ui/widgets/actions/button_game_quit.dart b/lib/ui/widgets/actions/button_game_quit.dart index 3c018f02149536936b9bd8fd66a149cf8b9ce974..c2da533f8326ce6cffe3b4b7c7dc3c3dab7e77b2 100644 --- a/lib/ui/widgets/actions/button_game_quit.dart +++ b/lib/ui/widgets/actions/button_game_quit.dart @@ -8,7 +8,7 @@ class QuitGameButton extends StatelessWidget { @override Widget build(BuildContext context) { - return TextButton( + return ElevatedButton( child: const Image( image: AssetImage('assets/ui/button_back.png'), fit: BoxFit.fill, diff --git a/lib/ui/widgets/game/game_board.dart b/lib/ui/widgets/game/game_board.dart index 859cbb0cafe5eeb7839d5aa4b5068bed1a182843..81defffc542a208285b2067bec918575c057553a 100644 --- a/lib/ui/widgets/game/game_board.dart +++ b/lib/ui/widgets/game/game_board.dart @@ -44,12 +44,12 @@ class GameBoardWidget extends StatelessWidget { cellTip = tips[colIndex]; } - final bool hasFocus = (!currentGame.gameWon) && + final bool hasFocus = (!currentGame.foundWord) && (lineIndex == guesses.length) && (colIndex == word.length); final String foundLetter = - ((!currentGame.gameWon) && (lineIndex == guesses.length)) + ((!currentGame.foundWord) && (lineIndex == guesses.length)) ? currentGame.foundLetters.substring(colIndex, colIndex + 1) : ' '; @@ -85,7 +85,8 @@ class GameBoardWidget extends StatelessWidget { } } - if (gameCubit.isGameFinished() && !currentGame.gameWon) { + // Failed -> show word + if (currentGame.isFinished && !currentGame.gameWon) { gameBoard.add(Text( currentGame.word, style: const TextStyle( diff --git a/pubspec.yaml b/pubspec.yaml index 1196902b1bad49e310bebce1c4fd23b57163c67e..45a416adfa3373e48070e7dae1fea1802b6a83fe 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A motus-like game application. publish_to: "none" -version: 0.1.0+30 +version: 0.1.1+31 environment: sdk: "^3.0.0"