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

Display word if not found when game ends

parent 21454327
No related branches found
No related tags found
1 merge request!25Resolve "Display word when game ends"
Pipeline #3580 passed
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=0.0.20 app.versionName=0.0.21
app.versionCode=20 app.versionCode=21
Display word if not found when the game ends
Affichage du mot à deviner s'il n'est pas trouvé à la fin de la partie
...@@ -102,6 +102,17 @@ class Board { ...@@ -102,6 +102,17 @@ class Board {
tableRows.add(TableRow(children: tableCells)); tableRows.add(TableRow(children: tableCells));
} }
List<Widget> gameBoard = [
Table(
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
border: TableBorder.all(
color: Colors.white,
style: BorderStyle.none,
),
children: tableRows,
),
];
double horizontalMargins = 20; double horizontalMargins = 20;
if (wordLength < 6) { if (wordLength < 6) {
horizontalMargins = 40; horizontalMargins = 40;
...@@ -110,16 +121,21 @@ class Board { ...@@ -110,16 +121,21 @@ class Board {
} }
} }
if (myProvider.isGameFinished() && !myProvider.gameWon) {
gameBoard.add(Text(
myProvider.word,
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.bold,
),
));
}
return Container( return Container(
margin: EdgeInsets.symmetric(horizontal: horizontalMargins), margin: EdgeInsets.symmetric(horizontal: horizontalMargins),
padding: EdgeInsets.all(2), padding: EdgeInsets.all(2),
child: Table( child: Column(
defaultVerticalAlignment: TableCellVerticalAlignment.middle, children: gameBoard,
border: TableBorder.all(
color: Colors.white,
style: BorderStyle.none,
),
children: tableRows,
), ),
); );
} }
......
...@@ -198,9 +198,7 @@ class Data extends ChangeNotifier { ...@@ -198,9 +198,7 @@ class Data extends ChangeNotifier {
} }
bool isGameFinished() { bool isGameFinished() {
print('isGameFinished'); if (_foundWord || (_guesses.length >= _maxGuessesCount)) {
if (_foundWord || (_guesses.length > (_maxGuessesCount - 1))) {
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment