Пример #1
0
        public void Trade(Room room, Player player)
        {
            if (Wares.Count > 0)
            {
                Console.WriteLine($"{Greeting}. Here is what I have on me.");

                //Defining a starting number that will increment with the room inventory list
                int index = 1;
                foreach (Item item in Wares)
                {
                    //Show the item name with the index number
                    Console.WriteLine($"{index}) {item.Name}");
                    index++;
                }
                //Adding a manual option for user to select for exiting out this menu
                Console.WriteLine($"{index}) I'll pass.");
                Console.WriteLine($"What do you want to pick? {player.Name}");
                int userInputAsNumber = Utility.GetANumberFromUser(index);

                //Check the user made the selection of the last option we manually added to the list
                if (userInputAsNumber < index)
                {
                    //Find the selected item from rooms item list
                    Item selectedItem = Wares[userInputAsNumber - 1];
                    //checking if the play can pick up item
                    if (selectedItem.CanPickUp)
                    {
                        //player is adding item to inventory
                        player.PickUpItem(selectedItem);
                        //removes item from wares
                        Wares.Remove(selectedItem);
                    }
                    else
                    {
                        Console.WriteLine("Sorry. You can't have that.");
                        Trade(room, player);
                    }

                    //Call the player method to add the item to the inventory


                    //Wares.Clear();


                    //Removes the first item
                    // Wares.Remove(Wares[0]);

                    //Removes first item in the list (by index number)
                    /// Wares.RemoveAt(0);

                    //Resets the whole list
                    //Wares = new List<Item>();
                }
            }
            else
            {
                Console.WriteLine($"Sorry, {player.Name}. I don't have any items left.");
            }
        }
Пример #2
0
 public Zieglers()
 {
     Name = "Zieglers";
     Url  = "http://www.zieglers.com";
     PageRetriever.Referer = Url;
     WareInfoList          = new List <ExtWareInfo>();
     Wares.Clear();
     SpecialSettings = new ExtSettings();
 }
Пример #3
0
 public Jobboerse()
 {
     Name = "Jobboerse";
     Url  = "http://jobboerse.arbeitsagentur.de/vamJB/stellenangeboteFinden.html";
     PageRetriever.Referer = Url;
     WareInfoList          = new List <ExtWareInfo>();
     Wares.Clear();
     BrandItemType   = 2;
     SpecialSettings = new ExtSettings();
 }
Пример #4
0
        /// <summary>
        /// 获取商品信息按钮点击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetWaresInfo_Click(object sender, EventArgs e)
        {
            Wares wares = JDHelper.GetInstance().GetWaresInfo(txtWaresId.Text);

            if (wares != null)
            {
                lsvFindWInfo.Items.Clear();
                ListViewItem lvItem = new ListViewItem();
                lvItem.Text = wares.id;
                lvItem.SubItems.Add(wares.title);
                lvItem.SubItems.Add(wares.price);
                lsvFindWInfo.Items.Add(lvItem);
            }
        }
Пример #5
0
        /// <summary>
        /// 获取商品信息
        /// </summary>
        /// <param name="waresId"></param>
        /// <returns></returns>
        public Wares GetWaresInfo(string waresId)
        {
            JDHttpHelper jdHttp = new JDHttpHelper();

            jdHttp.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";

            Dictionary <string, string> headerDic = new Dictionary <string, string>();

            headerDic["Accept-Encoding"] = "gzip, deflate, sdch, br";
            headerDic["Accept-Language"] = "zh-CN,zh;q=0.8";

            string url    = string.Format("https://item.jd.com/{0}.html", waresId);
            string result = jdHttp.GetHtml(url, "get", Encoding.UTF8, headerDic);

            Match reg = Regex.Match(result, @"<div class=""sku-name"">(.*?)</div>", RegexOptions.Singleline);

            WPrice wp = null;

            this.GetWaresPrice(waresId).TryGetValue(waresId, out wp);

            if (wp == null)
            {
                wp = new WPrice()
                {
                    p = "error!"
                };
            }
            Wares wares = null;

            wares = new Wares()
            {
                url   = url,
                id    = waresId,
                title = reg.Groups[1].Value.Trim(),
                price = wp.p
            };

            //查询价格
            //https://p.3.cn/prices/mgets?callback=jQuery5638364&type=1&area=5_274_3207_0&pdtk=&pduid=938279766&pdpin=&pdbp=0&skuIds=J_4082633&source=item-pc
            //查询是否有货
            //https://c0.3.cn/stock?skuId=4082633&area=5_274_3207_0&venderId=1000079304&cat=1318,1466,12122&buyNum=1&choseSuitSkuIds=&extraParam={%22originid%22:%221%22}&ch=1&fqsp=0&pduid=1982668971&pdpin=&callback=jQuery680992
            return(wares);
        }