Example #1
0
 private static void setBetModifier(betMode mode)
 {
     if (mode == betMode.Tournament)
     {
         betModifier = 1;
     }
     else if (mode == betMode.Matchmaking)
     {
         betModifier = 0.20;
     }
     else
     {
         betModifier = 0.10;
     }
 }
Example #2
0
        private static betMode setBetMode(stateJson currentState)
        {
            betMode mode = betMode.Exhibitions; //default to exhibitions, our most reserved betting mode

            if (currentState.remaining.Contains("until the next tournament") ||
                currentState.remaining.Contains("Matchmaking mode has been") ||
                currentState.remaining.Contains("Tournament mode will be"))
            {
                //matchmaking
                mode = betMode.Matchmaking;
            }

            else if (currentState.remaining.Contains("characters are left in the bracket") ||
                     currentState.remaining.Contains("Tournament mode start") ||
                     currentState.remaining.Contains("FINAL ROUND"))
            {
                //tournament
                mode = betMode.Tournament;
            }

            return(mode);
        }
Example #3
0
        private static void makeBet(CookieContainer cookieContainer, List <fighter> currentFighters, int balance, double redChanceToWin, betMode currentMode)
        {
            oldBalance = balance;
            try
            {
                var request = (HttpWebRequest)WebRequest.Create("http://www.saltybet.com/ajax_place_bet.php");
                request.CookieContainer = cookieContainer;
                var postData = "selectedplayer=player" + (isRedBestBet(redChanceToWin) ? 1 : 2);
                if (balance <= 50000)
                {
                    betModifier = 1;
                }
                else if (balance >= 1000000)
                {
                    betModifier /= 4;
                }
                if ((redChanceToWin <= 10 || redChanceToWin >= 90) && currentMode != betMode.Tournament)
                {
                    betModifier *= 3; //confident bet, lets bet alot, unless it's tournament we are already betting all our salt
                }
                else if (redChanceToWin >= 46 && redChanceToWin <= 54 && currentMode != betMode.Tournament)
                {
                    balance     = 10000;
                    betModifier = 1; //close match, bet 10k to try and win some of dat good salt.
                }
                Console.WriteLine("Bet placed: $" + (int)(balance * betModifier));
                postData += "&wager=" + (int)(balance * betModifier);
                var data = Encoding.ASCII.GetBytes(postData);

                request.Method        = "POST";
                request.ContentType   = "application/x-www-form-urlencoded";
                request.ContentLength = data.Length;

                using (var stream = request.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);
                    stream.Close();
                    stream.Dispose();
                }
                request.Abort();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Could not place bet");
            }
        }
Example #4
0
        private static void buildCurrentMatch(CookieContainer cookieContainer)
        {
            //happens when waifu says bets are open
            //add fight to db if it doesn't exist, then wait for win or loss message, update who won.
            //if fight does exist, offer advice on who to bet on, wait for win/loss, update who won.
gameCrash:
            int balance = getBalance(cookieContainer);

            mySqlCon.ConnectionString = mySqlConnectString;
            stateJson      currentState    = getCurrentState();
            matchstatsJson currentMatch    = getCurrentMatchStats(makeCookieContainer());
            List <fighter> currentFighters = buildFighters(currentMatch);
            string         RedTeam         = currentState.p1name;
            string         BlueTeam        = currentState.p2name;
            int            countFighters   = currentFighters.Count;
            double         redChanceToWin  = 0;

            mySqlCon.Open();

            try
            {
                //figure out how to bet by getting bet mode
                currentMode = setBetMode(currentState);
                setBetModifier(currentMode);
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot set bet modifier");
                Console.WriteLine(e);
            }

            match newMatch = new match(currentFighters);

            redChanceToWin = newMatch.getRedChanceToWin(mySqlCon);
            Console.WriteLine("red chance to win: " + redChanceToWin);


            try
            {
                bool fighting = true;
                Console.WriteLine("Current Salt: " + balance);
                Console.WriteLine("Salt gained/lost on last bet: " + (balance - oldBalance));
                makeBet(cookieContainer, currentFighters, balance, redChanceToWin, currentMode);
                Console.WriteLine("Waiting for winner");
                while (fighting)
                {
                    string message = irc.readMessage();
                    if (message.Contains(waifu))
                    {
                        if (message.Contains(RedTeam) && message.Contains("wins"))
                        {
                            Console.WriteLine(message);
                            updateELOs(newMatch, redChanceToWin, true);
                            isRedTeam = true;
                            recordWL(redChanceToWin);
                            Console.WriteLine("Red wins!");
                            Console.WriteLine("W/L: " + wins + "/" + losses);
                            mySqlCon.Close();
                            fighting = false;
                        }
                        else if (message.Contains(BlueTeam) && message.Contains("wins"))
                        {
                            Console.WriteLine(message);
                            updateELOs(newMatch, redChanceToWin, false);
                            isRedTeam = false;
                            recordWL(redChanceToWin);
                            Console.WriteLine("Blue wins!");
                            Console.WriteLine("W/L: " + wins + "/" + losses);
                            mySqlCon.Close();
                            fighting = false;
                        }
                        else if (message.Contains("Bets are OPEN"))
                        {
                            Console.WriteLine(message);
                            Console.WriteLine("We missed the winner message or the game possibly crashed, start over");
                            fighting = false;
                            mySqlCon.Close();
                            goto gameCrash;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                mySqlCon.Close();
                //Console.WriteLine("Could not Connect to DB");
            }
        }