diff --git a/index.html b/index.html
index 9cee94f..e1e3459 100644
--- a/index.html
+++ b/index.html
@@ -272,6 +272,18 @@
}
}
+ function newRow() {
+ var row = '
';
+
+ for (var i = 0; i < gameBoardWidth; i++) {
+ row += newTile();
+ };
+
+ row += '
';
+
+ return row;
+ }
+
$.fn.checkRow = function() {
//unclicked tiles
@@ -316,30 +328,22 @@
return $(this).checkRow();
});
- var numRowsToRemove = rowsToRemove.length;
-
- if (numRowsToRemove == 0) return;
-
- rowsToRemove.addClass("removing");
-
rowsToRemove.each(function() {
score += $(this).children('.mine').length;
- });
- rowsToRemove.slideUp("slow", function() {
- $(this).remove();
- //add new row on bottom
+ $(this).addClass("removing");
- $('#game').append('');
+ $(this).slideUp("slow", function() {
+ $(this).remove();
- for (var i = 0; i < gameBoardWidth; i++) {
- $('#game ul').last().append(newTile());
- }
+ //add new row on bottom
+ $('#game').append(newRow());
- refreshMineCounts();
+ refreshMineCounts();
- //click blank tiles
- $('li.revealed:not(.mine):empty').mouseup();
+ //click blank tiles
+ $('li.revealed:not(.mine):empty').mouseup();
+ });
});
}
@@ -348,15 +352,11 @@
return $(this).checkColumn();
});
- if (columnsToRemove.length == 0) return;
-
- columnsToRemove.addClass("removing");
-
columnsToRemove.each(function() {
score += $(this).column().filter('.mine').length;
- });
- columnsToRemove.each(function() {
+ $(this).addClass("removing");
+
$(this).column().animate({width: 0, borderRadius: 0, padding: 0}, "slow", function() {
$(this).parent().append(newTile());
$(this).remove();
@@ -446,15 +446,7 @@
}
$.fn.countMinesAdjacent = function() {
- var count = 0;
-
- $.each($(this).getAdjacentTiles(), function() {
- if ($(this).isMine()) {
- count++;
- }
- });
-
- return count;
+ return $(this).getAdjacentTiles().filter('.mine').length;
}
$.fn.getAdjacentTiles = function() {