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

Merge branch '9-remove-flag-on-cell-when-explored' into 'master'

Resolve "Remove flag on cell when explored"

Closes #9

See merge request !6
parents d641dceb a4266b12
No related branches found
No related tags found
1 merge request!6Resolve "Remove flag on cell when explored"
Pipeline #1809 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.4 app.versionName=0.0.5
app.versionCode=4 app.versionCode=5
Remove flag on cell when explored.
Enlève le marquage sur les cellules parcourues.
...@@ -80,6 +80,7 @@ class Data extends ChangeNotifier { ...@@ -80,6 +80,7 @@ class Data extends ChangeNotifier {
void setCellAsExplored(int row, int col) { void setCellAsExplored(int row, int col) {
_cells[row][col].isExplored = true; _cells[row][col].isExplored = true;
_cells[row][col].isMarked = false;
if (_cells[row][col].isMined) { if (_cells[row][col].isMined) {
_cells[row][col].isExploded = true; _cells[row][col].isExploded = true;
}; };
......
...@@ -4,21 +4,42 @@ import '../provider/data.dart'; ...@@ -4,21 +4,42 @@ import '../provider/data.dart';
class BoardUtils { class BoardUtils {
static printGrid(List cells) { static printGrid(List cells) {
final String IS_MINED = 'X';
final String IS_SAFE = '.';
final String MINE_FOUND = '#';
final String WRONG_MARKED_CELL = '0';
final String EXPLORED_SAFE_CELL = '.';
final String UNKNOWN_STATE = ' ';
print(''); print('');
String line = '--'; String line = '--';
for (var i = 0; i < cells[0].length; i++) { for (var i = 0; i < cells[0].length; i++) {
line += '-'; line += '-';
} }
print(line); print(line + ' ' + line);
for (var rowIndex = 0; rowIndex < cells.length; rowIndex++) { for (var rowIndex = 0; rowIndex < cells.length; rowIndex++) {
String row = '|'; String currentLine = '';
String solvedLine = '';
for (var colIndex = 0; colIndex < cells[rowIndex].length; colIndex++) { for (var colIndex = 0; colIndex < cells[rowIndex].length; colIndex++) {
row += cells[rowIndex][colIndex].isMined ? 'X' : '.'; solvedLine += cells[rowIndex][colIndex].isMined ? IS_MINED : IS_SAFE;
String cellString = UNKNOWN_STATE;
if (cells[rowIndex][colIndex].isExplored) {
cellString = EXPLORED_SAFE_CELL;
}
if (cells[rowIndex][colIndex].isMarked) {
if (cells[rowIndex][colIndex].isMined) {
cellString = MINE_FOUND;
} else {
cellString = WRONG_MARKED_CELL;
} }
row += '|';
print(row);
} }
print(line); currentLine += cellString;
}
print('|' + currentLine + '| |' + solvedLine + '|');
}
print(line + ' ' + line);
print(''); print('');
} }
...@@ -169,6 +190,8 @@ class BoardUtils { ...@@ -169,6 +190,8 @@ class BoardUtils {
int sizeHorizontal = cells.length; int sizeHorizontal = cells.length;
int sizeVertical = cells[0].length; int sizeVertical = cells[0].length;
printGrid(cells);
myProvider.updateGameWin(false); myProvider.updateGameWin(false);
myProvider.updateGameFail(false); myProvider.updateGameFail(false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment