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

Merge branch '5-count-moves' into 'master'

Resolve "Count moves"

Closes #5

See merge request !4
parents 8b033e15 e4afe613
Branches
Tags Release_0.0.4_4
1 merge request!4Resolve "Count moves"
Pipeline #2728 passed
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.3
app.versionCode=3
app.versionName=0.0.4
app.versionCode=4
......@@ -17,6 +17,18 @@ class Game {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: 8),
Container(
child: Text(
myProvider.movesCount.toString(),
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.w600,
color: Colors.black,
),
),
),
SizedBox(height: 2),
Expanded(
child: Board.buildGameBoard(myProvider),
),
......
......@@ -21,6 +21,7 @@ class Data extends ChangeNotifier {
bool _gameWon = false;
int _boardSize = 0;
int _colorsCount = 0;
int _movesCount = 0;
List _cells = [];
String get level => _level;
......@@ -125,6 +126,15 @@ class Data extends ChangeNotifier {
notifyListeners();
}
int get movesCount => _movesCount;
void updateMovesCount(int movesCount) {
_movesCount = movesCount;
notifyListeners();
}
void incrementMovesCount() {
updateMovesCount(movesCount + 1);
}
bool get gameIsRunning => _gameIsRunning;
void updateGameIsRunning(bool gameIsRunning) {
_gameIsRunning = gameIsRunning;
......@@ -144,6 +154,7 @@ class Data extends ChangeNotifier {
void resetGame() {
_gameIsRunning = false;
_gameWon = false;
_movesCount = 0;
notifyListeners();
}
......
......@@ -47,6 +47,8 @@ class BoardUtils {
for (var cellIndex = 0; cellIndex < cellsToFill.length; cellIndex++) {
myProvider.updateCellValue(cellsToFill[cellIndex][1], cellsToFill[cellIndex][0], value);
}
myProvider.incrementMovesCount();
}
static List getSiblingFillableCells(Data myProvider, row, col, siblingCells) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment