Ejemplo n.º 1
0
 public void PlaceDiceBet(PlaceDiceBet BetDetails)
 {
     try
     {
         if (WSClient.State != WebSocketState.Open && ispd)
         {
             callNotify("Attempting Reconnect");
             Logger.DumpLog("Reconnecting Bit-Exo socket", 2);
             ConnectSocket();
             Thread.Sleep(1000);
         }
         this.guid  = BetDetails.GUID;
         clientseed = R.Next(0, int.MaxValue).ToString();
         long tmpid = id++;
         this.High = BetDetails.High;
         Chance    = BetDetails.Chance;
         Requests.Add(tmpid, ReqType.bet);
         string request = string.Format("42{7}[\"dice_bet\",{{\"wager\":{0:0},\"client_seed\":{1},\"hash\":\"{2}\",\"cond\":\"{3}\",\"target\":{4},\"payout\":{5},\"currency\":\"{6}\"}}]",
                                        Math.Floor(BetDetails.Amount * 100000000m),
                                        clientseed,
                                        ServerHash,
                                        High ? ">" : "<",
                                        High ? MaxRoll - Chance : Chance,
                                        Math.Floor((BetDetails.Amount * 100000000m)) * ((100 - Edge) / Chance),
                                        CurrentCurrency,
                                        tmpid);
         WSClient.Send(request);
     }
     catch (Exception e)
     {
     }
 }
Ejemplo n.º 2
0
        public override PlaceDiceBet RunReset()
        {
            PlaceDiceBet NextBet = new PlaceDiceBet(0, false, 0);

            Runtime.Invoke("ResetDice", NextBet);
            return(NextBet);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        public override PlaceDiceBet RunReset()
        {
            PlaceDiceBet NextBet = new PlaceDiceBet(0, false, 0);

            dynamic result = Scope.ResetDice(NextBet);

            return(NextBet);
        }
Ejemplo n.º 5
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);
     }
 }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            this.Guid = BetDetails.GUID;

            string bet = string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "{{\"attrs\":{0}}}",
                                       json.JsonSerializer <YLBetSend>(
                                           new YLBetSend {
                amount = (long)(BetDetails.Amount * 100000000), range = BetDetails.High ? "hi" : "lo", target = (int)(BetDetails.Chance * 10000), coin = CurrentCurrency.ToLower()
            }));

            Write("create_bet", bet);
        }
Ejemplo n.º 8
0
        public override PlaceDiceBet RunReset()
        {
            PlaceDiceBet NextBet = new PlaceDiceBet(0, false, 0);

            globals.NextDiceBet = NextBet;
            //if (ResetDice == null)
            {
                runtime   = runtime.ContinueWithAsync("ResetDice(NextDiceBet)").Result;
                ResetDice = runtime.Script;
            }

            //else
            //    runtime = ResetDice.RunFromAsync(runtime).Result;
            return(NextBet);
        }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
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);
            }
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
 public override PlaceDiceBet RunReset()
 {
     try
     {
         DynValue DoDiceBet = CurrentRuntime.Globals.Get("ResetDice");
         if (DoDiceBet != null)
         {
             PlaceDiceBet NextBet = new PlaceDiceBet(0, false, 0);
             DynValue     Result  = CurrentRuntime.Call(DoDiceBet, 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);
 }
Ejemplo n.º 13
0
 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);
 }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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);
            }
        }
Ejemplo n.º 16
0
 public void PlaceDiceBet(PlaceDiceBet BetDetails)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 17
0
        public void PlaceDiceBet(PlaceDiceBet BetDetails)
        {
            try
            {
                decimal amount     = BetDetails.Amount;
                decimal chance     = BetDetails.Chance;
                bool    High       = BetDetails.High;
                string  clientseed = R.Next(0, int.MaxValue).ToString();

                string jsoncontent = json.JsonSerializer <NDPlaceBet>(new NDPlaceBet()
                {
                    amount = amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo),
                    perc   = chance.ToString("0.0000", System.Globalization.NumberFormatInfo.InvariantInfo),
                    pos    = High ? "hi" : "lo",
                    times  = 1,
                    cseed  = clientseed
                });
                StringContent Content   = new StringContent(jsoncontent, Encoding.UTF8, "application/json");
                string        Response  = Client.PostAsync("api/bet", Content).Result.Content.ReadAsStringAsync().Result;
                NDGetBet      BetResult = json.JsonDeserialize <NDGetBet>(Response);
                if (BetResult.info == null)
                {
                    DiceBet tmp = new DiceBet
                    {
                        TotalAmount = amount,
                        DateValue   = DateTime.Now,
                        Chance      = chance,
                        ClientSeed  = clientseed
                        ,
                        ServerHash = lastHash,
                        Guid       = BetDetails.GUID,
                        High       = High,
                        BetID      = BetResult.no.ToString(),
                        Nonce      = BetResult.index,
                        Roll       = BetResult.n / 10000m,
                        ServerSeed = BetResult.sseed,
                        Profit     = BetResult.amount
                    };

                    lastHash = BetResult.sshash;
                    Stats.Bets++;
                    bool win = (tmp.Roll > 99.99m - tmp.Chance && High) || (tmp.Roll < tmp.Chance && !High);
                    Stats.Balance  = BetResult.balance;
                    Stats.Wagered += amount;
                    Stats.Profit  += BetResult.amount;
                    if (win)
                    {
                        Stats.Wins++;
                    }
                    else
                    {
                        Stats.Losses++;
                    }

                    callBetFinished(tmp);
                }
                else
                {
                    callError(BetResult.info, true, ErrorType.Unknown);
                }
            }
            catch (Exception Ex)
            {
                Logger.DumpLog(Ex);
                callError(Ex.ToString(), true, ErrorType.Unknown);
            }
        }
Ejemplo n.º 18
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);
            }
        }
Ejemplo n.º 19
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); }
        }
Ejemplo n.º 20
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)
            {
            }
        }
Ejemplo n.º 21
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.");
            }
        }
Ejemplo n.º 22
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);
            }
        }
Ejemplo n.º 23
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);
            }
        }
Ejemplo n.º 24
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
            { }
        }
Ejemplo n.º 25
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);
            }
        }
Ejemplo n.º 26
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);
                }
            }
        }