Advertisement
aloenk

btslrspeed

Dec 15th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.56 KB | None | 0 0
  1. play = function() {
  2.     if (game_in_progress == true) {
  3.         $("#btn-bet-dice, #btn-bet-start-pilot-dice, #btn-bet-start-fast-dice").button("reset");
  4.         return false;
  5.     }
  6.  
  7.     RequestAbortCount = 0;
  8.     game_in_progress = true;
  9.  
  10.     if (autobet_mode == false) {
  11.         var amount = $("#amount").val();
  12.         var condition = $("#condition-input").val();
  13.         var game = $("#game-input").val();
  14.     }
  15.     else {
  16.         var amount = auto_amount;
  17.         var condition = auto_condition;
  18.         var game = auto_game;
  19.     }
  20.  
  21.     amount = round_float(amount, devise_decimal);
  22.  
  23.     var profit = parseFloat($("#profit").val());
  24.     var balance = parseFloat($("#balance-"+devise).val());
  25.     var error = false;
  26.     var error_value = "";
  27.     var error_title = "";
  28.     var error_info = "";
  29.  
  30.     if (profit > profit_max) {
  31.         error_title = "Maximum profit exceeded";
  32.         error_info = "Maximum profit: "+number_format(profit_max, devise_decimal);
  33.         error_value = "Maximum profit exceeded - Maximum profit: "+number_format(profit_max, devise_decimal);
  34.         error = true;
  35.     }
  36.  
  37.     if (amount > balance) {
  38.         error_title = "Bet amount";
  39.         error_info = "Maximum bet: "+number_format(balance, devise_decimal);
  40.         error_value = "Bet amount - Maximum bet: "+number_format(balance, devise_decimal);
  41.         error = true;
  42.     }
  43.     else if (amount > bet_max) {
  44.         error_title = "Bet amount";
  45.         error_info = "Maximum bet: "+number_format(bet_max, devise_decimal);
  46.         error_value = "Bet amount - Maximum bet: "+number_format(bet_max, devise_decimal);
  47.         error = true;
  48.     }
  49.     else if (amount < bet_min) {
  50.         error_title = "Bet amount";
  51.         error_info = "Minimum bet: "+number_format(bet_min, devise_decimal);
  52.         error_value = "Bet amount - Minimum bet: "+number_format(bet_min, devise_decimal);
  53.         error = true;
  54.     }
  55.  
  56.     if (error == true) {
  57.         game_in_progress = false;
  58.         $("#btn-bet-dice, #btn-bet-start-pilot-dice, #btn-bet-start-fast-dice").button("reset");
  59.  
  60.         if (autobet_mode == true) {
  61.             if (number_bet_done >= 1) {
  62.                 $("#modal-stop-autobet-numbers").html(number_bet_done);
  63.                 $("#modal-stop-autobet-value").html(error_value);
  64.                 $("#modal-stop-autobet-reason").modal("show");
  65.             }
  66.             else {
  67.                 showErrorNotification(error_title, error_info);
  68.             }
  69.  
  70.             stop_pilot_mode();
  71.         }
  72.         else {
  73.             showErrorNotification(error_title, error_info);
  74.         }
  75.  
  76.         return;
  77.     }
  78.  
  79.     var time1 = (new Date()).getTime();
  80.     $.ajax({
  81.         type: "POST",
  82.         url: "/api/bet",
  83.         data: {
  84.             access_token        :       access_token,
  85.             username            :       user_username,
  86.             type                        :       "dice",
  87.             amount              :       amount,
  88.             condition               :       condition,
  89.             game                    :       game,
  90.             devise                  :       devise
  91.         },
  92.         success: function(text) {
  93.             var val = JSON.parse(text);
  94.             if (val.return.success == 'true') {
  95.                 bet_nb_errors = 0;
  96.  
  97.                 var username = val.return.username;
  98.                 var id = val.return.id;
  99.                 var type = val.return.type;
  100.                 var devise = val.return.devise;
  101.                 var ts = val.return.ts;
  102.                 var time = val.return.time;
  103.                 var winning_chance = val.return.winning_chance;
  104.                 var roll_number = val.return.roll_number;
  105.                 var amount_return = val.return.amount_return;
  106.                 var new_balance = val.return.new_balance;
  107.                 var show = val.return.show;
  108.                 var amount = val.return.amount;
  109.                 var condition = val.return.condition;
  110.                 var game = val.return.game;
  111.                 var payout = val.return.payout;
  112.  
  113.                 $("#won-bet span").html(amount_return);
  114.                 $("#won-bet span").removeClass("text-danger text-success");
  115.                 if (amount_return >= 0) {
  116.                     $("#won-bet span").addClass("text-success");
  117.                     $("#won-bet span").html("+"+number_format(round_float(amount_return, 8), 8));
  118.                 }
  119.                 else {
  120.                     $("#won-bet span").addClass("text-danger");
  121.                     $("#won-bet span").html(number_format(round_float(amount_return, 8), 8));
  122.                 }
  123.                 show_result_bet();
  124.  
  125.                 var balance_amount = parseFloat($("#balance-"+devise).val());
  126.                 balance_amount += parseFloat(amount_return);
  127.                 $("#balance-"+devise).val(round_float(balance_amount, 12));
  128.  
  129.                 if (amount_return >= 0)
  130.                     $(".balance-"+devise+"-html").addClass("result-bet-win");
  131.                 else
  132.                     $(".balance-"+devise+"-html").addClass("result-bet-lose");
  133.  
  134.                 $(".balance-"+devise+"-html").html(round_float(balance_amount, 8));
  135.  
  136.                 if (amount_return >= 0)
  137.                     setTimeout(function() { $(".balance-"+devise+"-html").removeClass("result-bet-win");    }, 350);
  138.                 else
  139.                     setTimeout(function() { $(".balance-"+devise+"-html").removeClass("result-bet-lose");   }, 350);
  140.  
  141.                 addBetHistory("my-bets", type, id, username, time, amount, devise, winning_chance, roll_number, amount_return, condition, game, payout);
  142.  
  143.                 var notifications = val.return.notifications;
  144.                 for (var prop in notifications) {
  145.                     if (notifications[prop].name == "rcvJackpotDice")
  146.                         rcvJackpotDice(notifications[prop]);
  147.                     else {
  148.                         rcvnotificationbet(notifications[prop]);
  149.                     }
  150.                 }
  151.  
  152.                 var time2 = (new Date()).getTime();
  153.                 var delay = time2-time1;
  154.  
  155.                 if (autobet_mode == false) {
  156.                     if (devise == "btc")
  157.                         var base_speed = 0.00001000;
  158.                     else if (devise == "ltc")
  159.                         var base_speed = 0.001;
  160.                     else if (devise == "doge")
  161.                         var base_speed = 10;
  162.  
  163.                     if (amount < base_speed)
  164.                         var time_by_bet = 500;
  165.                     else
  166.                         var time_by_bet = 100;
  167.  
  168.                     if (delay < time_by_bet)
  169.                         time_by_bet = time_by_bet-delay;
  170.                     else
  171.                         time_by_bet = 0;
  172.  
  173.                     setTimeout(function() {
  174.                         $("#btn-bet-dice, #btn-bet-start-pilot-dice, #btn-bet-start-fast-dice").button("reset");
  175.                     }, time_by_bet);
  176.  
  177.                     // setTimeout(function() {
  178.                     //$("#btn-bet-dice, #btn-bet-start-pilot-dice, #btn-bet-start-fast-dice").button("reset");
  179.                     // }, time_by_bet);
  180.                 }
  181.                 else {
  182.                     number_bet_done++;
  183.  
  184.                     if (unlimited_bet == false) {
  185.                         number_rolls--;
  186.                         $("#limit-rolls-input").val(number_rolls);
  187.  
  188.                         var pourcBarre = ((number_rolls_total-number_rolls)/number_rolls_total)*100;
  189.                         $("#progress-bar-pilot-mode div").css("width", pourcBarre+"%");
  190.                     }
  191.  
  192.                     if (amount_return >= 0) {
  193.                         auto_stats_won++;
  194.                     }
  195.                     else {
  196.                         auto_stats_lost++;
  197.                     }
  198.  
  199.                     auto_stats_lucky = ((((parseInt(auto_stats_won)/parseInt(number_bet_done))*100)/parseFloat(winning_chance))*100).toFixed(2);
  200.  
  201.                     auto_stats_wagered = parseFloat(auto_stats_wagered)+parseFloat(amount);
  202.                     auto_stats_profit = parseFloat(auto_stats_profit)+parseFloat(amount_return);
  203.  
  204.                     if (on_win == "id-bet-win" && amount_return >= 0) {
  205.                         auto_amount = parseFloat(auto_amount)+parseFloat(auto_amount*(pourc_on_win/100));
  206.                     }
  207.                     else if (amount_return >= 0) {
  208.                         auto_amount = auto_amount_var;
  209.                     }
  210.  
  211.                     if (on_lose == "id-bet-lose" && amount_return < 0) {
  212.                         auto_amount = parseFloat(auto_amount)+parseFloat(auto_amount*(pourc_on_lose/100));
  213.                     }
  214.                     else if (amount_return < 0) {
  215.                         auto_amount = auto_amount_var;
  216.                     }
  217.  
  218.                     update_stats_auto();
  219.  
  220.                     if ((number_bet_done < number_rolls_total) || unlimited_bet == true) {
  221.                         var speed_bet_val = $("#speed-bet").val();
  222.                         var speed = (100-speed_bet_val);
  223.  
  224.                         if (devise == "btc")
  225.                             var base_speed = 0.00000100;
  226.                         else if (devise == "ltc")
  227.                             var base_speed = 0.0002;
  228.                         else if (devise == "doge")
  229.                             var base_speed = 2;
  230.  
  231.                         if (auto_amount >= (base_speed*50)) {
  232.                             var time_by_bet = speed*20;
  233.                         }
  234.                         else if (auto_amount >= (base_speed*10)) {
  235.                             var time_by_bet = speed*10;
  236.                         }
  237.                         else if (auto_amount >= base_speed) {
  238.                             var time_by_bet = speed*5;
  239.                         }
  240.                         else {
  241.                             var time_by_bet = speed*1;
  242.                         }
  243.  
  244.                         if (autobet_stop == false) {
  245.                             if (delay < time_by_bet)
  246.                                 time_by_bet = time_by_bet-delay;
  247.                             else
  248.                                 time_by_bet = 0;
  249.  
  250.                             setTimeout(function() {
  251.                                 if(auto_amount > 0.00001000){
  252. //                                  if(!confirm(round_float(auto_amount, devise_decimal))){
  253. //                                      stop_pilot_mode();
  254. //                                      //     auto_amount = 500;
  255. //                                      return false;
  256. //                                  }
  257.  
  258.                                     auto_amount_o = auto_amount
  259. //                                  if(auto_amount > 0.00000400)
  260. //                                      auto_amount = 0.00000400;
  261.  
  262.                                     auto_amount = prompt(round_float(auto_amount_o, devise_decimal)+'?', round_float(auto_amount, devise_decimal));
  263.                                     if(auto_amount == ""){
  264.                                         stop_pilot_mode();
  265.                                         return false;
  266.                                     }
  267.  
  268.                                     auto_amount = parseFloat(auto_amount);
  269.                                 }
  270.                                
  271.                                 if((auto_amount - 0.00001) > auto_stats_profit){
  272. //                                  if(!confirm('amount='+round_float(auto_amount, devise_decimal)+' > profit='+round_float(auto_stats_profit, devise_decimal))){
  273. //                                      stop_pilot_mode();
  274. //                                      //     auto_amount = 500;
  275. //                                      return false;
  276. //                                  }
  277.                                    
  278.                                    
  279.                                     auto_amount = prompt('amount='+round_float(auto_amount, devise_decimal)+' > profit='+round_float(auto_stats_profit, devise_decimal), round_float(auto_amount, devise_decimal));
  280.                                     if(auto_amount == ""){
  281.                                         stop_pilot_mode();
  282.                                         return false;
  283.                                     }
  284.  
  285.                                     auto_amount = parseFloat(auto_amount);
  286.                                 }
  287.                                
  288.  
  289.                                 play();
  290.                             }, time_by_bet);
  291.                         }
  292.                         else {
  293.                             stop_pilot_mode();
  294.                         }
  295.                     }
  296.                     else {
  297.                         stop_pilot_mode();
  298.                     }
  299.                 }
  300.  
  301.                 if (val.return.event == true) {
  302.                     socket.emit("event", {});
  303.                 }
  304.             }
  305.             else {
  306.                 if (val.return.type != "abort") {
  307.                     if (autobet_mode == false) {
  308.                         showErrorNotification(val.return.value, val.return.info);
  309.                         $("#btn-bet-dice, #btn-bet-start-pilot-dice, #btn-bet-start-fast-dice").button("reset");
  310.                     }
  311.                     else {
  312.                         if (number_bet_done >= 1) {
  313.                             $("#modal-stop-autobet-numbers").html(number_bet_done);
  314.                             $("#modal-stop-autobet-value").html(val.return.value);
  315.                             $("#modal-stop-autobet-reason").modal("show");
  316.                         }
  317.                         else {
  318.                             showErrorNotification(val.return.value, val.return.info);
  319.                         }
  320.  
  321.                         stop_pilot_mode();
  322.                     }
  323.                 }
  324.                 else {
  325.                     if (bet_nb_errors >= 2) {
  326.                         bet_nb_errors = 0;
  327.                         if (autobet_mode == false) {
  328.                             showErrorNotification(val.return.value, val.return.info);
  329.                             $("#btn-bet-dice, #btn-bet-start-pilot-dice, #btn-bet-start-fast-dice").button("reset");
  330.                         }
  331.                         else {
  332.                             if (number_bet_done >= 1) {
  333.                                 $("#modal-stop-autobet-numbers").html(number_bet_done);
  334.                                 $("#modal-stop-autobet-value").html(val.return.value);
  335.                                 $("#modal-stop-autobet-reason").modal("show");
  336.                             }
  337.                             else {
  338.                                 showErrorNotification(val.return.value, val.return.info);
  339.                             }
  340.  
  341.                             stop_pilot_mode();
  342.                         }
  343.  
  344.                     }
  345.                     else {
  346.                         bet_nb_errors++;
  347.                         setTimeout(function() { play(); }, 1000);
  348.                     }
  349.                 }
  350.  
  351.             }
  352.  
  353.             game_in_progress = false;
  354.  
  355.         }
  356.     });
  357.  
  358. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement