Skip to content
Snippets Groups Projects
Commit bee0c411 authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Add "guesses count" indicator

parent 0cc7a543
No related branches found
No related tags found
1 merge request!27Resolve "Add "guesses count""
Pipeline #5868 passed
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=1.0.23 app.versionName=1.0.24
app.versionCode=24 app.versionCode=25
Add "guesses count" indicator.
Ajout d'un compteur de coups.
...@@ -36,7 +36,7 @@ class GameCubit extends HydratedCubit<GameState> { ...@@ -36,7 +36,7 @@ class GameCubit extends HydratedCubit<GameState> {
// Base data // Base data
board: state.currentGame.board, board: state.currentGame.board,
// Game data // Game data
movesCount: state.currentGame.movesCount, guessesCount: state.currentGame.guessesCount,
pairsFound: state.currentGame.pairsFound, pairsFound: state.currentGame.pairsFound,
); );
game.dump(); game.dump();
...@@ -130,6 +130,9 @@ class GameCubit extends HydratedCubit<GameState> { ...@@ -130,6 +130,9 @@ class GameCubit extends HydratedCubit<GameState> {
} }
} }
state.currentGame.guessesCount++;
refresh();
// timer + check pair + unselect // timer + check pair + unselect
Timer(const Duration(seconds: 2), () { Timer(const Duration(seconds: 2), () {
if (hasSameValue) { if (hasSameValue) {
...@@ -137,12 +140,11 @@ class GameCubit extends HydratedCubit<GameState> { ...@@ -137,12 +140,11 @@ class GameCubit extends HydratedCubit<GameState> {
final int itemValue = state.currentGame.board.tiles[selectedTilesIndexes[0]].value; final int itemValue = state.currentGame.board.tiles[selectedTilesIndexes[0]].value;
state.currentGame.pairsFound.add(itemValue); state.currentGame.pairsFound.add(itemValue);
}
state.currentGame.movesCount++;
refresh(); refresh();
}
state.currentGame.isFinished = state.currentGame.gameWon; state.currentGame.isFinished = state.currentGame.gameWon;
refresh();
unselectAllTiles(); unselectAllTiles();
allowInteractions(true); allowInteractions(true);
......
...@@ -28,7 +28,7 @@ class Game { ...@@ -28,7 +28,7 @@ class Game {
required this.board, required this.board,
// Game data // Game data
required this.movesCount, required this.guessesCount,
required this.pairsFound, required this.pairsFound,
}); });
...@@ -47,7 +47,7 @@ class Game { ...@@ -47,7 +47,7 @@ class Game {
final Board board; final Board board;
// Game data // Game data
int movesCount; int guessesCount;
List<int> pairsFound = []; List<int> pairsFound = [];
factory Game.createNull() { factory Game.createNull() {
...@@ -58,7 +58,7 @@ class Game { ...@@ -58,7 +58,7 @@ class Game {
// Base data // Base data
board: Board.createNull(), board: Board.createNull(),
// Game data // Game data
movesCount: 0, guessesCount: 0,
pairsFound: [], pairsFound: [],
); );
} }
...@@ -83,7 +83,7 @@ class Game { ...@@ -83,7 +83,7 @@ class Game {
// Base data // Base data
board: board, board: board,
// Game data // Game data
movesCount: 0, guessesCount: 0,
pairsFound: [], pairsFound: [],
); );
} }
...@@ -111,7 +111,7 @@ class Game { ...@@ -111,7 +111,7 @@ class Game {
printlog(' Base data'); printlog(' Base data');
board.dump(); board.dump();
printlog(' Game data'); printlog(' Game data');
printlog(' movesCount: $movesCount'); printlog(' guessesCount: $guessesCount');
printlog(' pairsFound: $pairsFound'); printlog(' pairsFound: $pairsFound');
printlog(''); printlog('');
} }
...@@ -135,7 +135,7 @@ class Game { ...@@ -135,7 +135,7 @@ class Game {
// Base data // Base data
'board': board.toJson(), 'board': board.toJson(),
// Game data // Game data
'movesCount': movesCount, 'guessesCount': guessesCount,
'pairsFound': pairsFound, 'pairsFound': pairsFound,
}; };
} }
......
...@@ -13,7 +13,14 @@ class GameTopWidget extends StatelessWidget { ...@@ -13,7 +13,14 @@ class GameTopWidget extends StatelessWidget {
builder: (BuildContext context, GameState gameState) { builder: (BuildContext context, GameState gameState) {
final Game currentGame = gameState.currentGame; final Game currentGame = gameState.currentGame;
return const Text(''); return Text(
currentGame.guessesCount.toString(),
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.primary,
),
);
}, },
); );
} }
......
...@@ -3,7 +3,7 @@ description: A simple and classic memory game. ...@@ -3,7 +3,7 @@ description: A simple and classic memory game.
publish_to: "none" publish_to: "none"
version: 1.0.23+24 version: 1.0.24+25
environment: environment:
sdk: "^3.0.0" sdk: "^3.0.0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment