示例#1
0
        void PlaceBetThread(object BetObj)
        {
            PlaceBetObj betobj = BetObj as PlaceBetObj;
            decimal     low    = 0;
            decimal     high   = 0;

            if (betobj.High)
            {
                high = maxRoll * 100;
                low  = (maxRoll - chance) * 100 + 1;
            }
            else
            {
                high = chance * 100 - 1;
                low  = 0;
            }
            string loginjson = json.JsonSerializer <WDPlaceBet>(new WDPlaceBet()
            {
                curr = Currency,
                bet  = betobj.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")
                {
                    Bet Result = new Bet()
                    {
                        Amount     = betobj.Amount,
                        date       = DateTime.Now,
                        Chance     = tmpBalance.data.chance,
                        clientseed = currentseed.client,
                        Currency   = Currency,
                        Guid       = betobj.Guid,
                        Id         = tmpBalance.data.hash,
                        high       = betobj.High,
                        nonce      = tmpBalance.data.nonce,
                        Profit     = tmpBalance.data.win - tmpBalance.data.bet,
                        Roll       = tmpBalance.data.result / 100m,
                        serverhash = currentseed.hash
                    };
                    this.bets++;
                    bool Win = (((bool)High ? (decimal)Result.Roll > (decimal)maxRoll - (decimal)(chance) : (decimal)Result.Roll < (decimal)(chance)));
                    if (Win)
                    {
                        wins++;
                    }
                    else
                    {
                        losses++;
                    }
                    wagered += amount;
                    profit  += Result.Profit;
                    balance += Result.Profit;
                    FinishedBet(Result);
                }
                else
                {
                    Parent.updateStatus(tmpBalance.message);
                }
            }
        }
示例#2
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);
                }
            }
        }