Working column clearing + other fixes
right-click will no longer bring up context menu, ever various performance enhancements and refactoring
This commit is contained in:
parent
52c39c0347
commit
101ae1867f
60
index.html
60
index.html
|
@ -284,43 +284,31 @@
|
|||
return row;
|
||||
}
|
||||
|
||||
|
||||
$.fn.checkRow = function() {
|
||||
$.fn.check = function() {
|
||||
//unclicked tiles
|
||||
if ($(this).children('li:not(.revealed):not(.flagged)').length > 0) {
|
||||
if ($(this).filter('li:not(.revealed):not(.flagged)').length > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//incorrectly flagged tiles
|
||||
if ($(this).children('li.flagged:not(.mine)').length > 0) {
|
||||
if ($(this).filter('li.flagged:not(.mine)').length > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//clicked mines
|
||||
if ($(this).children('li.revealed.mine').length > 0) {
|
||||
if ($(this).filter('li.revealed.mine').length > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$.fn.checkRow = function() {
|
||||
return $(this).children().check();
|
||||
}
|
||||
|
||||
$.fn.checkColumn = function() {
|
||||
//unclicked tiles
|
||||
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;
|
||||
return $(this).column().check();
|
||||
}
|
||||
|
||||
window.removeClearedRows = function() {
|
||||
|
@ -355,22 +343,30 @@
|
|||
columnsToRemove.each(function() {
|
||||
score += $(this).column().filter('.mine').length;
|
||||
|
||||
$(this).addClass("removing");
|
||||
$(this).column().addClass("removing");
|
||||
|
||||
$(this).column().animate({width: 0, borderRadius: 0, padding: 0}, "slow", function() {
|
||||
$(this).parent().append(newTile());
|
||||
$(this).remove();
|
||||
//animation for top row + deletion
|
||||
// then animation for others?
|
||||
//...
|
||||
|
||||
$(this).animate({width: 0, borderRadius: 0, padding: 0}, "slow", function() {
|
||||
$(this).column().remove();
|
||||
$('ul').each(function() {
|
||||
$(this).append(newTile());
|
||||
});
|
||||
|
||||
refreshMineCounts();
|
||||
|
||||
//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() {
|
||||
$('li.revealed:not(.mine)').each(function() {
|
||||
$('ul:not(.removing) li.revealed:not(.mine, .removing)').each(function() {
|
||||
var mineCount = $(this).countMinesText();
|
||||
|
||||
$(this).text(mineCount);
|
||||
|
@ -409,6 +405,12 @@
|
|||
);
|
||||
}
|
||||
|
||||
$.fn.updateMineCount = function() {
|
||||
$(this).text(
|
||||
$(this).countMinesText
|
||||
);
|
||||
}
|
||||
|
||||
$.fn.rowScore = function() {
|
||||
return $(this).children('.mine').length;
|
||||
}
|
||||
|
@ -600,7 +602,7 @@
|
|||
clearTimeout(timeout);
|
||||
}
|
||||
|
||||
$(document).on("contextmenu", "li", function(event) {
|
||||
$(document).on("contextmenu", "*", function(event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
|
@ -646,7 +648,7 @@
|
|||
}
|
||||
|
||||
removeClearedRows();
|
||||
//removeClearedColumns();
|
||||
removeClearedColumns();
|
||||
checkGameOver();
|
||||
|
||||
updateScore();
|
||||
|
|
Loading…
Reference in New Issue