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

Merge branch '11-add-a-target-moves-count' into 'master'

Resolve "Add a "target" moves count"

Closes #11

See merge request !9
parents c610a9b0 68d97b10
Branches
Tags Release_0.0.6_6
1 merge request!9Resolve "Add a "target" moves count"
Pipeline #2736 passed
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.5
app.versionCode=5
app.versionName=0.0.6
app.versionCode=6
......@@ -55,6 +55,14 @@ class Game {
color: Colors.black,
),
),
Text(
'(max: ' + myProvider.maxMovesCount.toString() + ')',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: Colors.grey,
),
),
]
),
Column(
......
......@@ -22,6 +22,7 @@ class Data extends ChangeNotifier {
int _boardSize = 0;
int _colorsCount = 0;
int _movesCount = 0;
int _maxMovesCount = 0;
List _cells = [];
int _progress = 0;
......@@ -140,6 +141,11 @@ class Data extends ChangeNotifier {
updateMovesCount(movesCount + 1);
}
int get maxMovesCount => _maxMovesCount;
void updateMaxMovesCount(int maxMovesCount) {
_maxMovesCount = maxMovesCount;
}
int get progress => _progress;
int get progressTotal => _progressTotal;
int get progressDelta => _progressDelta;
......@@ -176,6 +182,7 @@ class Data extends ChangeNotifier {
_gameIsRunning = false;
_gameWon = false;
_movesCount = 0;
_maxMovesCount = 0;
_progress = 0;
notifyListeners();
}
......
......@@ -39,11 +39,19 @@ class BoardUtils {
myProvider.resetGame();
myProvider.updateCells(grid);
myProvider.updateMaxMovesCount(computeMaxMovesCountLimit(myProvider));
int initProgress = BoardUtils.getSiblingFillableCells(myProvider, 0, 0, [[0, 0]]).length;
myProvider.updateProgress(initProgress);
}
static int computeMaxMovesCountLimit(myProvider) {
int boardSize = myProvider.boardSize;
int colorsCount = myProvider.colorsCount;
return (30 * (boardSize * colorsCount) / (17 * 6)).round();
}
static fillBoardFromFirstCell(Data myProvider, int value) {
List cellsToFill = BoardUtils.getSiblingFillableCells(myProvider, 0, 0, [[0, 0]]);
int progressBeforeMove = cellsToFill.length;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment