Example #1
0
        public List <Auction> getCreateOffers()
        {
            if (this.helpf.playerstoreAllCardsChanged)
            {
                this.updateCardFilter();
            }
            if (createCardsFilter.filtersChanged)
            {
                //sellOfferListFiltered = new List<Auction> (fullSellOfferList);
                createOfferListFiltered.Clear();
                //createOfferListFiltered.AddRange(this.helpf.allOwnTradeableAuctions);
                foreach (Auction c in this.helpf.allOwnTradeableAuctions)
                {
                    bool found = false;
                    foreach (Auction a in this.addAuctionList)
                    {
                        if (a.card.id == c.card.id)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        continue;
                    }
                    createOfferListFiltered.Add(c);
                }
                foreach (Auction c in this.createOfferListFiltered)
                {
                    int index = helpf.cardidToArrayIndex(c.card.getType());
                    if (index >= 1)
                    {
                        c.setPrice(prcs.getPrice(index, sttngs.wtbAHpriceType));
                    }
                    //if (c.price == 0) c.setPrice(1);


                    if (index >= 0)
                    {
                        c.setPrice(Prices.Instance.getPrice(index, ScrollsPostPriceType.BLACKMARKET));
                    }
                }
                createOfferListFiltered.RemoveAll(createCardsFilter.isFiltered);
                createCardsFilter.filtersChanged = false;
                createOfferListFiltered.Sort(Auction.getComparison(AuctionHouse.SortMode.PRICE_REVERSE)); //.CARD
            }
            return(new List <Auction>(createOfferListFiltered));
        }
Example #2
0
        public void totalpricecheck()//int[] cardids
        {
            WebRequest myWebRequest;

            myWebRequest = WebRequest.Create("http://a.scrollsguide.com/prices");

            /*
             * if (sttngs.scrollspostday == ScrollsPostDayType.thirty)
             * { myWebRequest = WebRequest.Create("http://api.scrollspost.com/v1/prices/30-days/"); }
             * else
             * {
             *  if (sttngs.scrollspostday == ScrollsPostDayType.fourteen)
             *  { myWebRequest = WebRequest.Create("http://api.scrollspost.com/v1/prices/14-days/"); }
             *  else
             *  {
             *      if (sttngs.scrollspostday == ScrollsPostDayType.seven)
             *      { myWebRequest = WebRequest.Create("http://api.scrollspost.com/v1/prices/7-days/"); }
             *      else
             *      {
             *          if (sttngs.scrollspostday == ScrollsPostDayType.three)
             *          { myWebRequest = WebRequest.Create("http://api.scrollspost.com/v1/prices/3-days/"); }
             *          else
             *          {
             *              if (sttngs.scrollspostday == ScrollsPostDayType.hour)
             *              { myWebRequest = WebRequest.Create("http://api.scrollspost.com/v1/prices/1-hour/"); }
             *              else
             *              {
             *                  myWebRequest = WebRequest.Create("http://api.scrollspost.com/v1/prices/1-day/");
             *              }
             *          }
             *      }
             *  }
             * }
             */
            myWebRequest.Timeout = 10000;
            WebResponse myWebResponse = myWebRequest.GetResponse();

            System.IO.Stream       stream = myWebResponse.GetResponseStream();
            System.IO.StreamReader reader = new System.IO.StreamReader(stream, System.Text.Encoding.UTF8);
            string ressi = reader.ReadToEnd();
            //Console.WriteLine(ressi);

            JsonReader jsonReader = new JsonReader();
            Dictionary <string, object> dictionary = (Dictionary <string, object>)jsonReader.Read(ressi);

            if ((string)(dictionary["msg"]) == "success")
            {
                Dictionary <string, object>[] d = (Dictionary <string, object>[])dictionary["data"];
                for (int i = 0; i < d.GetLength(0); i++)
                {
                    int id = Convert.ToInt32(d[i]["id"]);

                    int lower = 0; int higher = 0; int sugger = 0;
                    int high = (int)d[i]["buy"];
                    int low  = (int)d[i]["sell"];
                    if (high != 0)
                    {
                        int value = high;
                        lower  = value;
                        higher = value;
                    }
                    if (low != 0)
                    {
                        int value = low;
                        if (value < lower || (value != 0 && lower == 0))
                        {
                            lower = value;
                        }
                        if (value > higher || (value != 0 && higher == 0))
                        {
                            higher = value;
                        }
                    }
                    sugger = (lower + higher) / 2;

                    //int index = Array.FindIndex(cardids, element => element == id);
                    int index = helpf.cardidToArrayIndex(id);
                    if (index >= 0)
                    {
                        lowerprice[index] = lower;
                        upperprice[index] = higher;
                        sugprice[index]   = sugger;
                    }
                }
            }
        }