Merge remote-tracking branch 'origin/master' into gh-pages

This commit is contained in:
synth-ruiner 2015-03-10 10:27:34 +00:00
commit c2f36da8cb
1 changed files with 31 additions and 29 deletions

View File

@ -284,43 +284,31 @@
return row; return row;
} }
$.fn.check = function() {
$.fn.checkRow = function() {
//unclicked tiles //unclicked tiles
if ($(this).children('li:not(.revealed):not(.flagged)').length > 0) { if ($(this).filter('li:not(.revealed):not(.flagged)').length > 0) {
return false; return false;
} }
//incorrectly flagged tiles //incorrectly flagged tiles
if ($(this).children('li.flagged:not(.mine)').length > 0) { if ($(this).filter('li.flagged:not(.mine)').length > 0) {
return false; return false;
} }
//clicked mines //clicked mines
if ($(this).children('li.revealed.mine').length > 0) { if ($(this).filter('li.revealed.mine').length > 0) {
return false; return false;
} }
return true; return true;
} }
$.fn.checkRow = function() {
return $(this).children().check();
}
$.fn.checkColumn = function() { $.fn.checkColumn = function() {
//unclicked tiles return $(this).column().check();
if ($(this).column().filter(':not(.revealed):not(.flagged)').length > 0) {
return false;
}
//incorrectly flagged tiles
if ($(this).column().filter('.flagged:not(.mine)').length > 0) {
return false;
}
//clicked mines
if ($(this).column().filter('.revealed.mine').length > 0) {
return false;
}
return true;
} }
window.removeClearedRows = function() { window.removeClearedRows = function() {
@ -355,22 +343,30 @@
columnsToRemove.each(function() { columnsToRemove.each(function() {
score += $(this).column().filter('.mine').length; score += $(this).column().filter('.mine').length;
$(this).addClass("removing"); $(this).column().addClass("removing");
$(this).column().animate({width: 0, borderRadius: 0, padding: 0}, "slow", function() { //animation for top row + deletion
$(this).parent().append(newTile()); // then animation for others?
$(this).remove(); //...
$(this).animate({width: 0, borderRadius: 0, padding: 0}, "slow", function() {
$(this).column().remove();
$('ul').each(function() {
$(this).append(newTile());
});
refreshMineCounts(); refreshMineCounts();
//click blank tiles //click blank tiles
$('li.revealed:not(.mine):empty').mouseup(); $('li.revealed:not(.mine, .removing):empty').mouseup();
}); });
$(this).column().animate({width: 0, borderRadius: 0, padding: 0}, "slow");
}); });
} }
function refreshMineCounts() { function refreshMineCounts() {
$('li.revealed:not(.mine)').each(function() { $('ul:not(.removing) li.revealed:not(.mine, .removing)').each(function() {
var mineCount = $(this).countMinesText(); var mineCount = $(this).countMinesText();
$(this).text(mineCount); $(this).text(mineCount);
@ -409,6 +405,12 @@
); );
} }
$.fn.updateMineCount = function() {
$(this).text(
$(this).countMinesText
);
}
$.fn.rowScore = function() { $.fn.rowScore = function() {
return $(this).children('.mine').length; return $(this).children('.mine').length;
} }
@ -600,7 +602,7 @@
clearTimeout(timeout); clearTimeout(timeout);
} }
$(document).on("contextmenu", "li", function(event) { $(document).on("contextmenu", "*", function(event) {
event.preventDefault(); event.preventDefault();
}); });
@ -646,7 +648,7 @@
} }
removeClearedRows(); removeClearedRows();
//removeClearedColumns(); removeClearedColumns();
checkGameOver(); checkGameOver();
updateScore(); updateScore();