Beispiel #1
0
        void PlaceBetThread(object High)
        {
            try
            {
                Parent.updateStatus(string.Format("Betting: {0:0.00000000} at {1:0.00000000} {2}", amount, chance, (bool)High ? "High" : "Low"));
                HttpWebRequest betrequest = (HttpWebRequest)HttpWebRequest.Create("https://safedice.com/api/dicebets");
                if (Prox != null)
                {
                    betrequest.Proxy = Prox;
                }
                betrequest.Method = "POST";
                SafeDiceBet tmpBet = new SafeDiceBet
                {
                    siteId        = curen,
                    amount        = (long)(amount * (Currency != "2"? 100000000: 1000000000000)),
                    payout        = (double)(((long)((99.5 / chance) * (curen != 2 ? 100000000 : 1000000000000))) / (curen != 2 ? 100000000.0 : 1000000000000.0)),
                    isFixedPayout = false,
                    isRollLow     = !(bool)High,
                    target        = ((bool)High) ? (999999 - ((long)(chance * 10000))).ToString() : ((long)(chance * 10000)).ToString()
                };
                string post = json.JsonSerializer <SafeDiceBet>(tmpBet);

                betrequest.ContentLength = post.Length;
                betrequest.ContentType   = " application/json;charset=utf-8";
                betrequest.Headers.Add("authorization", "Bearer " + accesstoken);
                betrequest.CookieContainer = new CookieContainer();
                using (var writer = new StreamWriter(betrequest.GetRequestStream()))
                {
                    writer.Write(post);
                    writer.Flush();
                    writer.Close();
                }
                string            tmp           = betrequest.ToString();
                HttpWebResponse   EmitResponse  = (HttpWebResponse)betrequest.GetResponse();
                string            sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd();
                SafeDiceBetResult tmpResult     = json.JsonDeserialize <SafeDiceBetResult>(sEmitResponse);
                Bet bet = new Bet();
                bet.Amount     = (decimal)tmpResult.amount / (curen != 2 ? 100000000m : 1000000000000m);
                bet.date       = json.ToDateTime2(tmpResult.processTime);
                bet.Chance     = (!tmpResult.isRollLow ? 100m - (decimal)tmpResult.target / 1000000m * 100m : (decimal)tmpResult.target / 1000000m * 100m);
                bet.high       = !tmpResult.isRollLow;
                bet.clientseed = client;
                bet.Id         = tmpResult.id;
                bet.nonce      = nonce++;
                bet.Profit     = tmpResult.profit / (curen != 2 ? 100000000m : 1000000000000m);
                bet.Roll       = (decimal)tmpResult.roll / 10000m;
                bet.serverhash = serverhash;
                bet.uid        = (int)tmpResult.accountId;
                balance       += (double)bet.Profit;

                ++bets;
                wagered += (double)bet.Amount;
                bool win = false;
                if (tmpResult.isRollLow && tmpResult.roll < tmpResult.target)
                {
                    win = true;
                }
                else if (!tmpResult.isRollLow && tmpResult.roll > tmpResult.target)
                {
                    win = true;
                }
                if (win)
                {
                    ++wins;
                }
                else
                {
                    ++losses;
                }
                profit += (double)bet.Profit;
                FinishedBet(bet);
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                    string sEmitResponse = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
                    Parent.updateStatus(sEmitResponse);
                    System.Windows.Forms.MessageBox.Show("Error placing bet. Betting stopped");

                    /*if (e.Message.Contains("401"))
                     * {
                     *  System.Windows.Forms.MessageBox.Show("Could not log in. Please ensure the username, passowrd and 2fa code are all correct.");
                     * }*/
                }
            }
        }
Beispiel #2
0
        void PlaceBetThread(object Obj)
        {
            PlaceBetObj tmp    = Obj as PlaceBetObj;
            bool        High   = tmp.High;
            decimal     amount = tmp.Amount;
            decimal     chance = tmp.Chance;

            try
            {
                Parent.updateStatus(string.Format("Betting: {0:0.00000000} at {1:0.00000000} {2}", amount, chance, (bool)High ? "High" : "Low"));
                SafeDiceBet tmpBet = new SafeDiceBet
                {
                    siteId        = curen,
                    amount        = (long)(amount * (curen != 2 ? 100000000m : 1000000000000m)),
                    payout        = (decimal)(((long)((99.5m / chance) * (curen != 2 ? 100000000m : 1000000000000m))) / (curen != 2 ? 100000000.0m : 1000000000000.0m)),
                    isFixedPayout = false,
                    isRollLow     = !(bool)High,
                    target        = ((bool)High) ? (999999m - ((long)(chance * 10000m))).ToString(System.Globalization.NumberFormatInfo.InvariantInfo) : ((long)(chance * 10000m)).ToString(System.Globalization.NumberFormatInfo.InvariantInfo)
                };
                string post = json.JsonSerializer <SafeDiceBet>(tmpBet);

                /*HttpWebRequest betrequest = (HttpWebRequest)HttpWebRequest.Create("https://safedice.com/api/dicebets");
                 * if (Prox != null)
                 *  betrequest.Proxy = Prox;
                 * betrequest.Method = "POST";
                 * SafeDiceBet tmpBet = new SafeDiceBet
                 * {
                 *  siteId = curen,
                 *  amount = (long)(amount * ( Currency!="2"? 100000000: 1000000000000)),
                 *  payout = (decimal)(((long)((99.5 / chance) * (curen != 2 ? 100000000 : 1000000000000))) / (curen != 2 ? 100000000.0 : 1000000000000.0)),
                 *  isFixedPayout = false,
                 *  isRollLow = !(bool)High,
                 *  target = ((bool)High) ? (999999 - ((long)(chance * 10000))).ToString() : ((long)(chance * 10000)).ToString()
                 * };
                 * string post = json.JsonSerializer<SafeDiceBet>(tmpBet);
                 *
                 * betrequest.ContentLength = post.Length;
                 * betrequest.ContentType = " application/json;charset=utf-8";
                 * betrequest.Headers.Add("authorization", "Bearer " + accesstoken);
                 * betrequest.CookieContainer = new CookieContainer();
                 * using (var writer = new StreamWriter(betrequest.GetRequestStream()))
                 * {
                 *
                 *  writer.Write(post);
                 *  writer.Flush();
                 *  writer.Close();
                 * }
                 * string tmp = betrequest.ToString();
                 * HttpWebResponse EmitResponse = (HttpWebResponse)betrequest.GetResponse();*/
                string sEmitResponse = ""; //new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd();

                HttpContent cont = new StringContent(post);
                cont.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
                string Resp = "";
                using (var response = Client.PostAsync("dicebets", cont))
                {
                    Resp = response.Result.Content.ReadAsStringAsync().Result;
                    if (Resp == "{}")
                    {
                        Parent.updateStatus("Something went wrong! Please check your bet size.");
                        return;
                    }
                }

                SafeDiceBetResult tmpResult = json.JsonDeserialize <SafeDiceBetResult>(Resp);
                Bet bet = new Bet();
                bet.Amount     = (decimal)tmpResult.amount / (curen != 2 ? 100000000m : 1000000000000m);
                bet.date       = DateTime.Now;
                bet.Chance     = (!tmpResult.isRollLow ? 100m - (decimal)tmpResult.target / 1000000m * 100m : (decimal)tmpResult.target / 1000000m * 100m);
                bet.high       = !tmpResult.isRollLow;
                bet.clientseed = client;
                bet.Id         = tmpResult.id.ToString();
                bet.nonce      = nonce++;
                bet.Profit     = tmpResult.profit / (curen != 2 ? 100000000m : 1000000000000m);
                bet.Roll       = (decimal)tmpResult.roll / 10000m;
                bet.serverhash = serverhash;
                bet.uid        = (int)tmpResult.accountId;
                balance       += (decimal)bet.Profit;

                ++bets;
                wagered += (decimal)bet.Amount;
                bool win = false;
                if (tmpResult.isRollLow && tmpResult.roll < tmpResult.target)
                {
                    win = true;
                }
                else if (!tmpResult.isRollLow && tmpResult.roll > tmpResult.target)
                {
                    win = true;
                }
                if (win)
                {
                    ++wins;
                }
                else
                {
                    ++losses;
                }
                profit += (decimal)bet.Profit;
                FinishedBet(bet);
                retrycount = 0;
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                    string sEmitResponse = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
                    Parent.updateStatus(sEmitResponse);
                    System.Windows.Forms.MessageBox.Show("Error placing bet. Betting stopped");

                    /*if (e.Message.Contains("401"))
                     * {
                     *  System.Windows.Forms.MessageBox.Show("Could not log in. Please ensure the username, passowrd and 2fa code are all correct.");
                     * }*/
                }
            }
            catch (AggregateException e)
            {
                Parent.DumpLog(e.InnerException.Message, 3);
                Parent.DumpLog(e.InnerException.StackTrace, 4);
            }
            catch
            {
                if (retrycount++ < 3)
                {
                    PlaceBetThread(tmp);
                    return;
                }
            }
        }
Beispiel #3
0
        void PlaceBetThread(object High)
        {
            try
            {
                Parent.updateStatus(string.Format("Betting: {0:0.00000000} at {1:0.00000000} {2}", amount, chance, (bool)High ? "High" : "Low"));
                HttpWebRequest betrequest = (HttpWebRequest)HttpWebRequest.Create("https://safedice.com/api/dicebets");
                if (Prox != null)
                    betrequest.Proxy = Prox;
                betrequest.Method = "POST";
                SafeDiceBet tmpBet = new SafeDiceBet
                {
                    siteId = curen,
                    amount = (long)(amount * ( Currency!="2"? 100000000: 1000000000000)),
                    payout = (double)(((long)((99.5 / chance) * (curen != 2 ? 100000000 : 1000000000000))) / (curen != 2 ? 100000000.0 : 1000000000000.0)),
                    isFixedPayout = false,
                    isRollLow = !(bool)High,
                    target = ((bool)High) ? (999999 - ((long)(chance * 10000))).ToString() : ((long)(chance * 10000)).ToString()
                };
                string post = json.JsonSerializer<SafeDiceBet>(tmpBet);

                betrequest.ContentLength = post.Length;
                betrequest.ContentType = " application/json;charset=utf-8";
                betrequest.Headers.Add("authorization", "Bearer " + accesstoken);
                betrequest.CookieContainer = new CookieContainer();
                using (var writer = new StreamWriter(betrequest.GetRequestStream()))
                {

                    writer.Write(post);
                    writer.Flush();
                    writer.Close();
                }
                string tmp = betrequest.ToString();
                HttpWebResponse EmitResponse = (HttpWebResponse)betrequest.GetResponse();
                string sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd();
                SafeDiceBetResult tmpResult = json.JsonDeserialize<SafeDiceBetResult>(sEmitResponse);
                Bet bet = new Bet();
                bet.Amount = (decimal)tmpResult.amount / (curen != 2 ? 100000000m : 1000000000000m);
                bet.date = json.ToDateTime2(tmpResult.processTime);
                bet.Chance = (!tmpResult.isRollLow ? 100m - (decimal)tmpResult.target / 1000000m * 100m : (decimal)tmpResult.target / 1000000m * 100m);
                bet.high = !tmpResult.isRollLow;
                bet.clientseed = client;
                bet.Id = tmpResult.id;
                bet.nonce = nonce++;
                bet.Profit = tmpResult.profit / (curen != 2 ? 100000000m : 1000000000000m);
                bet.Roll = (decimal)tmpResult.roll / 10000m;
                bet.serverhash = serverhash;
                bet.uid = (int)tmpResult.accountId;
                balance += (double)bet.Profit;

                ++bets;
                wagered += (double)bet.Amount;
                bool win = false;
                if (tmpResult.isRollLow && tmpResult.roll < tmpResult.target)
                    win = true;
                else if (!tmpResult.isRollLow && tmpResult.roll > tmpResult.target)
                    win = true;
                if (win)
                    ++wins;
                else
                    ++losses;
                profit += (double)bet.Profit;
                FinishedBet(bet);
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {

                    string sEmitResponse = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
                    Parent.updateStatus(sEmitResponse);
                    System.Windows.Forms.MessageBox.Show("Error placing bet. Betting stopped");
                    /*if (e.Message.Contains("401"))
                    {
                        System.Windows.Forms.MessageBox.Show("Could not log in. Please ensure the username, passowrd and 2fa code are all correct.");
                    }*/

                }
            }
        }