Esempio n. 1
0
        /// <summary>
        /// Search the MarketCache
        /// </summary>
        public virtual bool SearchInventory(GamePlayer player, MarketSearch.SearchData searchData)
        {
            MarketSearch         marketSearch = new MarketSearch(player);
            List <InventoryItem> items        = marketSearch.FindItemsInList(DBItems(), searchData);

            if (items != null)
            {
                int  maxPerPage           = 20;
                byte maxPages             = (byte)(Math.Ceiling((double)items.Count / (double)maxPerPage) - 1);
                int  first                = (searchData.page) * maxPerPage;
                int  last                 = first + maxPerPage;
                List <InventoryItem> list = new List <InventoryItem>();
                int index                 = 0;
                foreach (InventoryItem item in items)
                {
                    if (index >= first && index <= last)
                    {
                        list.Add(item);
                    }
                    index++;
                }

                if ((int)searchData.page == 0)
                {
                    player.Out.SendMessage("Items returned: " + items.Count + ".", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }

                if (items.Count == 0)                   // No items returned, let the client know
                {
                    player.Out.SendMarketExplorerWindow(list, 0, 0);
                }
                else if ((int)searchData.page <= (int)maxPages)                 //Don't let us tell the client about any more than the max pages
                {
                    player.Out.SendMessage("Moving to page " + ((int)(searchData.page + 1)) + ".", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    player.Out.SendMarketExplorerWindow(list, searchData.page, maxPages);
                }

                // Save the last search list in case we buy an item from it
                player.TempProperties.setProperty(EXPLORER_ITEM_LIST, list);
            }


            return(true);
        }
Esempio n. 2
0
 /// <summary>
 /// Do we handle a search?
 /// </summary>
 public bool SearchInventory(GamePlayer player, MarketSearch.SearchData searchData)
 {
     return false; // not applicable
 }
Esempio n. 3
0
		/// <summary>
		/// Search the MarketCache
		/// </summary>
		public virtual bool SearchInventory(GamePlayer player, MarketSearch.SearchData searchData)
		{
			MarketSearch marketSearch = new MarketSearch(player);
			List<InventoryItem> items = marketSearch.FindItemsInList(DBItems(), searchData);

			if (items != null)
			{
				int maxPerPage = 20;
				byte maxPages = (byte)(Math.Ceiling((double)items.Count / (double)maxPerPage) - 1);
				int first = (searchData.page) * maxPerPage;
				int last = first + maxPerPage;
				List<InventoryItem> list = new List<InventoryItem>();
				int index = 0;
				foreach (InventoryItem item in items)
				{
					if (index >= first && index <= last)
						list.Add(item);
					index++;
				}

				if ((int)searchData.page == 0)
				{
					player.Out.SendMessage("Items returned: " + items.Count + ".", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
				}

				if (items.Count == 0)	// No items returned, let the client know
				{
					player.Out.SendMarketExplorerWindow(list, 0, 0);
				}
				else if ((int)searchData.page <= (int)maxPages)	//Don't let us tell the client about any more than the max pages
				{
					player.Out.SendMessage("Moving to page " + ((int)(searchData.page + 1)) + ".", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
					player.Out.SendMarketExplorerWindow(list, searchData.page, maxPages);
				}

				// Save the last search list in case we buy an item from it
				player.TempProperties.setProperty(EXPLORER_ITEM_LIST, list);
			}


			return true;
		}