예제 #1
0
        void PlaceBetThread(object _High)
        {
            string err = "";

            try
            {
                PlaceBetObj tmp9 = _High as PlaceBetObj;

                bool   High   = tmp9.High;
                double amount = tmp9.Amount;
                //double chance = tmp9.Chance;

                Parent.updateStatus(string.Format("Betting: {0:0.00000000} at {1:0.00000000} {2}", amount, tmp9.Chance, High ? "High" : "Low"));

                double chance = (999999.0) * (tmp9.Chance / 100.0);
                //HttpWebResponse EmitResponse;
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string responseData           = "";
                if (next == "" && next != null)
                {
                    pairs = new List <KeyValuePair <string, string> >();
                    pairs.Add(new KeyValuePair <string, string>("a", "GetServerSeedHash"));
                    pairs.Add(new KeyValuePair <string, string>("s", sessionCookie));

                    Content      = new FormUrlEncodedContent(pairs);
                    responseData = "";
                    using (var response = Client.PostAsync("", Content))
                    {
                        try
                        {
                            responseData = response.Result.Content.ReadAsStringAsync().Result;
                        }
                        catch (AggregateException e)
                        {
                            if (e.InnerException.Message.Contains("ssl"))
                            {
                                PlaceBetThread(High);
                                return;
                            }
                        }
                    }
                    if (responseData.Contains("error"))
                    {
                        if (retrycount++ < 3)
                        {
                            Thread.Sleep(200);
                            PlaceBetThread(High);
                            return;
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                    string Hash = next = json.JsonDeserialize <d999Hash>(responseData).Hash;
                }
                string ClientSeed = r.Next(0, int.MaxValue).ToString();
                pairs = new List <KeyValuePair <string, string> >();
                pairs.Add(new KeyValuePair <string, string>("a", "PlaceBet"));
                pairs.Add(new KeyValuePair <string, string>("s", sessionCookie));
                pairs.Add(new KeyValuePair <string, string>("PayIn", ((long)(amount * 100000000.0)).ToString("0", System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("Low", (High ? 999999 - (int)chance : 0).ToString(System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("High", (High ? 999999 : (int)chance).ToString(System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("ClientSeed", ClientSeed));
                pairs.Add(new KeyValuePair <string, string>("Currency", Currency));
                pairs.Add(new KeyValuePair <string, string>("ProtocolVersion", "2"));

                Content = new FormUrlEncodedContent(pairs);
                string tmps = Content.ReadAsStringAsync().Result;

                responseData = "";
                using (var response = Client.PostAsync("", Content))
                {
                    try
                    {
                        responseData = response.Result.Content.ReadAsStringAsync().Result;
                    }
                    catch (AggregateException e)
                    {
                        Parent.DumpLog(e.InnerException.Message, 0);
                        if (retrycount++ < 3)
                        {
                            PlaceBetThread(High);
                            return;
                        }
                        if (e.InnerException.Message.Contains("ssl"))
                        {
                            PlaceBetThread(High);
                            return;
                        }
                        else
                        {
                            Parent.updateStatus("An error has occurred");
                        }
                    }
                }


                d999Bet tmpBet = json.JsonDeserialize <d999Bet>(responseData);

                if (amount >= 21)
                {
                }
                if (tmpBet.ChanceTooHigh == 1 || tmpBet.ChanceTooLow == 1 | tmpBet.InsufficientFunds == 1 || tmpBet.MaxPayoutExceeded == 1 || tmpBet.NoPossibleProfit == 1)
                {
                    if (tmpBet.ChanceTooHigh == 1)
                    {
                        err = "Chance too high";
                    }
                    if (tmpBet.ChanceTooLow == 1)
                    {
                        err += "Chance too Low";
                    }
                    if (tmpBet.InsufficientFunds == 1)
                    {
                        err += "Insufficient Funds";
                    }
                    if (tmpBet.MaxPayoutExceeded == 1)
                    {
                        err += "Max Payout Exceeded";
                    }
                    if (tmpBet.NoPossibleProfit == 1)
                    {
                        err += "No Possible Profit";
                    }
                    throw new Exception();
                }
                else if (tmpBet.BetId == 0)
                {
                    throw new Exception();
                }
                else
                {
                    balance = (double)tmpBet.StartingBalance / 100000000.0 - (amount) + ((double)tmpBet.PayOut / 100000000.0);

                    profit += -(amount) + (double)(tmpBet.PayOut / 100000000m);
                    Bet tmp = new Bet();
                    tmp.Amount     = (decimal)amount;
                    tmp.BetDate    = DateTime.Now.ToString();;
                    tmp.Chance     = ((decimal)chance * 100m) / 999999m;
                    tmp.clientseed = ClientSeed;
                    tmp.Currency   = Currency;
                    tmp.high       = High;
                    tmp.Id         = tmpBet.BetId;
                    tmp.nonce      = 0;
                    tmp.Profit     = ((decimal)tmpBet.PayOut / 100000000m) - ((decimal)amount);
                    tmp.Roll       = tmpBet.Secret / 10000m;
                    tmp.serverhash = next;
                    tmp.serverseed = tmpBet.ServerSeed;
                    tmp.uid        = (int)uid;
                    tmp.UserName   = "";

                    bool win = false;
                    if ((tmp.Roll > 99.99m - tmp.Chance && High) || (tmp.Roll < tmp.Chance && !High))
                    {
                        win = true;
                    }
                    if (win)
                    {
                        wins++;
                    }
                    else
                    {
                        losses++;
                    }
                    Wagered += tmp.Amount;
                    bets++;


                    sqlite_helper.InsertSeed(tmp.serverhash, tmp.serverseed);
                    next       = tmpBet.Next;
                    retrycount = 0;
                    FinishedBet(tmp);
                }
            }
            catch
            {
                if (err != "")
                {
                    Parent.updateStatus(err);
                }
                else
                {
                    Parent.updateStatus("Something went wrong! stopped betting");
                }
            }
        }
예제 #2
0
        void PlaceBetThread()
        {
            try
            {
                Parent.updateStatus(string.Format("Betting: {0:0.00000000} at {1:0.00000000} {2}", amount, this.chance, High ? "High" : "Low"));
                HttpWebRequest loginrequest = HttpWebRequest.Create("https://www.999dice.com/api/web.aspx") as HttpWebRequest;
                if (Prox != null)
                {
                    loginrequest.Proxy = Prox;
                }
                string          post          = string.Format("a=GetServerSeedHash&s={0}", sessionCookie);
                string          sEmitResponse = "";
                double          chance        = (999999.0) * (this.chance / 100.0);
                HttpWebResponse EmitResponse;

                if (next == "" && next != null)
                {
                    loginrequest = HttpWebRequest.Create("https://www.999dice.com/api/web.aspx") as HttpWebRequest;
                    if (Prox != null)
                    {
                        loginrequest.Proxy = Prox;
                    }
                    post = string.Format("a=GetServerSeedHash&s={0}", sessionCookie);
                    loginrequest.Method = "POST";

                    loginrequest.ContentLength = post.Length;
                    loginrequest.ContentType   = "application/x-www-form-urlencoded; charset=UTF-8";

                    using (var writer = new StreamWriter(loginrequest.GetRequestStream()))
                    {
                        writer.Write(post);
                    }
                    EmitResponse  = (HttpWebResponse)loginrequest.GetResponse();
                    sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd();
                    if (sEmitResponse.Contains("error"))
                    {
                        if (BetRetries++ < 3)
                        {
                            Thread.Sleep(200);
                            PlaceBetThread();
                            return;
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                    string Hash = next = json.JsonDeserialize <d999Hash>(sEmitResponse).Hash;
                }
                loginrequest = HttpWebRequest.Create("https://www.999dice.com/api/web.aspx") as HttpWebRequest;
                if (Prox != null)
                {
                    loginrequest.Proxy = Prox;
                }
                string ClientSeed = r.Next(0, int.MaxValue).ToString();


                post = string.Format("a=PlaceBet&s={0}&PayIn={1}&Low={2}&High={3}&ClientSeed={4}&Currency={5}&ProtocolVersion=2", sessionCookie, (long)Math.Ceiling(amount * 100000000.0), High ? 999999 - (int)chance : 0, High ? 999999 : (int)chance, ClientSeed, Currency);
                loginrequest.Method = "POST";

                loginrequest.ContentLength = post.Length;
                loginrequest.ContentType   = "application/x-www-form-urlencoded; charset=UTF-8";

                using (var writer = new StreamWriter(loginrequest.GetRequestStream()))
                {
                    writer.Write(post);
                }
                EmitResponse  = (HttpWebResponse)loginrequest.GetResponse();
                sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd();

                d999Bet tmpBet = json.JsonDeserialize <d999Bet>(sEmitResponse);
                if (amount >= 21)
                {
                }
                if (tmpBet.ChanceTooHigh == 1 || tmpBet.ChanceTooLow == 1 | tmpBet.InsufficientFunds == 1 || tmpBet.MaxPayoutExceeded == 1 || tmpBet.NoPossibleProfit == 1)
                {
                    throw new Exception();
                }
                if (tmpBet.BetId == 0)
                {
                }
                balance = (double)tmpBet.StartingBalance / 100000000.0 - (amount) + ((double)tmpBet.PayOut / 100000000.0);

                profit += -(amount) + (double)(tmpBet.PayOut / 100000000m);
                Bet tmp = new Bet();
                tmp.Amount     = (decimal)amount;
                tmp.BetDate    = DateTime.Now.ToString();;
                tmp.Chance     = ((decimal)chance * 100m) / 999999m;
                tmp.clientseed = ClientSeed;
                tmp.Currency   = Currency;
                tmp.high       = High;
                tmp.Id         = tmpBet.BetId;
                tmp.nonce      = 0;
                tmp.Profit     = ((decimal)tmpBet.PayOut / 100000000m) - ((decimal)amount);
                tmp.Roll       = tmpBet.Secret / 10000m;
                tmp.serverhash = next;
                tmp.serverseed = tmpBet.ServerSeed;
                tmp.uid        = (int)uid;
                tmp.UserName   = "";

                bool win = false;
                if ((tmp.Roll > 99.99m - tmp.Chance && High) || (tmp.Roll < tmp.Chance && !High))
                {
                    win = true;
                }
                if (win)
                {
                    wins++;
                }
                else
                {
                    losses++;
                }
                Wagered += tmp.Amount;
                bets++;
                BetRetries = 0;

                sqlite_helper.InsertSeed(tmp.serverhash, tmp.serverseed);
                next = tmpBet.Next;
                FinishedBet(tmp);
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Something went wrong! betting stopped.");
            }
        }