コード例 #1
0
        void placebetthread(object bet)
        {
            if (string.IsNullOrWhiteSpace(seed))
            {
                seed = RandomSeed();
            }
            try
            {
                PlaceBetObj tmp5   = bet as PlaceBetObj;
                decimal     amount = tmp5.Amount;
                decimal     chance = tmp5.Chance;
                bool        High   = tmp5.High;

                decimal tmpchance = High ?maxRoll - chance + 0.0001m : chance - 0.0001m;
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                //string seed = RandomSeed();
                pairs.Add(new KeyValuePair <string, string>("bet", (amount).ToString(System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("target", tmpchance.ToString("0.0000", System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("side", High ? "high" : "low"));
                pairs.Add(new KeyValuePair <string, string>("act", "play_dice"));
                pairs.Add(new KeyValuePair <string, string>("currency", Currency));
                pairs.Add(new KeyValuePair <string, string>("secret", secret));
                pairs.Add(new KeyValuePair <string, string>("token", accesstoken));
                pairs.Add(new KeyValuePair <string, string>("user_seed", seed));
                pairs.Add(new KeyValuePair <string, string>("v", "101"));


                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string sEmitResponse          = Client.PostAsync("action.php", Content).Result.Content.ReadAsStringAsync().Result;
                Lastbet = DateTime.Now;
                try
                {
                    string     x   = sEmitResponse.Replace("f-", "f_").Replace("n-", "n_").Replace("ce-", "ce_").Replace("r-", "r_");
                    bitvestbet tmp = json.JsonDeserialize <bitvestbet>(x);
                    if (tmp.success)
                    {
                        lastupdate = DateTime.Now;
                        Bet resbet = new Bet
                        {
                            Amount     = tmp5.Amount,
                            date       = DateTime.Now,
                            Chance     = tmp5.Chance,
                            high       = tmp5.High,
                            clientseed = seed,
                            serverhash = tmp.server_hash,
                            serverseed = tmp.server_seed,
                            Roll       = tmp.game_result.roll,
                            Profit     = tmp.game_result.win == 0 ? -tmp5.Amount : tmp.game_result.win - tmp5.Amount,
                            nonce      = long.Parse(tmp.player_seed.Substring(tmp.player_seed.IndexOf("|") + 1)),
                            Id         = tmp.game_id.ToString(),
                            Currency   = Currency
                        };
                        resbet.Guid = tmp5.Guid;
                        bets++;
                        //lasthash = tmp.server_hash;
                        bool Win = (((bool)High ? (decimal)tmp.game_result.roll > (decimal)maxRoll - (decimal)(chance) : (decimal)tmp.game_result.roll < (decimal)(chance)));
                        if (Win)
                        {
                            wins++;
                        }
                        else
                        {
                            losses++;
                        }
                        wagered += amount;
                        profit  += resbet.Profit;
                        balance  = decimal.Parse(
                            Currency.ToLower() == "bitcoins"?
                            tmp.data.balance:
                            Currency.ToLower() == "ethers"? tmp.data.balance_ether
                                : Currency.ToLower() == "litecoins"?tmp.data.balance_litecoin:
                            Currency.ToLower() == "dogecoins" ? tmp.data.balance_dogecoin :
                            Currency.ToLower() == "bcash" ? tmp.data.balance_bcash : tmp.data.token_balance,
                            System.Globalization.NumberFormatInfo.InvariantInfo);

                        /*tmp.bet.client = tmp.user.client;
                         * tmp.bet.serverhash = tmp.user.server;
                         * lastupdate = DateTime.Now;
                         * balance = tmp.user.balance / 100000000.0m; //i assume
                         * bets = tmp.user.bets;
                         * wins = tmp.user.wins;
                         * losses = tmp.user.losses;
                         * wagered = (decimal)(tmp.user.wagered / 100000000m);
                         * profit = (decimal)(tmp.user.profit / 100000000m);
                         */
                        FinishedBet(resbet);
                        retrycount = 0;
                    }
                    else
                    {
                        Parent.updateStatus(tmp.msg);
                        if (tmp.msg.ToLower() == "bet rate limit exceeded")
                        {
                            Parent.updateStatus(tmp.msg + ". Retrying in a second;");
                            Thread.Sleep(1000);
                            placebetthread(bet);
                            return;
                        }
                    }
                }
                catch (Exception e)
                {
                    Parent.updateStatus("An unknown error has occurred");
                    Parent.DumpLog(e.ToString(), -1);
                }
            }
            catch (AggregateException e)
            {
                Parent.DumpLog(e.ToString(), -1);
            }
            catch (Exception e2)
            {
                Parent.DumpLog(e2.ToString(), -1);
            }
        }
コード例 #2
0
        void placebetthread(object bet)
        {
            try
            {
                PlaceBetObj tmp5   = bet as PlaceBetObj;
                decimal     amount = tmp5.Amount;
                decimal     chance = tmp5.Chance;
                bool        High   = tmp5.High;

                decimal tmpchance = High ?maxRoll - chance + 0.0001m : chance - 0.0001m;
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                string seed = RandomSeed();
                pairs.Add(new KeyValuePair <string, string>("bet", (amount).ToString(System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("target", tmpchance.ToString("0.0000", System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("side", High ? "high" : "low"));
                pairs.Add(new KeyValuePair <string, string>("act", "play_dice"));
                pairs.Add(new KeyValuePair <string, string>("currency", Currency));
                pairs.Add(new KeyValuePair <string, string>("secret", secret));
                pairs.Add(new KeyValuePair <string, string>("token", accesstoken));
                pairs.Add(new KeyValuePair <string, string>("user_seed", seed));
                pairs.Add(new KeyValuePair <string, string>("v", "65535"));


                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string sEmitResponse          = Client.PostAsync("action.php", Content).Result.Content.ReadAsStringAsync().Result;
                Lastbet = DateTime.Now;
                try
                {
                    bitvestbet tmp = json.JsonDeserialize <bitvestbet>(sEmitResponse.Replace("f-", "f_").Replace("n-", "n_"));
                    if (tmp.success)
                    {
                        Bet resbet = new Bet
                        {
                            Amount     = tmp5.Amount,
                            date       = DateTime.Now,
                            Chance     = tmp5.Chance,
                            high       = tmp5.High,
                            clientseed = seed,
                            serverhash = lasthash,
                            serverseed = tmp.server_seed,
                            Roll       = tmp.game_result.roll,
                            Profit     = tmp.game_result.win == 0 ? -tmp5.Amount : tmp.game_result.win - tmp5.Amount,
                            nonce      = -1,
                            Id         = tmp.game_id,
                            Currency   = Currency
                        };
                        bets++;
                        lasthash = tmp.server_hash;
                        bool Win = (((bool)High ? (decimal)tmp.game_result.roll > (decimal)maxRoll - (decimal)(chance) : (decimal)tmp.game_result.roll < (decimal)(chance)));
                        if (Win)
                        {
                            wins++;
                        }
                        else
                        {
                            losses++;
                        }
                        wagered += amount;
                        profit  += resbet.Profit;
                        balance  = decimal.Parse(Currency.ToLower() == "bitcoins"?tmp.data.balance:tmp.data.token_balance, System.Globalization.NumberFormatInfo.InvariantInfo);

                        /*tmp.bet.client = tmp.user.client;
                         * tmp.bet.serverhash = tmp.user.server;
                         * lastupdate = DateTime.Now;
                         * balance = tmp.user.balance / 100000000.0m; //i assume
                         * bets = tmp.user.bets;
                         * wins = tmp.user.wins;
                         * losses = tmp.user.losses;
                         * wagered = (decimal)(tmp.user.wagered / 100000000m);
                         * profit = (decimal)(tmp.user.profit / 100000000m);
                         */
                        FinishedBet(resbet);
                        retrycount = 0;
                    }
                    else
                    {
                        Parent.updateStatus(tmp.msg);
                        if (tmp.msg.ToLower() == "bet rate limit exceeded")
                        {
                            Parent.updateStatus(tmp.msg + ". Retrying in a second;");
                            Thread.Sleep(1000);
                            placebetthread(bet);
                            return;
                        }
                    }
                }
                catch
                {
                    Parent.updateStatus(sEmitResponse);
                }
            }
            catch (AggregateException e)
            {
                if (retrycount++ < 3)
                {
                    Thread.Sleep(500);
                    placebetthread(new PlaceBetObj(High, amount, chance));
                    return;
                }
                if (e.InnerException.Message.Contains("429") || e.InnerException.Message.Contains("502"))
                {
                    Thread.Sleep(500);
                    placebetthread(new PlaceBetObj(High, amount, chance));
                }
            }
            catch (Exception e2)
            {
            }
        }