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

Remove flag on cell when explored

parent d641dceb
No related branches found
No related tags found
1 merge request!6Resolve "Remove flag on cell when explored"
Pipeline #1798 passed
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.4
app.versionCode=4
app.versionName=0.0.5
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 {
void setCellAsExplored(int row, int col) {
_cells[row][col].isExplored = true;
_cells[row][col].isMarked = false;
if (_cells[row][col].isMined) {
_cells[row][col].isExploded = true;
};
......
......@@ -4,21 +4,42 @@ import '../provider/data.dart';
class BoardUtils {
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('');
String line = '--';
for (var i = 0; i < cells[0].length; i++) {
line += '-';
}
print(line);
print(line + ' ' + line);
for (var rowIndex = 0; rowIndex < cells.length; rowIndex++) {
String row = '|';
String currentLine = '';
String solvedLine = '';
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('');
}
......@@ -169,6 +190,8 @@ class BoardUtils {
int sizeHorizontal = cells.length;
int sizeVertical = cells[0].length;
printGrid(cells);
myProvider.updateGameWin(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