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

Merge branch '23-fix-delete-cells-on-top-line' into 'master'

Resolve "Fix delete cells on top line"

Closes #23

See merge request !20
parents ed890e3a 1f1de442
No related branches found
No related tags found
1 merge request!20Resolve "Fix delete cells on top line"
Pipeline #4962 passed
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.16
app.versionCode=16
app.versionName=0.0.17
app.versionCode=17
Fix delete cells on top line.
Correction sur la suppression de cellules sur la première ligne.
......@@ -30,4 +30,6 @@ class DefaultGameSettings {
return [];
}
static int blockMinimumCellsCount = 3;
}
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:jeweled/config/default_game_settings.dart';
import 'package:jeweled/models/game.dart';
import 'package:jeweled/models/cell_location.dart';
......@@ -109,7 +110,7 @@ class GameCubit extends HydratedCubit<GameState> {
if (cellValue != null) {
List<CellLocation> blockCells = currentGame.getSiblingCells(tappedCellLocation, []);
if (blockCells.length >= 3) {
if (blockCells.length >= DefaultGameSettings.blockMinimumCellsCount) {
this.deleteBlock(blockCells);
this.increaseMovesCount();
this.increaseScore(getScoreFromBlock(blockCells.length));
......
......@@ -79,14 +79,20 @@ class _GameBoard extends State<GameBoard> with TickerProviderStateMixin {
});
// Build animation for each cell to move
bool needAnimation = false;
cellsToRemove.forEach((cellToRemove) {
for (int i = 0; i < cellToRemove.row; i++) {
final int stepsCount = stepsDownCounts[(cellToRemove.row - i) - 1][cellToRemove.col];
this.animations[(cellToRemove.row - i) - 1][cellToRemove.col] = animation(stepsCount);
needAnimation = true;
}
});
controller.forward().orCancel;
if (!needAnimation) {
gameCubit.postAnimate();
}
}
@override
......@@ -104,16 +110,16 @@ class _GameBoard extends State<GameBoard> with TickerProviderStateMixin {
return GestureDetector(
onTapUp: (details) {
bool canRemoveCell = true;
bool animationInProgress = false;
animations.forEach((row) {
row.forEach((cell) {
if (cell != null) {
canRemoveCell = false;
animationInProgress = true;
}
});
});
if (canRemoveCell) {
if (!animationInProgress) {
final double xTap = details.localPosition.dx;
final double yTap = details.localPosition.dy;
final int col = xTap ~/ (displayWidth / currentGame.settings.boardSize);
......
......@@ -3,7 +3,7 @@ description: Jeweled Game
publish_to: 'none'
version: 0.0.16+16
version: 0.0.17+17
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