diff --git a/index.html b/index.html index f9707a5..427877d 100644 --- a/index.html +++ b/index.html @@ -468,7 +468,9 @@ $('#setup').hide(); }); - $.fn.leftClick = function() { + $.fn.leftClick = function(automated) { + if (!automated) automated = false; + //don't want first click to be a mine if (firstClick) { var x = $(this).getX(); @@ -500,9 +502,11 @@ //$(this).middleClick(); //number of flags matches number of adjacent mines - $(this).getAdjacentTiles().filter(':not(.flagged)').each(function() { - //$(this).mousedown(); - }); + if (!automated && parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged, .revealed.mine').length) { + $(this).getAdjacentTiles().filter(':not(.flagged)').each(function() { + $(this).mousedown(); + }); + } } else { $(this).addClass("revealed"); @@ -522,8 +526,6 @@ } $.fn.middleClick = function() { - //move this functionality to left click - //number of flags matches number of adjacent mines if (parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged, .revealed.mine').length) { $(this).getAdjacentTiles().filter(':not(.flagged)').each(function() { @@ -558,9 +560,11 @@ $(this).middleClick(); break; case 1: - default: $(this).leftClick(); break; + default: + $(this).leftClick(true); //automated + break; } removeClearedRows();