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

Merge branch '7-fix-get-previous-home' into 'master'

Resolve "Fix get previous home"

Closes #7

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