Beispiel #1
0
        void ProcessBitdiceBet(bitdicebetbase Bet)
        {
            if (Bet.message.type == "secret")
            {
                server = Bet.message.secret.id;
            }

            Bet newbet = new Bet()
            {
                Guid       = this.Guid,
                Id         = Bet.message.data.bet.id.ToString(),
                Amount     = decimal.Parse(Bet.message.data.bet.amount, System.Globalization.NumberFormatInfo.InvariantInfo),
                date       = DateTime.Now,
                Chance     = decimal.Parse(Bet.message.data.bet.chance, System.Globalization.NumberFormatInfo.InvariantInfo),
                Currency   = Bet.message.data.bet.currency,
                nonce      = -1,
                Roll       = decimal.Parse(Bet.message.data.bet.lucky, System.Globalization.NumberFormatInfo.InvariantInfo),
                Profit     = decimal.Parse(Bet.message.data.bet.win, System.Globalization.NumberFormatInfo.InvariantInfo),
                high       = Bet.message.data.bet.high,
                clientseed = Bet.message.data.old.client,
                serverhash = Bet.message.data.old.hash,
                serverseed = Bet.message.data.old.secret
            };

            server   = Bet.message.data.secret.id;
            balance  = decimal.Parse(Bet.message.data.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
            wagered += newbet.Amount;
            profit  += newbet.Profit;
            bets++;
            if (Bet.message.data.bet.result)
            {
                wins++;
            }
            else
            {
                losses++;
            }
            FinishedBet(newbet);
        }
Beispiel #2
0
        void Client_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            try
            {
                Parent.DumpLog(e.Message, 4);
                string s = e.Message.Replace("\\\"", "\"").Replace("\"{", "{").Replace("}\"", "}");
                //Parent.DumpLog(e.Message, -1);
                //Parent.DumpLog("", -1);
                //Parent.DumpLog(s,-1);
                bitdicebetbase tmp = json.JsonDeserialize <bitdicebetbase>(s);
                if (tmp.type == "confirm_subscription")
                {
                    switch (tmp.identifier.channel)
                    {
                    case "ProfileChannel": Client.Send("{\"command\":\"message\",\"identifier\":\"{\\\"channel\\\":\\\"ProfileChannel\\\"}\",\"data\":\"{\\\"action\\\":\\\"profile\\\"}\"}");
                        Client.Send("{\"command\":\"message\",\"identifier\":\"{\\\"channel\\\":\\\"ProfileChannel\\\"}\",\"data\":\"{\\\"action\\\":\\\"dashboard\\\"}\"}");
                        break;

                    case "WalletChannel": Client.Send("{\"command\":\"message\",\"identifier\":\"{\\\"channel\\\":\\\"WalletChannel\\\"}\",\"data\":\"{\\\"action\\\":\\\"balance\\\"}\"}");
                        break;

                    case "EventsChannel": Client.Send("{\"command\":\"message\",\"identifier\":\"{\\\"channel\\\":\\\"EventsChannel\\\"}\",\"data\":\"{\\\"action\\\":\\\"events\\\"}\"}"); break;

                    case "DiceChannel": Client.Send("{\"command\":\"message\",\"identifier\":\"{\\\"channel\\\":\\\"DiceChannel\\\"}\",\"data\":\"{\\\"action\\\":\\\"secret\\\"}\"}"); break;
                    }
                    return;
                }
                else if (tmp.message.type == "changeCurrency")
                {
                    Client.Send("{\"command\":\"message\",\"identifier\":\"{\\\"channel\\\":\\\"ProfileChannel\\\"}\",\"data\":\"{\\\"action\\\":\\\"dashboard\\\"}\"}");
                    Client.Send("{\"command\":\"message\",\"identifier\":\"{\\\"channel\\\":\\\"WalletChannel\\\"}\",\"data\":\"{\\\"balance\\\":\\\"profile\\\"}\"}");
                }
                else if (tmp.message.type == "balances")
                {
                    bitdicebalancedata tmp2 = json.JsonDeserialize <bitdicebalancedata>(s);
                    switch (tmp2.message.data.active)
                    {
                    case "doge": balance = decimal.Parse(tmp2.message.data.wallets.doge.balance, System.Globalization.NumberFormatInfo.InvariantInfo); break;

                    case "btc": balance = decimal.Parse(tmp2.message.data.wallets.btc.balance, System.Globalization.NumberFormatInfo.InvariantInfo); break;

                    case "ltc": balance = decimal.Parse(tmp2.message.data.wallets.ltc.balance, System.Globalization.NumberFormatInfo.InvariantInfo); break;

                    case "eth": balance = decimal.Parse(tmp2.message.data.wallets.eth.balance, System.Globalization.NumberFormatInfo.InvariantInfo); break;

                    case "csno": balance = decimal.Parse(tmp2.message.data.wallets.eth.balance, System.Globalization.NumberFormatInfo.InvariantInfo); break;
                    }
                    Parent.updateBalance(balance);
                }
                else if (tmp.message.type == "dashboard")
                {
                    bitdiceprofiledata tmp2 = json.JsonDeserialize <bitdiceprofiledata>(s);
                    this.bets    = (int)tmp2.message.profile.bets;
                    this.profit  = tmp2.message.profile.profit;
                    this.wagered = tmp2.message.profile.wagered;
                    Parent.updateBets(bets);
                    Parent.updateProfit(profit);
                    Parent.updateWagered(wagered);
                }
                else if (tmp.message.type == "dashboard_update")
                {
                    bitdiceprofiledata tmp2 = json.JsonDeserialize <bitdiceprofiledata>(s);
                    this.bets    = (int)tmp2.message.update.bets;
                    this.profit  = tmp2.message.update.profit;
                    this.wagered = tmp2.message.update.wagered;
                    Parent.updateBets(bets);
                    Parent.updateProfit(profit);
                    Parent.updateWagered(wagered);
                }
                switch (tmp.identifier.channel)
                {
                case "DiceChannel": ProcessBitdiceBet(tmp); break;

                default: break;
                }
            }
            catch (Exception er)
            {
                Parent.DumpLog(er.ToString(), 1);
            }



            //socketbase tmp = json.JsonDeserialize<socketbase>(e.Message);

            /*if (!string.IsNullOrEmpty(tmp.method))
             * {
             *  switch (tmp.method)
             *  {
             *      case "chat:new": Client_ChatReceived(json.JsonDeserialize<bitchatSocket>(e.Message.Replace("params", "_params"))._params); break;
             *      case "stat.global": break;
             *      case "stat.user": Client_UserStats(json.JsonDeserialize<bitstatsusersocket>(e.Message.Replace("params", "_params"))._params); break;
             *      case "stat.bets": Client_BetResult(json.JsonDeserialize<bitstatsbetsocket>(e.Message.Replace("params", "_params").Replace("\\", "").Replace("\"{", "{").Replace("}\"", "}"))._params); break;
             *  }
             * }*/
        }