Exemple #1
0
        public GameInfo(NewGame g)
        {
            this.game = g;
            InitializeComponent();
            game.cards = game.cards == null ? new List<GameCard>() : game.cards;
            game.gamePack = game.gamePack == null ? new GamePack(game) : game.gamePack;

            int kol = 0;
            double sum = 0;
            foreach(GameCard gc in game.cards.FindAll(x=>!x.foil))
            {
                kol++;
                sum+=Convert.ToDouble(gc.LowestPrice);

            }
            label5.Text = game.gamePack.LowestPrice + "/" + (sum * 3 / kol).ToString();

            progressBar1.Minimum = 0;
            progressBar1.Maximum = g.cards.Count / 2;
            progressBar1.Value = 0;
            progressBar1.Step = 1;
            gcList = new List<GameCard>(game.cards);
            gcList.Add(game.gamePack);
            checkBox2.Checked = game.favorite;

            gameCardBindingSource.DataSource = gcList.FindAll(x => x.foil == checkBox1.Checked | !x.foil);
            dataGridView1.DataSource = gameCardBindingSource;
            textBox1.Text = game.name;
            textBox2.Text = game.id;
        }
Exemple #2
0
        public GameCard(string html,NewGame ng)
        {
            string ItemGame = Regex.Match(html, "(?<=game_name\">)(.*)(?=</span>)").ToString();
            ItemGame = ItemGame.Replace(" Foil Trading Card", "");
            ItemGame = ItemGame.Replace(" Trading Card", "");
            if (ItemGame.Equals(ng.name))
            {
                this.game = ng;
                //Fix for Steam update 5/01/14 4:00 PM PST
                this.url = Regex.Match(html, "(?<==\")(.*)(?=\" id)").ToString();
                this.volume = Regex.Match(html, "(?<=num_listings_qty\">)(.*)(?=</span>)").ToString();
                string ItemName = Regex.Match(html, "(?<=listing_item_name\" style=\"color:)(.*)(?=</span>)").ToString();
                ItemName = ItemName.Remove(0, ItemName.IndexOf(">") + 1);
                this.name = ItemName;
                this.img_url = Regex.Match(html, "(?<=net/economy/image/)(.*)(/62fx62f)", RegexOptions.Singleline).ToString();

            }
        }
Exemple #3
0
 public double profit(NewGame game)
 {
     int kol = 0;
     double summ = 0;
     string volume = "";
     foreach (GameCard gc in game.cards.FindAll(x=>!x.foil))
     {
         if (gc.game.id == game.id )
         {
             kol++;
             if (gc != null)
             {
                 if (gc.LowestPrice != null)
                     summ += Convert.ToDouble(gc.LowestPrice);
                 volume += gc.volume + " ";
             }
         }
     }
     return kol == 0 ? 0 : (((summ * 3 / kol) / 1.15) - 6000 / kol / 80 * price80);
 }
Exemple #4
0
 public int CompareGames(NewGame x, NewGame y)
 {
     if (profit(x) < profit(y))
         return -1;
     return 1;
 }
Exemple #5
0
 private void button8_Click(object sender, EventArgs e)
 {
     NewGame ng = new NewGame();
     games.Add(ng);
     GameInfo gi = new GameInfo(ng);
     gi.Show();
 }
Exemple #6
0
 private void button6_Click(object sender, EventArgs e)
 {
     HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://steamcommunity.com/market/search/render/?query=Trading Card&start=0&count=1");
     HttpWebResponse flixresponse = (HttpWebResponse)request.GetResponse();
     StreamReader response = new StreamReader(flixresponse.GetResponseStream(), Encoding.UTF8);
     string html = response.ReadToEnd();
     var searchJS = JsonConvert.DeserializeObject<SearchBody>(html);
     List<NewGame> tmpList = new List<NewGame>();
     if (searchJS.Success) {
         int count = Convert.ToInt32(searchJS.TotalCount);
         int countPerPage = 100;
         for (int page = 0; page < count / countPerPage; page++)
         {
             request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://steamcommunity.com/market/search/render/?query=Trading Card&start=" + page * countPerPage + "&count=" + countPerPage);
             flixresponse = (HttpWebResponse)request.GetResponse();
             response = new StreamReader(flixresponse.GetResponseStream(), Encoding.UTF8);
             html = response.ReadToEnd();
             searchJS = JsonConvert.DeserializeObject<SearchBody>(html);
             int kol = 0;
             if (searchJS.Success)
             {
                 MatchCollection matches = Regex.Matches(searchJS.HtmlRes, "(?<=market_listing_row_link\" href)(.*?)(?<=</a>)", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline);
                 if (matches.Count != 0)
                 {
                     foreach (Match match in matches)
                     {
                         string currmatch = match.Groups[1].Value;
                         string ItemGame = Regex.Match(html, "(?<=game_name\">)(.*)(?=</span>)").ToString();
                         ItemGame = ItemGame.Replace(" Foil Trading Card", "");
                         ItemGame = ItemGame.Replace(" Trading Card", "");
                         /*string url = Regex.Match(html, "(?<==\")(.*)(?=\" id)").ToString();
                         string volume = Regex.Match(html, "(?<=num_listings_qty\">)(.*)(?=</span>)").ToString();
                         string ItemName = Regex.Match(html, "(?<=listing_item_name\" style=\"color:)(.*)(?=</span>)").ToString();
                         ItemName = ItemName.Remove(0, ItemName.IndexOf(">") + 1);
                         string name = ItemName;
                         string img_url = Regex.Match(html, "(?<=net/economy/image/)(.*)(/62fx62f)", RegexOptions.Singleline).ToString();*/
                         NewGame tmpNG = new NewGame();
                         tmpNG.name = ItemGame;
                         tmpList.Add(tmpNG);
                         //NewGame tmpNG = games.Find(x => x.name == name);
                     }
                 }
             }
         }
     }
 }
Exemple #7
0
 public void refreshPrices(NewGame g)
 {
     progressBar1.Value = 0;
     progressBar1.Maximum = g.cards.Count == 0 ?1:g.cards.Count / 2;
     foreach (GameCard gc in g.cards.FindAll(x=>!x.foil))
     {
         gc.RefreshThreadable();
     }
     g.gamePack.Refresh(progressBar1);
     g.profit = profit(g);
 }
Exemple #8
0
 public GamePack(NewGame ng)
 {
     foil = false; game = ng; name = ng.name + "%20Booster%20Pack";
 }
Exemple #9
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://www.steamcardexchange.net/index.php?boosterprices");
            request.AllowAutoRedirect = false;
            //request.CookieContainer.Add(new Cookie("PHPSESSID", "tep5gkkt47qktdl8fsrh0rqeqqvbhs5j"));
            HttpWebResponse flixresponse = (HttpWebResponse)request.GetResponse();
            request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://www.steamcardexchange.net/index.php?boosterprices");
            request.CookieContainer = new CookieContainer();
            string value = flixresponse.Headers["Set-Cookie"].Remove(0, 10);
            value = value.Remove(value.IndexOf(";"), value.Length - value.IndexOf(";"));
            Cookie cookie = new Cookie("PHPSESSID", value, "/", "localhost");
            request.CookieContainer.Add(cookie);
            flixresponse = (HttpWebResponse)request.GetResponse();

            StreamReader response = new StreamReader(flixresponse.GetResponseStream(), Encoding.UTF8);
            string html = response.ReadToEnd();
            html = html.Remove(0, html.IndexOf("<tbody>") + 7);
            html = html.Remove(html.IndexOf("</tbody>"), html.Length - html.IndexOf("</tbody>"));

            MatchCollection matches = Regex.Matches(html, "(?<=<tr>)(.*?)(?<=</tr>)", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline);
            if (matches.Count != 0)
            {
                foreach (Match match in matches)
                {
                    string currmatch = match.Groups[0].Value;

                    string gameId = Regex.Match(currmatch, "(?<=appid-)(.*?)(?=\\\">)").ToString();
                    currmatch = currmatch.Remove(0, currmatch.IndexOf("appid"));
                    string gameName = Regex.Match(currmatch, "(?<=\">)(.*)(?=</a>)").ToString();

                    currmatch = match.Groups[0].Value;
                    string ItemGame = currmatch.Substring(currmatch.IndexOf(">") + 1);
                    ItemGame = ItemGame.Remove(ItemGame.IndexOf("</a"));

                    if (games.Find(x => x.name == gameName) == null)
                    {
                        NewGame tmpNG = new NewGame();
                        tmpNG.name = gameName;
                        tmpNG.id = gameId;

                        //карты в руки
                        string responseHtml = Requests.GetHttpResponse("http://steamcommunity.com/market/search/render/?query=" + gameName + " Trading Card&start=0&count=200");
                        if (responseHtml == null)
                        {
                            refreshGrid();
                            break;
                        }
                        tmpNG.GetCards(responseHtml);

                        //обновили карты
                        refreshPrices(tmpNG);

                        //схоронили игоря
                        games.Add(tmpNG);
                    }
                }
            }
        }