Exemple #1
0
            public DiceBet ToBet()
            {
                DiceBet bet = new DiceBet
                {
                    TotalAmount = amount,
                    Chance      = state.condition.ToLower() == "above" ? 99.99m - (decimal)state.target : (decimal)state.target,
                    High        = state.condition.ToLower() == "above",
                    Currency    = currency,
                    DateValue   = DateTime.Now,
                    BetID       = id.ToString(),
                    Roll        = (decimal)state.result,
                    ClientSeed  = clientSeed.seed,
                    ServerHash  = serverSeed.seedHash,
                    Nonce       = nonce
                };

                //User tmpu = User.FindUser(bet.UserName);

                /*if (tmpu == null)
                 *  bet.uid = 0;
                 * else
                 *  bet.uid = (int)tmpu.Uid;*/
                bool win = (((bool)bet.High ? (decimal)bet.Roll > (decimal)99.99 - (decimal)(bet.Chance) : (decimal)bet.Roll < (decimal)(bet.Chance)));

                bet.Profit = win ? ((payout - amount)) : (-amount);
                return(bet);
            }
        public bool CheckHighLow(DiceBet NewBet, bool win, SessionStats Stats, out bool NewHigh, SiteStats siteStats)
        {
            NewHigh = false;

            if (EnableSwitchWins && Stats.Wins % SwitchWins == 0)
            {
                NewHigh = !NewBet.High;
                return(true);
            }
            if (EnableSwitchWinStreak && Stats.WinStreak % SwitchWinStreak == 0 && win)
            {
                NewHigh = !NewBet.High;
                return(true);
            }
            if (EnableSwitchLosses && Stats.Losses % SwitchLosses == 0)
            {
                NewHigh = !NewBet.High;
                return(true);
            }
            if (EnableSwitchLossStreak && Stats.LossStreak % SwitchLossStreak == 0 && !win)
            {
                NewHigh = !NewBet.High;
                return(true);
            }
            if (EnableSwitchBets && Stats.Bets % SwitchBets == 0)
            {
                NewHigh = !NewBet.High;
                return(true);
            }
            return(false);
        }
Exemple #3
0
        private DiceBet SimulatedBet(PlaceDiceBet NewBet)
        {
            //get RNG result from site
            decimal Lucky = 0;

            if (!Site.NonceBased)
            {
                GenerateSeeds();
            }

            Lucky = Site.GetLucky(serverseedhash, serverseed, clientseed, (int)BetsWithSeed);

            DiceBet betresult = new DiceBet {
                TotalAmount = NewBet.Amount,
                Chance      = NewBet.Chance,
                ClientSeed  = clientseed,
                Currency    = "simulation",
                DateValue   = DateTime.Now,
                Guid        = null,
                High        = NewBet.High,
                Nonce       = BetsWithSeed,
                Roll        = Lucky,
                ServerHash  = serverseedhash,
                ServerSeed  = serverseed
            };

            betresult.Profit = betresult.GetWin(Site) ?  ((((100.0m - Site.Edge) / NewBet.Chance) * NewBet.Amount) - NewBet.Amount): -NewBet.Amount;
            OnBetSimulated?.Invoke(this, new BetFinisedEventArgs(betresult));
            return(betresult);
        }
Exemple #4
0
        void processbet(NSBet tmpbbet)
        {
            DiceBet newbet = new DiceBet
            {
                BetID       = tmpbbet.id,
                TotalAmount = decimal.Parse(tmpbbet.betAmount, System.Globalization.NumberFormatInfo.InvariantInfo),
                DateValue   = DateTime.Now,
                ClientSeed  = tmpbbet.dice.clientSeed,
                High        = tmpbbet.betCondition == "H",
                Chance      = tmpbbet.betCondition == "H" ? MaxRoll - decimal.Parse(tmpbbet.betTarget, System.Globalization.NumberFormatInfo.InvariantInfo) : decimal.Parse(tmpbbet.betTarget, System.Globalization.NumberFormatInfo.InvariantInfo),
                Nonce       = tmpbbet.nonce,
                Guid        = this.Guid,
                Roll        = decimal.Parse(tmpbbet.roll, System.Globalization.NumberFormatInfo.InvariantInfo),
                ServerHash  = tmpbbet.dice.serverSeedHash
            };

            newbet.Profit = tmpbbet.outcome == "W" ? decimal.Parse(tmpbbet.profitAmount, System.Globalization.NumberFormatInfo.InvariantInfo) : -newbet.TotalAmount;
            if (tmpbbet.outcome == "W")
            {
                Stats.Wins++;
            }
            else
            {
                Stats.Losses++;
            }
            Stats.Bets++;
            Stats.Balance  = decimal.Parse(tmpbbet.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
            Stats.Wagered += newbet.TotalAmount;
            Stats.Profit  += newbet.Profit;
            callBetFinished(newbet);
        }
Exemple #5
0
        public PlaceDiceBet CalculateNextDiceBet(DiceBet PreviousBet, bool Win)
        {
            decimal      Lastbet = PreviousBet.TotalAmount;
            SessionStats Stats   = this.Stats;

            if (Win)
            {
                if ((Stats.WinStreak) % (AlembertStretchWin + 1) == 0)
                {
                    Lastbet += AlembertIncrementWin;
                }
            }
            else
            {
                if ((Stats.LossStreak) % (AlembertStretchLoss + 1) == 0)
                {
                    Lastbet += AlembertIncrementLoss;
                }
            }
            if (Lastbet < MinBet)
            {
                Lastbet = MinBet;
            }

            return(new PlaceDiceBet(Lastbet, High, PreviousBet.Chance));
        }
Exemple #6
0
 public void PlaceDiceBet(PlaceDiceBet BetDetails)
 {
     try
     {
         string sEmitResponse = Client.GetStringAsync(string.Format(
                                                          "placebet.php?ctoken={0}&betInSatoshis={1}&" +
                                                          "id={2}&serverHash={3}&clientRoll={4}&belowRollToWin={5}",
                                                          accesstoken,
                                                          (BetDetails.Amount * 100000000m).ToString("0", System.Globalization.NumberFormatInfo.InvariantInfo),
                                                          GameID,
                                                          curHash,
                                                          R.Next(0, int.MaxValue).ToString(),
                                                          ((BetDetails.Chance / 100m) * 65535).ToString("0"))).Result;
         SatGame betresult = json.JsonDeserialize <SatGame>(sEmitResponse);
         if (betresult.status == "success")
         {
             DiceBet tmpRes = new DiceBet()
             {
                 TotalAmount = (decimal)betresult.bet.betInSatoshis / 100000000m,
                 DateValue   = DateTime.Now,
                 Chance      = decimal.Parse(betresult.bet.probability),
                 ClientSeed  = betresult.clientRoll.ToString(),
                 High        = false,
                 BetID       = betresult.bet.betID.ToString(),
                 Nonce       = -1,
                 Profit      = (decimal)betresult.bet.profitInSatoshis / 100000000m,
                 ServerHash  = betresult.serverHash,
                 ServerSeed  = betresult.serverRoll + "-" + betresult.serverSalt,
                 Roll        = decimal.Parse(betresult.bet.rollInPercent),
                 Guid        = BetDetails.GUID
             };
             Stats.Balance = betresult.userBalanceInSatoshis / 100000000.0m;
             Stats.Bets++;
             if (betresult.bet.result == "loss")
             {
                 Stats.Losses++;
             }
             else
             {
                 Stats.Wins++;
             }
             Stats.Wagered += tmpRes.TotalAmount;
             Stats.Profit  += tmpRes.Profit;
             curHash        = betresult.nextRound.hash;
             GameID         = betresult.nextRound.id;
             callBetFinished(tmpRes);
         }
         else
         {
             callError(betresult.message, false, ErrorType.Unknown);
         }
     }
     catch
     {
         callError("An error has occurred.", false, ErrorType.Unknown);
     }
 }
Exemple #7
0
        public PlaceDiceBet CalculateNextDiceBet(DiceBet PreviousBet, bool Win)
        {
            decimal Lastbet = PreviousBet.TotalAmount;

            if (Win)
            {
                switch (WinAction)
                {
                case "Step": presetLevel += WinStep; break;

                case "Stop": CallStop("Stop on win set in preset list."); break;

                case "Reset": presetLevel = 0; break;
                }
            }
            else
            {
                switch (LossAction)
                {
                case "Step": presetLevel += LossStep; break;

                case "Stop": CallStop("Stop on Loss set in preset list."); break;

                case "Reset": presetLevel = 0; break;
                }
            }
            if (presetLevel < 0)
            {
                presetLevel = 0;
            }
            if (presetLevel > PresetBets.Count - 1)
            {
                switch (EndAction)
                {
                case "Step": while (presetLevel > PresetBets.Count - 1)
                    {
                        presetLevel -= EndStep;
                    }
                    break;

                case "Stop": CallStop("End of preset list reached"); break;

                case "Reset": presetLevel = 0; break;
                }
            }

            if (presetLevel < PresetBets.Count)
            {
                Lastbet = SetPresetValues(presetLevel);
            }
            else
            {
                CallStop("It Seems a problem has occurred with the preset list values");
            }
            return(new PlaceDiceBet(Lastbet, High, Chance));
        }
Exemple #8
0
        public PlaceDiceBet CalculateNextDiceBet(DiceBet PreviousBet, bool Win)
        {
            decimal LastBet = PreviousBet.TotalAmount;

            if (Win)
            {
                if (EnableFiboWinIncrement)
                {
                    FibonacciLevel += FiboWinIncrement;
                }
                else if (EnableFiboWinReset)
                {
                    FibonacciLevel = 0;
                }
                else
                {
                    FibonacciLevel = 0;
                    CallStop("Fibonacci bet won.");
                }
            }
            else
            {
                if (EnableFiboLossIncrement)
                {
                    FibonacciLevel += FiboLossIncrement;
                }
                else if (EnableFiboLossReset)
                {
                    FibonacciLevel = 0;
                }
                else
                {
                    FibonacciLevel = 0;
                    CallStop("Fibonacci bet lost.");
                }
            }
            if (FibonacciLevel < 0)
            {
                FibonacciLevel = 0;
            }

            if (FibonacciLevel >= FiboLeve & EnableFiboLevel)
            {
                if (EnableFiboLevelReset)
                {
                    FibonacciLevel = 0;
                }
                else
                {
                    FibonacciLevel = 0;
                    CallStop("Fibonacci level " + FiboLeve + ".");
                }
            }
            LastBet = CalculateFibonacci(FibonacciLevel);
            return(new PlaceDiceBet(LastBet, High, PreviousBet.Chance));
        }
Exemple #9
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            try
            {
                byte[] bytes = new byte[4];
                Rg.GetBytes(bytes);
                string seed = ((long)BitConverter.ToUInt32(bytes, 0)).ToString();
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                pairs.Add(new KeyValuePair <string, string>("wager", (BetDetails.Amount).ToString("0.00000000")));
                pairs.Add(new KeyValuePair <string, string>("region", BetDetails.High ? ">" : "<"));
                pairs.Add(new KeyValuePair <string, string>("target", (BetDetails.High ? MaxRoll - BetDetails.Chance : BetDetails.Chance).ToString("0.00")));
                pairs.Add(new KeyValuePair <string, string>("odds", BetDetails.Chance.ToString("0.00")));
                pairs.Add(new KeyValuePair <string, string>("clientSeed", seed));
                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string     sEmitResponse      = Client.PostAsync("bet", Content).Result.Content.ReadAsStringAsync().Result;
                CoinProBet tmpbet             = json.JsonDeserialize <CoinProBet>(sEmitResponse);
                DiceBet    tmp = new DiceBet
                {
                    Guid        = BetDetails.GUID,
                    TotalAmount = (decimal)BetDetails.Amount,
                    DateValue   = DateTime.Now,
                    BetID       = tmpbet.bet_id.ToString(),
                    Profit      = (decimal)tmpbet.profit / 100000000m,
                    Roll        = (decimal)tmpbet.outcome,
                    High        = BetDetails.High,
                    Chance      = (decimal)BetDetails.Chance,
                    Nonce       = (int)(tmpbet.outcome * 100),
                    ServerHash  = lasthash,
                    ServerSeed  = tmpbet.secret.ToString(),
                    ClientSeed  = seed
                };

                lasthash = tmpbet.next_hash;
                Stats.Bets++;
                bool Win = (((bool)tmp.High ? (decimal)tmp.Roll > (decimal)MaxRoll - (decimal)(tmp.Chance) : (decimal)tmp.Roll < (decimal)(tmp.Chance)));
                if (Win)
                {
                    Stats.Wins++;
                }
                else
                {
                    Stats.Losses++;
                }
                Stats.Wagered += BetDetails.Amount;
                Stats.Profit  += tmp.Profit;
                Stats.Balance  = tmpbet.balance / 100000000m;
                callBetFinished(tmp);
            }
            catch (Exception e)
            {
                Logger.DumpLog(e.ToString(), -1);
                callError("An unknown error has occured while placing a bet.", false, ErrorType.Unknown);
            }
        }
 private DiceBetDto CreateBetDTO(DiceBet bet)
 {
     return(new DiceBetDto()
     {
         Id = bet.Id,
         UserId = bet.UserId,
         DiceSumBet = bet.DiceSumBet,
         DiceSumResult = bet.DiceSumResult,
         Stake = bet.Stake,
         Win = bet.Win,
         CreationDate = bet.CreationDate
     });
 }
 public PlaceDiceBet CalculateNextDiceBet(DiceBet PreviousBet, bool Win)
 {
     try
     {
         PlaceDiceBet NextBet = new PlaceDiceBet(PreviousBet.TotalAmount, PreviousBet.High, PreviousBet.Chance);
         //TypeReference.CreateTypeReference
         Runtime.Invoke("DoDiceBet", PreviousBet, Win, NextBet);
         return(NextBet);
     }
     catch (Exception e)
     {
         OnScriptError?.Invoke(this, new PrintEventArgs {
             Message = e.ToString()
         });
     }
     return(null);
 }
Exemple #12
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            decimal       amount  = BetDetails.Amount;
            decimal       chance  = BetDetails.Chance;
            bool          High    = BetDetails.High;
            StringContent Content = new StringContent(string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "{{\"amount\":\"{0:0.00000000}\",\"symbol\":\"{1}\",\"chance\":{2:0.00},\"isHigh\":{3}}}", amount, CurrentCurrency, chance, High ? "true" : "false"), Encoding.UTF8, "application/json");

            try
            {
                string   sEmitResponse = Client.PostAsync("play" + "?api_key=" + accesstoken, Content).Result.Content.ReadAsStringAsync().Result;
                QuackBet newbet        = json.JsonDeserialize <QuackBet>(sEmitResponse);
                if (newbet.error != null)
                {
                    callError(newbet.error, true, ErrorType.Unknown);
                    return;
                }
                DiceBet tmp = new DiceBet
                {
                    TotalAmount = decimal.Parse(newbet.bet.betAmount, System.Globalization.NumberFormatInfo.InvariantInfo),
                    Chance      = newbet.bet.chance,
                    ClientSeed  = currentseed.clientSeed,
                    Currency    = CurrentCurrency,
                    DateValue   = DateTime.Now,
                    High        = High,
                    Nonce       = currentseed.nonce++,
                    Profit      = decimal.Parse(newbet.bet.profit, System.Globalization.NumberFormatInfo.InvariantInfo),
                    Roll        = newbet.bet.number / 100,
                    ServerHash  = currentseed.serverSeedHash,
                    BetID       = newbet.bet.hash,
                    Guid        = BetDetails.GUID
                };
                lastupdate    = DateTime.Now;
                Stats.Profit  = decimal.Parse(newbet.user.profit, System.Globalization.NumberFormatInfo.InvariantInfo);
                Stats.Wagered = decimal.Parse(newbet.user.volume, System.Globalization.NumberFormatInfo.InvariantInfo);
                Stats.Balance = decimal.Parse(newbet.user.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                Stats.Wins    = newbet.user.wins;
                Stats.Bets    = newbet.user.bets;
                Stats.Losses  = newbet.user.bets - newbet.user.wins;
                callBetFinished(tmp);
            }
            catch (Exception e)
            {
                callError("There was an error placing your bet.", true, ErrorType.Unknown);
                Logger.DumpLog(e);
            }
        }
Exemple #13
0
            public DiceBet ToBet()
            {
                DiceBet tmp = new DiceBet
                {
                    TotalAmount = decimal.Parse(amount, System.Globalization.NumberFormatInfo.InvariantInfo),
                    DateValue   = DateTime.Now,
                    BetID       = id,
                    Profit      = decimal.Parse(profit, System.Globalization.NumberFormatInfo.InvariantInfo),
                    Roll        = (decimal)result,
                    High        = over,
                    Chance      = chance,
                    Nonce       = nonce,
                    ServerHash  = server_seed,
                    ClientSeed  = client_seed
                };

                return(tmp);
            }
Exemple #14
0
        public PlaceDiceBet CalculateNextDiceBet(DiceBet PreviousBet, bool Win)
        {
            try
            {
                PlaceDiceBet NextBet = new PlaceDiceBet(PreviousBet.TotalAmount, PreviousBet.High, PreviousBet.Chance);

                dynamic result = Scope.DoDiceBet(PreviousBet, Win, NextBet);

                return(NextBet);
            }
            catch (Exception e)
            {
                OnScriptError?.Invoke(this, new PrintEventArgs {
                    Message = e.ToString()
                });
            }
            return(null);
        }
 public PlaceDiceBet CalculateNextDiceBet(DiceBet PreviousBet, bool Win)
 {
     try
     {
         PlaceDiceBet NextBet   = new PlaceDiceBet(PreviousBet.TotalAmount, PreviousBet.High, PreviousBet.Chance);
         DynValue     DoDiceBet = CurrentRuntime.Globals.Get("DoDiceBet");
         if (DoDiceBet != null)
         {
             DynValue Result = CurrentRuntime.Call(DoDiceBet, PreviousBet, Win, NextBet);
         }
         return(NextBet);
     }
     catch (InternalErrorException e)
     {
         OnScriptError?.Invoke(this, new PrintEventArgs {
             Message = e.DecoratedMessage
         });
         //throw e;
     }
     catch (SyntaxErrorException e)
     {
         OnScriptError?.Invoke(this, new PrintEventArgs {
             Message = e.DecoratedMessage
         });
         //throw e;
     }
     catch (ScriptRuntimeException e)
     {
         OnScriptError?.Invoke(this, new PrintEventArgs {
             Message = e.DecoratedMessage
         });
         // throw e;
     }
     catch (Exception e)
     {
         OnScriptError?.Invoke(this, new PrintEventArgs {
             Message = e.ToString()
         });
         // throw e;
     }
     return(null);
 }
        public DiceBetDto Create(DiceBetDto bet)
        {
            var newBet = new DiceBet()
            {
                UserId        = bet.UserId,
                DiceSumBet    = bet.DiceSumBet,
                DiceSumResult = bet.DiceSumResult,
                Stake         = bet.Stake,
                Win           = bet.Win,
                CreationDate  = bet.CreationDate
            };

            using (var db = new OnlineCasinoDb())
            {
                db.DiceBets.Add(newBet);
                db.SaveChanges();
            }

            return(CreateBetDTO(newBet));
        }
Exemple #17
0
        public PlaceDiceBet CalculateNextDiceBet(DiceBet PreviousBet, bool Win)
        {
            try
            {
                PlaceDiceBet NextBet = new PlaceDiceBet(PreviousBet.TotalAmount, PreviousBet.High, PreviousBet.Chance);

                globals.NextDiceBet     = NextBet;
                globals.PreviousDiceBet = PreviousBet;
                globals.DiceWin         = Win;
                //if (DoDiceBet == null)
                {
                    runtime   = runtime.ContinueWithAsync("DoDiceBet(PreviousDiceBet, DiceWin, NextDiceBet)").Result;
                    DoDiceBet = runtime.Script;
                }

                /*else
                 * runtime = runtime.ContinueWithAsync("DoDiceBet(PreviousDiceBet, DiceWin, NextDiceBet)", ScriptOptions.Default.WithReferences(
                 *      Assembly.GetExecutingAssembly())
                 *      .WithImports(
                 *          "DoormatBot",
                 *          "DoormatBot.Games",
                 *          "System")).Result;*/


                //;

                /*else
                 *  runtime = DoDiceBet.RunFromAsync(runtime).Result;*/
                return(NextBet);
            }
            catch (Exception e)
            {
                OnScriptError?.Invoke(this, new PrintEventArgs {
                    Message = e.ToString()
                });
            }
            return(null);
        }
Exemple #18
0
        void ProcessBet(string Res)
        {
            //433[null,{"created_at":"2019-01-19T11:47:37.991Z","raw_outcome":4264578078,"uname":"seuntjie","secret":2732336931,"salt":"7e59aAbbf531c9649a89a761ac96aba8","hash":"8cf7f15c173d47020d99b20bfa65f4b438799254b69ea8d208aba7fb4dc1c244","client_seed":1532241147,"payouts":[{"from":2168956358,"to":4294967295,"value":2}],"wager":1,"profit":1,"kind":"DICE","edge":1,"ref":null,"currency":"BXO","_id":3917670,"id":3917670,"next_hash":"dc407a52731281f7d9d32eb4e3dff3c84828b4284071483f9826a3072085261c","outcome":99.2923}]
            BEBetResult tmpResult = json.JsonDeserialize <BEBetResult>(Res);
            DiceBet     newBet    = new DiceBet
            {
                TotalAmount = ((decimal)tmpResult.wager) / 100000000m,
                DateValue   = DateTime.Now,
                ClientSeed  = tmpResult.client_seed.ToString(),
                Currency    = CurrentCurrency,
                Guid        = guid,
                High        = this.High,
                Nonce       = -1,
                BetID       = tmpResult.id.ToString(),
                Roll        = (decimal)tmpResult.outcome,
                ServerHash  = ServerHash,
                ServerSeed  = tmpResult.secret + "-" + tmpResult.salt,
                Profit      = ((decimal)tmpResult.profit) / 100000000m,
                Chance      = Chance
            };

            Stats.Bets++;
            Stats.Wagered += newBet.TotalAmount;
            Stats.Balance += newBet.Profit;
            Stats.Profit  += newBet.Profit;
            if ((newBet.High && newBet.Roll > MaxRoll - newBet.Chance) || (!newBet.High && newBet.Roll < newBet.Chance))
            {
                Stats.Wins++;
            }
            else
            {
                Stats.Losses++;
            }
            this.ServerHash = tmpResult.next_hash;
            callBetFinished(newBet);
        }
Exemple #19
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            string err = "";

            try
            {
                bool    High   = BetDetails.High;
                decimal amount = BetDetails.Amount;

                decimal chance = (999999.0m) * (BetDetails.Chance / 100.0m);
                //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"))
                            {
                                PlaceDiceBet(BetDetails);
                                return;
                            }
                        }
                    }
                    if (responseData.Contains("error"))
                    {
                        if (retrycount++ < 3)
                        {
                            Thread.Sleep(200);
                            PlaceBet(BetDetails);
                            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)((decimal)amount * 100000000m)).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", CurrentCurrency));
                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)
                    {
                        Logger.DumpLog(e);
                        callError(e.ToString(), true, ErrorType.Unknown);
                    }
                }
                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 || tmpBet.error != null)
                {
                    ErrorType typ = ErrorType.Unknown;
                    string    msg = tmpBet.error;
                    if (tmpBet.ChanceTooHigh == 1)
                    {
                        typ = ErrorType.InvalidBet;
                        msg = "Chance too high";
                    }
                    if (tmpBet.ChanceTooLow == 1)
                    {
                        typ = ErrorType.InvalidBet;
                        msg = "Chance too Low";
                    }
                    if (tmpBet.InsufficientFunds == 1)
                    {
                        typ = ErrorType.BalanceTooLow;
                        msg = "Insufficient Funds";
                    }
                    if (tmpBet.MaxPayoutExceeded == 1)
                    {
                        typ = ErrorType.InvalidBet;
                        msg = "Max Payout Exceeded";
                    }
                    if (tmpBet.NoPossibleProfit == 1)
                    {
                        typ = ErrorType.InvalidBet;
                        msg = "No Possible Profit";
                    }
                    callError(msg, false, typ);
                }
                else if (tmpBet.BetId == 0)
                {
                    throw new Exception();
                }
                else
                {
                    Stats.Balance = (decimal)tmpBet.StartingBalance / 100000000.0m - (amount) + ((decimal)tmpBet.PayOut / 100000000.0m);

                    Stats.Profit += -(amount) + (decimal)(tmpBet.PayOut / 100000000m);
                    DiceBet tmp = new DiceBet();
                    tmp.Guid        = BetDetails.GUID;
                    tmp.TotalAmount = (decimal)amount;
                    tmp.DateValue   = DateTime.Now;
                    tmp.Chance      = ((decimal)chance * 100m) / 999999m;
                    tmp.ClientSeed  = ClientSeed;
                    tmp.Currency    = CurrentCurrency;
                    tmp.High        = High;
                    tmp.BetID       = tmpBet.BetId.ToString();
                    tmp.Nonce       = 0;
                    tmp.Profit      = ((decimal)tmpBet.PayOut / 100000000m) - ((decimal)amount);
                    tmp.Roll        = tmpBet.Secret / 10000m;
                    tmp.ServerHash  = next;
                    tmp.ServerSeed  = tmpBet.ServerSeed;

                    /*tmp.Userid = (int)uid;
                     * tmp. = "";*/

                    bool win = false;
                    if ((tmp.Roll > 99.99m - tmp.Chance && High) || (tmp.Roll < tmp.Chance && !High))
                    {
                        win = true;
                    }
                    if (win)
                    {
                        Stats.Wins++;
                    }
                    else
                    {
                        Stats.Losses++;
                    }
                    Stats.Wagered += tmp.TotalAmount;
                    Stats.Bets++;


                    // sqlite_helper.InsertSeed(tmp.serverhash, tmp.serverseed);
                    next       = tmpBet.Next;
                    retrycount = 0;
                    callBetFinished(tmp);
                }
            }
            catch (Exception e)
            {
                Logger.DumpLog(e.ToString(), -1);
                callError(e.ToString(), true, ErrorType.Unknown);
            }
        }
Exemple #20
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            try
            {
                bool    High   = BetDetails.High;
                decimal amount = BetDetails.Amount;
                decimal chance = BetDetails.Chance;
                string  chars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZqwertyuiopasdfghjklzxcvbnm1234567890";
                while (clientseed.Length < 16)
                {
                    clientseed += chars[R.Next(0, chars.Length)];
                }
                string Params = string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "m={0}&client_seed={1}&jackpot=0&stake={2}&multiplier={3}&rand={5}&csrf_token={4}",
                                              High ? "hi" : "lo", clientseed, amount, (100m - Edge) / chance, csrf, R.Next(0, 9999999) / 10000000);

                var betresult = Client.GetAsync("https://freebitco.in/cgi-bin/bet.pl?" + Params).Result;
                if (betresult.IsSuccessStatusCode)
                {
                    string   Result = betresult.Content.ReadAsStringAsync().Result;
                    string[] msgs   = Result.Split(':');
                    if (msgs.Length > 2)
                    {
                        /*
                         *  1. Success code (s1)
                         *  2. Result (w/l)
                         *  3. Rolled number
                         *  4. User balance
                         *  5. Amount won or lost (always positive). If 2. is l, then amount is subtracted from balance else if w it is added.
                         *  6. Redundant (can ignore)
                         *  7. Server seed hash for next roll
                         *  8. Client seed of previous roll
                         *  9. Nonce for next roll
                         *  10. Server seed for previous roll
                         *  11. Server seed hash for previous roll
                         *  12. Client seed again (can ignore)
                         *  13. Previous nonce
                         *  14. Jackpot result (1 if won 0 if not won)
                         *  15. Redundant (can ignore)
                         *  16. Jackpot amount won (0 if lost)
                         *  17. Bonus account balance after bet
                         *  18. Bonus account wager remaining
                         *  19. Max. amount of bonus eligible
                         *  20. Max bet
                         *  21. Account balance before bet
                         *  22. Account balance after bet
                         *  23. Bonus account balance before bet
                         *  24. Bonus account balance after bet
                         */
                        DiceBet tmp = new DiceBet
                        {
                            Guid        = BetDetails.GUID,
                            TotalAmount = amount,
                            DateValue   = DateTime.Now,
                            Chance      = chance,
                            ClientSeed  = msgs[7],
                            High        = High,
                            BetID       = Stats.Bets.ToString(),
                            Profit      = msgs[1] == "w" ? decimal.Parse(msgs[4]) : -decimal.Parse(msgs[4], System.Globalization.NumberFormatInfo.InvariantInfo),
                            Nonce       = long.Parse(msgs[12], System.Globalization.NumberFormatInfo.InvariantInfo),
                            ServerHash  = msgs[10],
                            ServerSeed  = msgs[9],
                            Roll        = decimal.Parse(msgs[2], System.Globalization.NumberFormatInfo.InvariantInfo) / 100.0m
                        };
                        tmp.IsWin     = tmp.GetWin(this);
                        Stats.Balance = decimal.Parse(msgs[3], System.Globalization.NumberFormatInfo.InvariantInfo);
                        if (msgs[1] == "w")
                        {
                            Stats.Wins++;
                        }
                        else
                        {
                            Stats.Losses++;
                        }
                        Stats.Bets++;
                        Stats.Wagered += amount;
                        Stats.Profit  += tmp.Profit;
                        callBetFinished(tmp);
                    }
                    else if (msgs.Length > 0)
                    {
                        //20 - too low balance
                        if (msgs.Length > 1)

                        {
                            if (msgs[1] == "20")
                            {
                                callError("Balance too low.", true, ErrorType.BalanceTooLow);
                            }
                        }
                        else
                        {
                            callError("Site returned unknown error. Retrying in 30 seconds.", true, ErrorType.Unknown);
                        }
                    }
                    else
                    {
                        callError("Site returned unknown error. Retrying in 30 seconds.", true, ErrorType.Unknown);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.DumpLog(e);
                callError("An internal error occured. Retrying in 30 seconds.", true, ErrorType.Unknown);
            }
        }
Exemple #21
0
        void ProcessBet(string response)
        {
            YLBetResponse tmpbetrespo = json.JsonDeserialize <YLBetResponse>(response).result;

            lastbet = DateTime.Now;
            delay   = tmpbetrespo.delay;
            if (tmpbetrespo != null)
            {
                DiceBet tmp = new DiceBet()
                {
                    Guid        = Guid,
                    BetID       = tmpbetrespo.id.ToString(),
                    TotalAmount = (decimal)tmpbetrespo.amount / 100000000m,
                    DateValue   = DateTime.Now,
                    Chance      = (decimal)tmpbetrespo.target / 10000m,
                    High        = tmpbetrespo.range == "hi",
                    Profit      = (decimal)tmpbetrespo.profit / 100000000m,
                    Roll        = (decimal)tmpbetrespo.rolled / 10000m,
                    Nonce       = tmpbetrespo.nonce,
                    Currency    = tmpbetrespo.coin
                };
                bool     sent      = false;
                DateTime StartWait = DateTime.Now;
                if (Currentseed == null)
                {
                    //while (Currentseed == null && (DateTime.Now-StartWait).TotalSeconds<20)
                    {
                        if (!sent)
                        {
                            sent = true;
                            Write("read_seed", "{\"selector\":{\"id\":" + tmpbetrespo.seed_id + "}}");
                            callNotify("Getting seed data. Please wait.");
                        }
                        //Thread.Sleep(100);
                    }
                }
                if (Currentseed != null)
                {
                    if (Currentseed.id != tmpbetrespo.seed_id)
                    {
                        //while (Currentseed.id != tmpbetrespo.seed_id && (DateTime.Now - StartWait).TotalSeconds < 20)
                        {
                            if (!sent)
                            {
                                sent = true;
                                Write("read_seed", "{\"selector\":{\"id\":" + tmpbetrespo.seed_id + "}}");
                                callNotify("Getting seed data. Please wait.");
                            }
                            //Thread.Sleep(100);
                        }
                    }
                }
                if (Currentseed != null)
                {
                    tmp.ServerHash = Currentseed.secret_hashed;
                    tmp.ClientSeed = Currentseed.client_seed;
                }
                if (tmpbetrespo.user_data != null)
                {
                    Stats.Balance = (decimal)tmpbetrespo.user_data.balance / 100000000m;
                    Stats.Bets    = (int)tmpbetrespo.user_data.bets;
                    Stats.Wins    = (int)tmpbetrespo.user_data.wins;
                    Stats.Losses  = (int)tmpbetrespo.user_data.losses;
                    Stats.Profit  = (decimal)tmpbetrespo.user_data.profit / 100000000m;
                    Stats.Wagered = (decimal)tmpbetrespo.user_data.wagered / 100000000m;
                }
                else
                {
                    Stats.Balance += tmp.Profit;
                    Stats.Wagered += tmp.TotalAmount;
                    Stats.Bets++;
                    bool win = false;
                    if ((tmp.Roll > MaxRoll - tmp.Chance && tmp.High) || (tmp.Roll < tmp.Chance && !tmp.High))
                    {
                        win = true;
                    }
                    if (win)
                    {
                        Stats.Wins++;
                    }
                    else
                    {
                        Stats.Losses++;
                    }
                }
                callBetFinished(tmp);
            }
        }
Exemple #22
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            try
            {
                string ClientSeed = R.Next(0, 100).ToString();

                decimal amount    = BetDetails.Amount;
                decimal chance    = BetDetails.Chance;
                bool    High      = BetDetails.High;
                decimal tmpchance = High ? 99m - chance : chance;
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                pairs.Add(new KeyValuePair <string, string>("rollAmount", (amount * 100000000m).ToString("0", System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("rollUnder", tmpchance.ToString("0", System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("mode", High ? "2" : "1"));
                pairs.Add(new KeyValuePair <string, string>("rollClient", ClientSeed));
                pairs.Add(new KeyValuePair <string, string>("token", accesstoken));


                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string sEmitResponse          = Client.PostAsync("play.php", Content).Result.Content.ReadAsStringAsync().Result;
                //Lastbet = DateTime.Now;
                try
                {
                    KDBet tmp = json.JsonDeserialize <KDBet>(sEmitResponse);
                    if (tmp.roll_id != null && tmp.roll_id != null)
                    {
                        DiceBet tmpBet = new DiceBet
                        {
                            Guid        = BetDetails.GUID,
                            TotalAmount = amount,
                            DateValue   = DateTime.Now,
                            BetID       = tmp.roll_id.ToString(),
                            Profit      = tmp.roll_profit / 100000000m,
                            Roll        = tmp.roll_number,
                            High        = High,
                            Chance      = tmp.probability,
                            Nonce       = (long)tmp.provablef_serverRoll,
                            ServerHash  = LastHash,
                            ServerSeed  = tmp.provablef_Hash,
                            ClientSeed  = ClientSeed
                        };
                        if (tmp.roll_result == "win")
                        {
                            Stats.Wins++;
                        }
                        else
                        {
                            Stats.Losses++;
                        }
                        Stats.Wagered += amount;
                        Stats.Profit  += tmp.roll_profit / 100000000m;
                        Stats.Bets++;
                        LastHash      = tmp.roll_next.hash;
                        Stats.Balance = tmp.balance / 100000000m;
                        callBetFinished(tmpBet);
                    }
                    else
                    {
                        callError("An unknown error has occurred. Bet will retry in 30 seconds.", true, ErrorType.Unknown);
                    }
                    //retrycount = 0;
                }
                catch (Exception e)
                {
                    Logger.DumpLog(e);
                    callError(sEmitResponse, true, ErrorType.Unknown);
                }
            }
            catch (Exception e)
            { Logger.DumpLog(e); }
        }
Exemple #23
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            string     Clients     = R.Next(0, int.MaxValue).ToString();
            decimal    payout      = decimal.Parse(((100m - Edge) / (decimal)BetDetails.Chance).ToString("0.0000"));
            cgPlaceBet tmpPlaceBet = new cgPlaceBet()
            {
                Bet = BetDetails.Amount, ClientSeed = Clients, UnderOver = BetDetails.High, Payout = (decimal)payout
            };

            string      post = json.JsonSerializer <cgPlaceBet>(tmpPlaceBet);
            HttpContent cont = new StringContent(post);

            cont.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");

            /*List<KeyValuePair<string, string>> pairs = new List<KeyValuePair<string, string>>();
             * pairs.Add(new KeyValuePair<string, string>("value", post));
             * //pairs.Add(new KeyValuePair<string, string>("affiliate", "seuntjie"));
             * FormUrlEncodedContent cont = new FormUrlEncodedContent(pairs);*/

            try
            {
                string   sEmitResponse = Client.PostAsync("placebet/" + CurrentCurrency + "/" + accesstoken, cont).Result.Content.ReadAsStringAsync().Result;
                cgGetBet Response      = json.JsonDeserialize <cgGetBet>(sEmitResponse);
                if (Response.Message != "" && Response.Message != null)
                {
                    callError(Response.Message, true, ErrorType.Unknown);
                    return;
                }
                DiceBet bet = new DiceBet()
                {
                    Guid        = BetDetails.GUID,
                    TotalAmount = (decimal)BetDetails.Amount,
                    Profit      = (decimal)Response.Profit,
                    Roll        = (decimal)Response.Roll,
                    Chance      = decimal.Parse(Response.Target.Substring(3), System.Globalization.NumberFormatInfo.InvariantInfo),
                    DateValue   = DateTime.Now,
                    ClientSeed  = Clients,
                    Currency    = CurrentCurrency,
                    BetID       = Response.BetId.ToString(),
                    High        = Response.Target.Contains(">"),
                    ServerHash  = CurrenyHash,
                    Nonce       = -1,
                    ServerSeed  = Response.ServerSeed
                };
                if (bet.High)
                {
                    bet.Chance = (decimal)MaxRoll - bet.Chance;
                }
                this.CurrenyHash = Response.NextServerSeedHash;
                bool Win = (((bool)bet.High ? (decimal)bet.Roll > (decimal)MaxRoll - (decimal)(bet.Chance) : (decimal)bet.Roll < (decimal)(bet.Chance)));
                if (Win)
                {
                    Stats.Wins++;
                }
                else
                {
                    Stats.Losses++;
                }
                Stats.Bets++;
                Stats.Wagered += bet.TotalAmount;
                Stats.Balance += Response.Profit;
                Stats.Profit  += Response.Profit;
                callBetFinished(bet);
            }
            catch
            { }
        }
Exemple #24
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            decimal low  = 0;
            decimal high = 0;

            if (BetDetails.High)
            {
                high = MaxRoll * 100;
                low  = (MaxRoll - BetDetails.Chance) * 100 + 1;
            }
            else
            {
                high = BetDetails.Chance * 100 - 1;
                low  = 0;
            }
            string loginjson = json.JsonSerializer <WDPlaceBet>(new WDPlaceBet()
            {
                curr = CurrentCurrency,
                bet  = BetDetails.Amount,
                game = "in",
                high = (int)high,
                low  = (int)low
            });

            HttpContent cont = new StringContent(loginjson);

            cont.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            HttpResponseMessage resp2 = Client.PostAsync("roll", cont).Result;

            if (resp2.IsSuccessStatusCode)
            {
                string response   = resp2.Content.ReadAsStringAsync().Result;
                WDBet  tmpBalance = json.JsonDeserialize <WDBet>(response);
                if (tmpBalance.status == "success")
                {
                    DiceBet Result = new DiceBet()
                    {
                        TotalAmount = BetDetails.Amount,
                        DateValue   = DateTime.Now,
                        Chance      = tmpBalance.data.chance,
                        ClientSeed  = currentseed.client,
                        Currency    = CurrentCurrency,
                        Guid        = BetDetails.GUID,
                        BetID       = tmpBalance.data.hash,
                        High        = BetDetails.High,
                        Nonce       = tmpBalance.data.nonce,
                        Profit      = tmpBalance.data.win - tmpBalance.data.bet,
                        Roll        = tmpBalance.data.result / 100m,
                        ServerHash  = currentseed.hash
                    };
                    Stats.Bets++;
                    bool Win = (((bool)BetDetails.High ? (decimal)Result.Roll > (decimal)MaxRoll - (decimal)(BetDetails.Chance) : (decimal)Result.Roll < (decimal)(BetDetails.Chance)));
                    if (Win)
                    {
                        Stats.Wins++;
                    }
                    else
                    {
                        Stats.Losses++;
                    }
                    Stats.Wagered += BetDetails.Amount;
                    Stats.Profit  += Result.Profit;
                    Stats.Balance += Result.Profit;
                    callBetFinished(Result);
                }
                else
                {
                    callNotify(tmpBalance.message);
                    callError(tmpBalance.message, false, ErrorType.Unknown);
                }
            }
        }
Exemple #25
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(seed))
                {
                    seed = RandomSeed();
                }
                decimal amount = BetDetails.Amount;
                decimal chance = BetDetails.Chance;
                bool    High   = BetDetails.High;

                decimal tmpchance = High ? MaxRoll - chance + 0.0001m : chance - 0.0001m;
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();

                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", CurrencyMap[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
                {
                    string     x   = sEmitResponse.Replace("f-", "f_").Replace("n-", "n_").Replace("ce-", "ce_").Replace("r-", "r_");
                    bitvestbet tmp = json.JsonDeserialize <bitvestbet>(x);
                    if (tmp.success)
                    {
                        DiceBet resbet = new DiceBet
                        {
                            TotalAmount = amount,
                            DateValue   = DateTime.Now,
                            Chance      = chance,
                            High        = High,
                            ClientSeed  = seed,
                            ServerHash  = tmp.server_hash,
                            ServerSeed  = tmp.server_seed,
                            Roll        = (decimal)tmp.game_result.roll,
                            Profit      = tmp.game_result.win == 0 ? -amount : (decimal)tmp.game_result.win - amount,
                            Nonce       = long.Parse(tmp.player_seed.Substring(tmp.player_seed.IndexOf("|") + 1)),
                            BetID       = tmp.game_id.ToString(),
                            Currency    = Currencies[Currency]
                        };
                        resbet.Guid = BetDetails.GUID;
                        Stats.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)
                        {
                            Stats.Wins++;
                        }
                        else
                        {
                            Stats.Losses++;
                        }
                        Stats.Wagered += amount;
                        Stats.Profit  += resbet.Profit;
                        Stats.Balance  = decimal.Parse(CurrencyMap[Currency].ToLower() == "bitcoins" ?
                                                       tmp.data.balance :
                                                       CurrencyMap[Currency].ToLower() == "ethers" ? tmp.data.balance_ether
                                : CurrencyMap[Currency].ToLower() == "litecoins" ? tmp.data.balance_litecoin :
                                                       CurrencyMap[Currency].ToLower() == "dogecoins" ? tmp.data.balance_dogecoin :
                                                       CurrencyMap[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);
                         */
                        callBetFinished(resbet);
                        retrycount = 0;
                    }
                    else
                    {
                        if (tmp.msg == "Insufficient Funds")
                        {
                            callError(tmp.msg, false, ErrorType.BalanceTooLow);
                        }
                        callNotify(tmp.msg);
                        if (tmp.msg.ToLower() == "bet rate limit exceeded")
                        {
                            /*callNotify(tmp.msg + ". Retrying in a second;");
                             * Thread.Sleep(1000);
                             * placebetthread(bet);
                             * return;*/
                        }
                        else
                        {
                            callError(tmp.msg, false, ErrorType.InvalidBet);
                        }
                    }
                }
                catch (Exception e)
                {
                    callNotify("An unknown error has occurred");
                    Logger.DumpLog(e);
                }
            }
            catch (AggregateException e)
            {
                if (retrycount++ < 3)
                {
                    Thread.Sleep(500);
                    PlaceDiceBet(BetDetails);
                    return;
                }
                if (e.InnerException.Message.Contains("429") || e.InnerException.Message.Contains("502"))
                {
                    Thread.Sleep(500);
                    PlaceDiceBet(BetDetails);
                }
            }
            catch (Exception e2)
            {
            }
        }
Exemple #26
0
        private void TableView_RowDoubleClick(object sender, DevExpress.Xpf.Grid.RowDoubleClickEventArgs e)
        {
            DiceBet bet = gcDiceBets.SelectedItem as DiceBet;

            BetClicked?.Invoke(this, new ViewBetEventArgs(bet));
        }
Exemple #27
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            try
            {
                string Highlow = BetDetails.High ? "high" : "low";
                string request = string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "dice?api_key={0}&currency={1}&amount={2}&chance={3}&type={4}",
                                               APIKey,
                                               CurrentCurrency,
                                               BetDetails.Amount,
                                               BetDetails.Chance,
                                               Highlow);
                var    BetResponse = Client.PostAsync(request, new StringContent("")).Result;
                string sbetresult  = BetResponse.Content.ReadAsStringAsync().Result;

                BDBetResponse NewBet = json.JsonDeserialize <BDBetResponse>(sbetresult);
                try
                {
                    if (!string.IsNullOrWhiteSpace(NewBet.error))
                    {
                        if (NewBet.error.ToLower().StartsWith("minimum bet amount is") || NewBet.error.ToLower().StartsWith("you can bet on "))
                        {
                            callError(NewBet.error, false, ErrorType.InvalidBet);
                        }
                        else if (NewBet.error.ToLower() == "your balance is too low")
                        {
                            callError(NewBet.error, false, ErrorType.BalanceTooLow);
                        }

                        callError(NewBet.error, false, ErrorType.Unknown);
                        return;
                    }
                    if (CurrentSeed.id != NewBet.bet.data.secret)
                    {
                        string SecretResponse = Client.GetStringAsync($"dice/secret?api_key={APIKey}").Result;
                        BDSeed tmpSeed        = json.JsonDeserialize <BDSeed>(SecretResponse);
                        CurrentSeed = tmpSeed;
                    }
                    Bet result = new DiceBet
                    {
                        TotalAmount = NewBet.bet.amount,
                        DateValue   = DateTime.Now,
                        Chance      = NewBet.bet.data.chance,
                        ClientSeed  = CurrentSeed.hash,//-----------THIS IS WRONG! THIS NEEDS TO BE FIXED AT SOME POINT BEFORE GOING LIVE
                        Guid        = BetDetails.GUID,
                        Currency    = Currencies[Currency],
                        High        = NewBet.bet.data.high,
                        BetID       = NewBet.bet.id.ToString(),
                        Nonce       = NewBet.bet.data.nonce,
                        Profit      = NewBet.bet.profit,
                        Roll        = NewBet.bet.data.lucky,
                        ServerHash  = CurrentSeed.hash,
                        //serverseed = NewBet.old.secret
                    };


                    //CurrentSeed = new BDSeed { hash = NewBet.secret.hash, id = NewBet.secret.id };
                    bool win = NewBet.bet.data.result;
                    if (win)
                    {
                        Stats.Wins++;
                    }
                    else
                    {
                        Stats.Losses++;
                    }
                    Stats.Bets++;
                    Stats.Wagered += result.TotalAmount;
                    Stats.Profit  += result.Profit;
                    Stats.Balance  = NewBet.balance;

                    callBetFinished(result);
                }
                catch (Exception e)
                {
                    Logger.DumpLog(e);
                    callError(e.ToString(), false, ErrorType.Unknown);
                }
            }
            catch (Exception e)
            {
                Logger.DumpLog(e);
                callError(e.ToString(), false, ErrorType.Unknown);
            }
        }
Exemple #28
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            try
            {
                decimal amount = BetDetails.Amount;
                decimal chance = BetDetails.Chance;
                bool    High   = BetDetails.High;

                /*if (amount < 10000 && (DateTime.Now - Lastbet).TotalMilliseconds < 500)
                 * {
                 *  Thread.Sleep((int)(500.0 - (DateTime.Now - Lastbet).TotalMilliseconds));
                 * }*/
                decimal tmpchance = High ? MaxRoll - chance : chance;
                string  query     = "mutation{" + RolName + "(amount:" + amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo) + ", target:" + tmpchance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo) + ",condition:" + (High ? "above" : "below") + ",currency:" + CurrentCurrency.ToLower() + ") { id nonce currency amount payout state { ... on " + GameName + " { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses betAmount profit currency}}}}";
                //string query = "mutation {" + RolName + "(amount:" + amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo) + ", target:" + tmpchance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo) + ",condition:" + (High ? "above" : "below") + ",currency:" + Currencies[Currency].ToLower() + ") { id iid nonce currency amount payout state { ... on " + GameName + " { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses amount profit currency}}}}";
                //var primediceRoll = GQLClient.SendMutationAsync<dynamic>(new GraphQLRequest { Query = query }).Result;
                GraphQLResponse <RollDice> betresult = GQLClient.SendMutationAsync <RollDice>(new GraphQLRequest {
                    Query = query
                }).Result;

                RollDice tmp = betresult.Data.primediceRoll;

                Lastbet = DateTime.Now;
                try
                {
                    lastupdate = DateTime.Now;
                    foreach (Statistic x in tmp.user.statistic)
                    {
                        if (x.currency.ToLower() == Currencies[Currency].ToLower() && x.game == StatGameName)
                        {
                            this.Stats.Bets    = (int)x.bets;
                            this.Stats.Wins    = (int)x.wins;
                            this.Stats.Losses  = (int)x.losses;
                            this.Stats.Profit  = x.profit;
                            this.Stats.Wagered = x.amount;
                            break;
                        }
                    }
                    foreach (Balance x in tmp.user.balances)
                    {
                        if (x.available.currency.ToLower() == Currencies[Currency].ToLower())
                        {
                            this.Stats.Balance = x.available.amount;
                            break;
                        }
                    }
                    DiceBet tmpbet = tmp.ToBet();
                    tmpbet.IsWin = tmpbet.GetWin(this);
                    tmpbet.Guid  = BetDetails.GUID;
                    callBetFinished(tmpbet);
                    retrycount = 0;
                }
                catch (Exception e)
                {
                    Logger.DumpLog(e);
                    callNotify("Some kind of error happened. I don't really know graphql, so your guess as to what went wrong is as good as mine.");
                }
            }
            catch (Exception e2)
            {
                callNotify("Error occured while trying to bet, retrying in 30 seconds. Probably.");
                Logger.DumpLog(e2);
            }
        }
Exemple #29
0
        private void SimulationThread()
        {
            try
            {
                DiceBet NewBet = SimulatedBet(DiceStrategy.RunReset());
                this.Balance += (decimal)NewBet.Profit;
                Profit       += (decimal)NewBet.Profit;
                while (TotalBetsPlaced < Bets && !Stop && Running)
                {
                    if (log)
                    {
                        bets.Add(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}"
                                               , TotalBetsPlaced, NewBet.Roll, NewBet.Chance, (NewBet.High ? ">" : "<"), NewBet.GetWin(Site) ? "win" : "lose", NewBet.TotalAmount, NewBet.Profit, this.Balance, Profit));
                    }

                    if (TotalBetsPlaced % 10000 == 0)
                    {
                        OnSimulationWriting?.Invoke(this, new EventArgs());
                        if (log)
                        {
                            using (StreamWriter sw = File.AppendText(TmpFileName))
                            {
                                foreach (string tmpbet in bets)
                                {
                                    sw.WriteLine(tmpbet);
                                }
                            }
                            bets.Clear();
                        }
                    }

                    TotalBetsPlaced++;
                    BetsWithSeed++;
                    bool         Reset        = false;
                    PlaceDiceBet NewBetObject = null;
                    bool         win          = NewBet.GetWin(Site);
                    string       Response     = "";
                    if (BetSettings.CheckResetPreStats(NewBet, NewBet.GetWin(Site), Stats, SiteStats))
                    {
                        Reset        = true;
                        NewBetObject = DiceStrategy.RunReset();
                    }
                    if (BetSettings.CheckStopPreStats(NewBet, NewBet.GetWin(Site), Stats, out Response, SiteStats))
                    {
                        this.Stop = (true);
                    }
                    Stats.UpdateStats(NewBet, win);
                    if (DiceStrategy is ProgrammerMode)
                    {
                        (DiceStrategy as ProgrammerMode).UpdateSessionStats(CopyHelper.CreateCopy <SessionStats>(Stats));
                        (DiceStrategy as ProgrammerMode).UpdateSiteStats(CopyHelper.CreateCopy <SiteStats>(SiteStats));
                        (DiceStrategy as ProgrammerMode).UpdateSite(CopyHelper.CreateCopy <SiteDetails>(Site.SiteDetails));
                    }
                    if (BetSettings.CheckResetPostStats(NewBet, NewBet.GetWin(Site), Stats, SiteStats))
                    {
                        Reset        = true;
                        NewBetObject = DiceStrategy.RunReset();
                    }
                    if (BetSettings.CheckStopPOstStats(NewBet, NewBet.GetWin(Site), Stats, out Response, SiteStats))
                    {
                        Stop = true;
                    }
                    decimal withdrawamount = 0;
                    if (BetSettings.CheckWithdraw(NewBet, NewBet.GetWin(Site), Stats, out withdrawamount, SiteStats))
                    {
                        this.Balance -= withdrawamount;
                    }
                    if (BetSettings.CheckBank(NewBet, NewBet.GetWin(Site), Stats, out withdrawamount, SiteStats))
                    {
                        this.Balance -= withdrawamount;
                    }
                    if (BetSettings.CheckTips(NewBet, NewBet.GetWin(Site), Stats, out withdrawamount, SiteStats))
                    {
                        this.Balance -= withdrawamount;
                    }
                    bool NewHigh = false;
                    if (BetSettings.CheckResetSeed(NewBet, NewBet.GetWin(Site), Stats, SiteStats))
                    {
                        GenerateSeeds();
                    }
                    if (BetSettings.CheckHighLow(NewBet, NewBet.GetWin(Site), Stats, out NewHigh, SiteStats))
                    {
                        (DiceStrategy as iDiceStrategy).High = NewHigh;
                    }
                    if (!Reset)
                    {
                        NewBetObject = (DiceStrategy as iDiceStrategy).CalculateNextDiceBet(NewBet, win);
                    }
                    if (Running && !Stop && TotalBetsPlaced <= Bets)
                    {
                        if (this.Balance < (decimal)NewBetObject.Amount)
                        {
                            break;
                        }
                        NewBet        = SimulatedBet(NewBetObject);
                        this.Balance += (decimal)NewBet.Profit;
                        Profit       += (decimal)NewBet.Profit;
                        //save to file
                    }
                }

                using (StreamWriter sw = File.AppendText(TmpFileName))
                {
                    foreach (string tmpbet in bets)
                    {
                        sw.WriteLine(tmpbet);
                    }
                }
                bets.Clear();
                OnSimulationComplete?.Invoke(this, new EventArgs());
            }
            catch (Exception e)
            {
                Logger.DumpLog(e);
            }
        }
Exemple #30
0
        public void PlaceDiceBet(PlaceDiceBet BetObj)
        {
            try
            {
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();

                /*access_token
                 * type:dice
                 * amount:0.00000001
                 * condition:< or >
                 * game:49.5
                 * devise:btc*/
                pairs.Add(new KeyValuePair <string, string>("access_token", accesstoken));
                //pairs.Add(new KeyValuePair<string, string>("type", "dice"));
                pairs.Add(new KeyValuePair <string, string>("amount", BetObj.Amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("over", BetObj.High.ToString().ToLower()));
                pairs.Add(new KeyValuePair <string, string>("target", !BetObj.High ? BetObj.Chance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo) : (MaxRoll - BetObj.Chance).ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo)));
                pairs.Add(new KeyValuePair <string, string>("currency", CurrentCurrency));
                pairs.Add(new KeyValuePair <string, string>("api_key", "0b2edbfe44e98df79665e52896c22987445683e78"));
                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                HttpResponseMessage   tmpmsg  = Client.PostAsync("api/bet-dice", Content).Result;
                string sEmitResponse          = tmpmsg.Content.ReadAsStringAsync().Result;
                bsBet  bsbase = null;
                try
                {
                    bsbase = json.JsonDeserialize <bsBet>(sEmitResponse.Replace("\"return\":", "\"_return\":"));
                }
                catch (Exception e)
                {
                }

                if (bsbase != null)
                {
                    // if (bsbase._return != null)
                    if (bsbase.success)
                    {
                        Stats.Balance = decimal.Parse(bsbase.new_balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                        lastupdate    = DateTime.Now;
                        DiceBet tmp = bsbase.ToBet();
                        tmp.Guid       = BetObj.GUID;
                        Stats.Profit  += (decimal)tmp.Profit;
                        Stats.Wagered += (decimal)tmp.TotalAmount;
                        tmp.DateValue  = DateTime.Now;
                        bool win = false;
                        if ((tmp.Roll > 99.99m - tmp.Chance && tmp.High) || (tmp.Roll < tmp.Chance && !tmp.High))
                        {
                            win = true;
                        }
                        //set win
                        if (win)
                        {
                            Stats.Wins++;
                        }
                        else
                        {
                            Stats.Losses++;
                        }
                        Stats.Bets++;
                        LastBetAmount = (double)BetObj.Amount;
                        LastBet       = DateTime.Now;
                        callBetFinished(tmp);
                        return;
                    }
                    else
                    {
                        if (bsbase.error != null)
                        {
                            if (bsbase.error.StartsWith("Maximum bet") || bsbase.error == "Bet amount not valid")
                            {
                                callError(bsbase.error, false, ErrorType.InvalidBet);
                            }

                            if (bsbase.error.Contains("Bet in progress, please wait few seconds and retry."))
                            {
                                callNotify("Bet in progress. You need to log in with your browser and place a bet manually to fix this.");
                            }
                            else
                            {
                                callNotify(bsbase.error);
                            }
                        }
                    }
                }
                //
            }
            catch (AggregateException e)
            {
                callNotify("An Unknown error has ocurred.");
            }
            catch (Exception e)
            {
                callNotify("An Unknown error has ocurred.");
            }
        }