예제 #1
0
        public static string getVariableName(Skin skin, Quality quality)
        {
            var name = String.Copy(skin.name);
            Regex rgx = new Regex("[^a-zA-Z0-9]");
            name = rgx.Replace(name, "");
            var charsToRemove = new string[] { "|", "-", " ", "}", ",", ".", ";", "'" };
            foreach (var c in charsToRemove)
            {
                name = name.Replace(c, string.Empty);
            }

            return name + EnumUtil.getQualityShort(quality);
        }
예제 #2
0
        public void buySkin(Skin skin, Quality quality, double priceLimit, int skinsToBuy)
        {
            var url = getMarketUrl(skin.name, quality);
            int skinsBought = 0;

            while(skinsBought < skinsToBuy)
            {
                driver.Navigate().GoToUrl(url);
                var results = driver.FindElementById("searchResultsRows");
                string expr = "//span[@class='market_listing_price market_listing_price_with_fee']";
                //results.FindElement(By.ClassName("market_listing_price_with_fee"));
                var listings = driver.FindElementsByClassName("market_recent_listing_row");
                double price = -1;
                foreach(var listing in listings)
                {
                    var priceElement = listing.FindElement(By.ClassName("market_listing_price_with_fee"));
                    var priceString = priceElement.Text;
                    priceString = Regex.Replace(priceString, "[^0-9.,]", "");

                    if (string.IsNullOrWhiteSpace(priceString))
                    {
                        continue;
                    }

                    if (double.TryParse(priceString, out price))
                    {
                        break;
                    }
                }

                if(!(price > -1))
                {
                    continue;
                }

                try{
                    if (price <= priceLimit)
                    {
                        var button = listings.First().FindElement(By.XPath("//a[contains(@class,'item_market_action_button_green')]"));
                        button.Click();
                        if (IsElementPresent(By.Id("market_buynow_dialog_accept_ssa")))
                        {
                            var checkBox = driver.FindElementById("market_buynow_dialog_accept_ssa");
                            if (checkBox.Selected != true)
                            {
                                checkBox.Click();
                            }

                            var finalButton = driver.FindElementById("market_buynow_dialog_purchase");
                            finalButton.Click();

                            if (IsElementPresentWithRetry(By.Id("market_buynow_dialog_purchasecomplete_message"), 15))
                            {
                                Console.WriteLine("{0}:Item purchased for: {1}", DateTime.Now, price);
                                skinsBought++;
                            }
                            else
                            {
                                //check visibility div id = market_buynow_dialog_error
                                Console.WriteLine("Purchase failed");
                            }
                        }
                        else
                        {
                            Console.WriteLine("{0}:Item probably purchased without rules confirmation for: {1}", DateTime.Now, price);

                            skinsBought++;
                        }
                    }
                    else
                    {
                        Console.WriteLine(string.Format("{0}: Available price: {1} is higher that required price: {2}", DateTime.Now, price, priceLimit));
                        Thread.Sleep(15000);
                    }
                }
                catch(Exception ex)
                {
                    Console.WriteLine(string.Format("{1}: Exception encountered {0}", ex, DateTime.Now));
                }

            }
        }
예제 #3
0
        public static string getBasicConstraints(Skin skin, int limit)
        {
            var list = new List<Skin>()
            {
                skin
            };

            return getBasicConstraints(list, limit);
        }