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

Fix collect seeds on previous cells

parent 8c0b59ae
No related branches found
No related tags found
1 merge request!6Resolve "Fix get previous home"
Pipeline #5941 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.5 app.versionName=0.0.6
app.versionCode=5 app.versionCode=6
Fix grab seeds.
Correction sur ramassage des graines.
...@@ -107,7 +107,7 @@ class GameCubit extends HydratedCubit<GameState> { ...@@ -107,7 +107,7 @@ class GameCubit extends HydratedCubit<GameState> {
refresh(); refresh();
final int lastCellIndex = await animateSeedsDistribution(cellIndex); final int lastCellIndex = await animateSeedsDistribution(cellIndex);
animateSeedsEarning(lastCellIndex); await animateSeedsEarning(lastCellIndex);
toggleCurrentPlayer(); toggleCurrentPlayer();
...@@ -148,9 +148,11 @@ class GameCubit extends HydratedCubit<GameState> { ...@@ -148,9 +148,11 @@ class GameCubit extends HydratedCubit<GameState> {
return cellIndex; return cellIndex;
} }
void animateSeedsEarning(int lastCellIndex) async { Future<int> animateSeedsEarning(int lastCellIndex) async {
printlog('animateSeedsEarning / lastCellIndex: $lastCellIndex'); printlog('animateSeedsEarning / lastCellIndex: $lastCellIndex');
int earnedSeedsCount = 0;
if (state.currentGame.isOpponentHouse(lastCellIndex)) { if (state.currentGame.isOpponentHouse(lastCellIndex)) {
final int seedsCount = state.currentGame.board.cells[lastCellIndex]; final int seedsCount = state.currentGame.board.cells[lastCellIndex];
printlog('found $seedsCount seed(s) on final house'); printlog('found $seedsCount seed(s) on final house');
...@@ -160,17 +162,21 @@ class GameCubit extends HydratedCubit<GameState> { ...@@ -160,17 +162,21 @@ class GameCubit extends HydratedCubit<GameState> {
state.currentGame.board.cells[lastCellIndex] = 0; state.currentGame.board.cells[lastCellIndex] = 0;
state.currentGame.scores[state.currentGame.currentPlayer] += seedsCount; state.currentGame.scores[state.currentGame.currentPlayer] += seedsCount;
earnedSeedsCount += seedsCount;
refresh(); refresh();
await Future.delayed(const Duration(milliseconds: 500)); await Future.delayed(const Duration(milliseconds: 500));
// (recursively) check previous cells // (recursively) check previous cells
printlog('-> dispatch to previous cell'); printlog('-> dispatch to previous cell');
animateSeedsEarning(state.currentGame.getPreviousCellIndex(lastCellIndex)); final int previousCellIndex = state.currentGame.getPreviousCellIndex(lastCellIndex);
earnedSeedsCount += await animateSeedsEarning(previousCellIndex);
} else { } else {
printlog('-> nothing to do'); printlog('-> nothing to do');
} }
} }
return earnedSeedsCount;
} }
@override @override
......
...@@ -3,7 +3,7 @@ description: Awale game ...@@ -3,7 +3,7 @@ description: Awale game
publish_to: "none" publish_to: "none"
version: 0.0.5+5 version: 0.0.6+6
environment: environment:
sdk: "^3.0.0" sdk: "^3.0.0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment