示例#1
0
        /// <summary>
        /// Retrieve all market orders created by <code>seller</code>
        /// </summary>
        public static List <MarketEntry> EntriesBySeller(Mobile seller)
        {
            List <MarketEntry> list   = new List <MarketEntry>();
            SQLiteDataReader   reader = ExecuteQuery("SELECT entryid,active,category,cost,description,itemserial FROM entries WHERE sellerserial = " + (int)seller.Serial);

            while (reader.Read())
            {
                IEntity     saleObject = World.FindEntity(reader.GetInt32(reader.GetOrdinal("itemserial")));
                MarketEntry entry      = new MarketEntry(seller);

                entry.Active      = reader.GetBoolean(reader.GetOrdinal("active"));
                entry.Category    = (Category)reader.GetInt32(reader.GetOrdinal("category"));
                entry.Description = reader.GetString(reader.GetOrdinal("description"));
                entry.TableId     = reader.GetInt32(reader.GetOrdinal("entryid"));

                if (saleObject != null)
                {
                    entry.SetSellItem(saleObject);
                }

                entry.ChangeCost(reader.GetInt32(reader.GetOrdinal("cost")), 0, 0);

                list.Add(entry);
            }

            reader.Close();

            return(list);
        }
示例#2
0
        /// <summary>
        /// Retrieve all market orders matching <code>category</code>
        /// </summary>
        public static List <MarketEntry> EntriesByCategory(Category category)
        {
            List <MarketEntry> list   = new List <MarketEntry>();
            SQLiteDataReader   reader = ExecuteQuery("SELECT entryid,cost,description,itemserial,sellerserial FROM entries WHERE active = 1 AND category = " + (int)category);

            while (reader.Read())
            {
                Mobile  seller     = World.FindMobile(reader.GetInt32(reader.GetOrdinal("sellerserial")));
                IEntity saleObject = World.FindEntity(reader.GetInt32(reader.GetOrdinal("itemserial")));

                if (seller == null || saleObject == null)
                {
                    continue;
                }

                MarketEntry entry = new MarketEntry(seller);
                entry.Category    = category;
                entry.Description = reader.GetString(reader.GetOrdinal("description"));
                entry.TableId     = reader.GetInt32(reader.GetOrdinal("entryid"));

                entry.ChangeCost(reader.GetInt32(reader.GetOrdinal("cost")), 0, 0);
                entry.SetSellItem(saleObject);

                list.Add(entry);
            }

            reader.Close();

            return(list);
        }
示例#3
0
        /// <summary>
        /// Retrieve all market orders matching <code>category</code>
        /// </summary>
        public static List<MarketEntry> EntriesByCategory( Category category )
        {
            List<MarketEntry> list = new List<MarketEntry>();
            SQLiteDataReader reader = ExecuteQuery("SELECT entryid,cost,description,itemserial,sellerserial FROM entries WHERE active = 1 AND category = " + (int)category);

            while( reader.Read() )
            {
                Mobile seller = World.FindMobile(reader.GetInt32(reader.GetOrdinal("sellerserial")));
                IEntity saleObject = World.FindEntity(reader.GetInt32(reader.GetOrdinal("itemserial")));

                if( seller == null || saleObject == null )
                    continue;

                MarketEntry entry = new MarketEntry(seller);
                entry.Category = category;
                entry.Description = reader.GetString(reader.GetOrdinal("description"));
                entry.TableId = reader.GetInt32(reader.GetOrdinal("entryid"));

                entry.ChangeCost(reader.GetInt32(reader.GetOrdinal("cost")), 0, 0);
                entry.SetSellItem(saleObject);

                list.Add(entry);
            }

            reader.Close();

            return list;
        }
示例#4
0
        /// <summary>
        /// Retrieve all market orders created by <code>seller</code>
        /// </summary>
        public static List<MarketEntry> EntriesBySeller( Mobile seller )
        {
            List<MarketEntry> list = new List<MarketEntry>();
            SQLiteDataReader reader = ExecuteQuery("SELECT entryid,active,category,cost,description,itemserial FROM entries WHERE sellerserial = " + (int)seller.Serial);

            while( reader.Read() )
            {
                IEntity saleObject = World.FindEntity(reader.GetInt32(reader.GetOrdinal("itemserial")));
                MarketEntry entry = new MarketEntry(seller);

                entry.Active = reader.GetBoolean(reader.GetOrdinal("active"));
                entry.Category = (Category)reader.GetInt32(reader.GetOrdinal("category"));
                entry.Description = reader.GetString(reader.GetOrdinal("description"));
                entry.TableId = reader.GetInt32(reader.GetOrdinal("entryid"));

                if( saleObject != null )
                    entry.SetSellItem(saleObject);

                entry.ChangeCost(reader.GetInt32(reader.GetOrdinal("cost")), 0, 0);

                list.Add(entry);
            }

            reader.Close();

            return list;
        }
示例#5
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            int val, type, index;

            DecodeButtonId(info.ButtonID, out val, out type, out index);

            if (val < 0)
            {
                return;
            }

            Mobile from = sender.Mobile;

            if (type == 1)
            {
                if (index == 1)
                {
                    bool newOrder = (_entry == null);

                    if (newOrder)
                    {
                        _entry = new MarketEntry(from);
                    }

                    _entry.Category = (Category)(info.Switches[0] - 1);

                    string cc = info.GetTextEntry(1).Text;
                    string cs = info.GetTextEntry(2).Text;
                    string cg = info.GetTextEntry(3).Text;

                    Regex rx = new Regex("[^0-9]");
                    cc = rx.Replace(cc, ""); cc.Trim();
                    cs = rx.Replace(cs, ""); cs.Trim();
                    cg = rx.Replace(cg, ""); cg.Trim();

                    int[] cost = new int[]
                    {
                        (String.IsNullOrEmpty(cc) ? 0 : Convert.ToInt32(cc)),
                        (String.IsNullOrEmpty(cs) ? 0 : Convert.ToInt32(cs)),
                        (String.IsNullOrEmpty(cg) ? 0 : Convert.ToInt32(cg))
                    };
                    _entry.ChangeCost(cost[0], cost[1], cost[2]);
                    _entry.Description = info.GetTextEntry(4).Text;

                    if (_entry.Cost < 10)
                    {
                        from.SendMessage("Please enter a price of at least 10 copper.");
                        from.SendGump(new OrderManagementGump(_entry));
                    }
                    else if (String.IsNullOrEmpty(_entry.Description))
                    {
                        from.SendMessage("Please enter a description for your order.");
                        from.SendGump(new OrderManagementGump(_entry));
                    }
                    else
                    {
                        if (newOrder)
                        {
                            Market.AddNewOrder(from, _entry);
                        }
                        else
                        {
                            Market.UpdateOrder(from, _entry);
                        }
                    }
                }
                else if (index == 2 && _entry != null)                  //cancel order
                {
                    Market.CloseOrder(_entry, false);
                }
            }
        }