var bet = 51; // place your bet here. minimum is 30.
/* in case the bot will click a bomb, bet will be adjusted on the next round to compensate the loss.
the bot will set the bet again to the original value on the next next round.*/
var bigBet = (bet+(0.039*bet))/0.039;
//var bigBet = 500;
bigBet = Math.ceil(bigBet);
var risky_bet_chance1 = 0;
var risky_bet_chance2 = 0;
//var stop_limit_balance = 6000;
/* click sequence interval in milliseconds. equivalent to 2 seconds.
You can change it to longer than 2 seconds but please don't change it to a lower value because it can messed up the timings if you have a slow internet. If you have a very slow internet connection, I recommend setting it up to 3 seconds or higher. */
var interval = 1000;
var restart, timeout1, timeout2, timeout3, timeout4, timeout5, timeout6, timeout7, num_clicks;
// force the difficulty to 1 mine at the start of the game.
$('.quarter').eq(1).find('button').click();
start_game();
function start_game() {
var risky_bet = Math.floor((Math.random() * 100) + 1);
if(restart == 1){
if (risky_bet < risky_bet_chance1) {
$('#bet').val(Math.ceil(1.1*bigBet));
} else {
$('#bet').val(bigBet);
}
restart = 0;
num_clicks = 1;
} else {
if (risky_bet < risky_bet_chance2) {
$('#bet').val(Math.ceil(1.5*bet));
} else {
$('#bet').val(bet);
}
num_clicks = 3;
}
$('#start_game').click();
timeout1 = setTimeout(click_tile1, interval)
} // end of function start_game()
function click_tile1() {
var tile1 = Math.floor((Math.random() * 25) + 1);
//search_last_bomb();
$('.game_left').first().find('li[data-tile='+tile1+']').click();
//$('.game_left [data-tile="'+tile1+'"]').click();
setTimeout(function(){
if($('.game_left').first().find('li[data-tile='+tile1+']').hasClass('bomb')){
$('.quarter').first().find('button').click();
var bal = $('.balance .num').html();
bal = $.trim(bal);
bal = bal.replace(',','');
bal = parseInt(bal);
//bal = bigBet // practice mode
if(bal < bigBet ){
stopgame();
} else {
restart = 1;
start_game();
}
} else {
if (num_clicks >= 2) {
timeout2 = setTimeout(click_tile2, interval);
} else {
$('.quarter').eq(1).find('button').click();
timeout3 = setTimeout(cashout, interval);
}
}
}, interval);
} // end of function click_tile1()
function click_tile2() {
var tile2 = Math.floor((Math.random() * 25) + 1);
//search_last_bomb();
$('.game_left').first().find('li[data-tile='+tile2+']').click();
//$('.game_left [data-tile="'+tile2+'"]').click();
setTimeout(function(){
if($('.game_left').first().find('li[data-tile='+tile2+']').hasClass('bomb')){
$('.quarter').first().find('button').click();
var bal = $('.balance .num').html();
bal = $.trim(bal);
bal = bal.replace(',','');
bal = parseInt(bal);
//bal = bigBet // practice mode
if(bal < bigBet){
stopgame();
} else {
restart = 1;
start_game();
}
}else{
if (num_clicks >= 3) {
timeout4 = setTimeout(click_tile3, interval);
} else {
$('.quarter').eq(1).find('button').click();
timeout5 = setTimeout(cashout, interval);
}
}
}, interval);
} // end of function click_tile2()
function click_tile3() {
var tile3 = Math.floor((Math.random() * 25) + 1);
//search_last_bomb();
$('.game_left').first().find('li[data-tile='+tile3+']').click();
//$('.game_left [data-tile="'+tile2+'"]').click();
setTimeout(function(){
if($('.game_left').first().find('li[data-tile='+tile3+']').hasClass('bomb')){
$('.quarter').first().find('button').click();
var bal = $('.balance .num').html();
bal = $.trim(bal);
bal = bal.replace(',','');
bal = parseInt(bal);
//bal = bigBet // practice mode
if(bal < bigBet){
stopgame();
} else {
restart = 1;
start_game();
}
}else{
$('.quarter').eq(1).find('button').click();
timeout6 = setTimeout(cashout, interval);
}
}, interval);
} // end of function click_tile2()
function cashout() {
$('.game_right').first().find('.cashout').click();
timeout7 = setTimeout(start_game, interval);
} // end of cashout
function stopgame(){
clearTimeout(timeout1);
clearTimeout(timeout2);
clearTimeout(timeout3);
clearTimeout(timeout4);
clearTimeout(timeout5);
clearTimeout(timeout6);
clearTimeout(timeout7);
} // end of stopgame()
function search_last_bomb(){
var has_chosen = 0;
if($('.game_left').eq(1) != null && $('.game_left').eq(1).length > 0){
$('.game_left').eq(1).find('.board').find('li').each(function(i,elem){
if($(elem).hasClass('reveal')){
has_chosen = 1;
tile1 = $(elem).data('tile');
return false;
}
});
}
if(has_chosen == 0){
tile1 = Math.floor((Math.random() * 25) + 1);
}
} // end of searchLastBombTile()