示例#1
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            int index = info.ButtonID;

            switch (index)
            {
            case 0:                     // EXIT
            {
                break;
            }

            case 1:                     // Set Filter
            {
                m_From.SendGump(new BOBFilterGump2(m_From, m_Book));

                break;
            }

            case 2:                     // Previous page
            {
                if (m_Page > 0)
                {
                    m_From.SendGump(new BOBGump2(m_From, m_Book, m_Page - 1, m_List));
                }

                return;
            }

            case 3:                     // Next page
            {
                if (GetIndexForPage(m_Page + 1) < m_List.Count)
                {
                    m_From.SendGump(new BOBGump2(m_From, m_Book, m_Page + 1, m_List));
                }

                break;
            }

            case 4:                     // Price all
            {
                if (m_Book.IsChildOf(m_From.Backpack))
                {
                    m_From.Prompt = new SetPricePrompt(m_Book, null, m_Page, m_List);
                    m_From.SendMessage("Type in a price for all deeds in the book:");
                }

                break;
            }

            default:
            {
                bool canDrop  = m_Book.IsChildOf(m_From.Backpack);
                bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor);

                index -= 5;

                int type = index % 2;
                index /= 2;

                if (index < 0 || index >= m_List.Count)
                {
                    break;
                }

                object obj = m_List[index];

                if (!m_Book.Entries.Contains(obj))
                {
                    m_From.SendLocalizedMessage(1062382);                               // The deed selected is not available.
                    break;
                }

                if (type == 0)                           // Drop
                {
                    if (m_Book.IsChildOf(m_From.Backpack))
                    {
                        Item item = Reconstruct(obj);

                        if (item != null)
                        {
                            Container pack = m_From.Backpack;
                            if ((pack == null) || ((pack != null) && (!pack.CheckHold(m_From, item, true, true, 0, item.PileWeight + item.TotalWeight))))
                            {
                                m_From.SendLocalizedMessage(503204);                                         // You do not have room in your backpack for this
                                m_From.SendGump(new BOBGump2(m_From, m_Book, m_Page, null));
                            }
                            else
                            {
                                if (m_Book.IsChildOf(m_From.Backpack))
                                {
                                    int sizeOfDroppedBod;
                                    if (obj is BOBLargeEntry)
                                    {
                                        sizeOfDroppedBod = ((BOBLargeEntry)obj).Entries.Length;
                                    }
                                    else
                                    {
                                        sizeOfDroppedBod = 1;
                                    }

                                    m_From.AddToBackpack(item);
                                    m_From.SendLocalizedMessage(1045152);                                             // The bulk order deed has been placed in your backpack.
                                    m_Book.Entries.Remove(obj);
                                    m_Book.InvalidateProperties();

                                    if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
                                    {
                                        m_Book.ItemCount--;
                                        m_Book.InvalidateItems();
                                    }

                                    if (m_Book.Entries.Count > 0)
                                    {
                                        m_Page = GetPageForIndex(index, sizeOfDroppedBod);
                                        m_From.SendGump(new BOBGump2(m_From, m_Book, m_Page, null));
                                    }
                                    else
                                    {
                                        m_From.SendLocalizedMessage(1062381);                                                 // The book is empty.
                                    }
                                }
                            }
                        }
                        else
                        {
                            m_From.SendMessage("Internal error. The bulk order deed could not be reconstructed.");
                        }
                    }
                }
                else                         // Set Price | Buy
                {
                    if (m_Book.IsChildOf(m_From.Backpack))
                    {
                        m_From.Prompt = new SetPricePrompt(m_Book, obj, m_Page, m_List);
                        m_From.SendLocalizedMessage(1062383);                                   // Type in a price for the deed:
                    }
                    else if (m_Book.RootParent is PlayerVendor)
                    {
                        PlayerVendor pv = (PlayerVendor)m_Book.RootParent;
                        VendorItem   vi = pv.GetVendorItem(m_Book);

                        if (vi != null && !vi.IsForSale)
                        {
                            int sizeOfDroppedBod;
                            int price = 0;
                            if (obj is BOBLargeEntry)
                            {
                                price            = ((BOBLargeEntry)obj).Price;
                                sizeOfDroppedBod = ((BOBLargeEntry)obj).Entries.Length;
                            }
                            else
                            {
                                price            = ((BOBSmallEntry)obj).Price;
                                sizeOfDroppedBod = 1;
                            }
                            if (price == 0)
                            {
                                m_From.SendLocalizedMessage(1062382);                                         // The deed selected is not available.
                            }
                            else
                            {
                                if (m_Book.Entries.Count > 0)
                                {
                                    m_Page = GetPageForIndex(index, sizeOfDroppedBod);
                                    m_From.SendGump(new BODBuyGump2(m_From, m_Book, obj, m_Page, price));
                                }
                                else
                                {
                                    m_From.SendLocalizedMessage(1062381);                                             // The book is emptz
                                }
                            }
                        }
                    }
                }
                break;
            }
            }
        }
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 2)
            {
                PlayerVendor pv = m_Book.RootParent as PlayerVendor;

                if (m_Book.Entries.Contains(m_Object) && pv != null)
                {
                    int price = 0;

                    VendorItem vi = pv.GetVendorItem(m_Book);

                    if (vi != null && !vi.IsForSale)
                    {
                        if (m_Object is BOBLargeEntry)
                        {
                            price = ((BOBLargeEntry)m_Object).Price;
                        }
                        else if (m_Object is BOBSmallEntry)
                        {
                            price = ((BOBSmallEntry)m_Object).Price;
                        }
                    }

                    if (price != m_Price)
                    {
                        pv.SayTo(m_From, "The price has been been changed. If you like, you may offer to purchase the item again.");
                    }
                    else if (price == 0)
                    {
                        pv.SayTo(m_From, 1062382);                           // The deed selected is not available.
                    }
                    else
                    {
                        Item item = null;

                        if (m_Object is BOBLargeEntry)
                        {
                            item = ((BOBLargeEntry)m_Object).Reconstruct();
                        }
                        else if (m_Object is BOBSmallEntry)
                        {
                            item = ((BOBSmallEntry)m_Object).Reconstruct();
                        }

                        if (item == null)
                        {
                            m_From.SendMessage("Internal error. The bulk order deed could not be reconstructed.");
                        }
                        else
                        {
                            pv.Say(m_From.Name);

                            Container pack = m_From.Backpack;

                            if ((pack == null) || ((pack != null) && (!pack.CheckHold(m_From, item, true, true, 0, item.PileWeight + item.TotalWeight))))
                            {
                                pv.SayTo(m_From, 503204);                                 // You do not have room in your backpack for this
                                m_From.SendGump(new BOBGump2(m_From, m_Book, m_Page, null));
                            }
                            else
                            {
                                if ((pack != null && pack.ConsumeTotal(typeof(Gold), price)) || Banker.Withdraw(m_From, price))
                                {
                                    m_Book.Entries.Remove(m_Object);
                                    m_Book.InvalidateProperties();
                                    pv.HoldGold += price;
                                    m_From.AddToBackpack(item);
                                    m_From.SendLocalizedMessage(1045152);                                       // The bulk order deed has been placed in your backpack.

                                    if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
                                    {
                                        m_Book.ItemCount--;
                                        m_Book.InvalidateItems();
                                    }

                                    if (m_Book.Entries.Count > 0)
                                    {
                                        m_From.SendGump(new BOBGump2(m_From, m_Book, m_Page, null));
                                    }
                                    else
                                    {
                                        m_From.SendLocalizedMessage(1062381);                                           // The book is empty.
                                    }
                                }
                                else
                                {
                                    pv.SayTo(m_From, 503205);                                       // You cannot afford this item.
                                    item.Delete();
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (pv == null)
                    {
                        m_From.SendLocalizedMessage(1062382);                           // The deed selected is not available.
                    }
                    else
                    {
                        pv.SayTo(m_From, 1062382);                           // The deed selected is not available.
                    }
                }
            }
            else
            {
                m_From.SendLocalizedMessage(503207);                   // Cancelled purchase.
            }
        }