Ejemplo n.º 1
0
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                Mobile from = sender.Mobile;

                int available = Vendor.MaxAmount - MiningCooperative.PurchaseAmount(from);
                int payment   = Vendor.Quantity * Vendor.Price;

                if (info.ButtonID == 1)
                {
                    if (available > 0)
                    {
                        if (Banker.Withdraw(from, payment, true))
                        {
                            CommodityDeed deed = new CommodityDeed();
                            deed.SetCommodity(new EtherealSand(Vendor.Quantity));
                            from.AddToBackpack(deed);

                            MiningCooperative.AddPurchase(from, Vendor.Quantity);
                            from.SendGump(new MiningCooperativeGump(Vendor, from));
                        }
                        else
                        {
                            Vendor.Say(500192); // Begging thy pardon, but thou canst not afford that.
                        }
                    }
                    else
                    {
                        Vendor.Say(1159195); // Begging thy pardon, but your family has purchased the maximum amount of that commodity.  I cannot sell you more until a new shipment arrives!
                    }
                }
            }
Ejemplo n.º 2
0
        private void ConvertCommodities()
        {
            var items = new List <Item>(Items);

            for (int i = 0; i < items.Count; i++)
            {
                var item = items[i];

                if (item is ICommodity && ((ICommodity)item).IsDeedable)
                {
                    var deed = new CommodityDeed();

                    if (deed.SetCommodity(item))
                    {
                        DropItem(deed);
                    }
                    else
                    {
                        deed.Delete();
                    }
                }
            }

            ColUtility.Free(items);
        }
Ejemplo n.º 3
0
        public void WithdrawInventory(Mobile from, int amount, CommodityBrokerEntry entry)
        {
            if (from == null || Plot == null || entry == null || !m_CommodityEntries.Contains(entry))
            {
                return;
            }

            Container pack = from.Backpack;

            if (pack != null)
            {
                while (amount > 60000)
                {
                    CommodityDeed deed = new CommodityDeed();
                    Item          item = Loot.Construct(entry.CommodityType);
                    item.Amount = 60000;
                    deed.SetCommodity(item);
                    pack.DropItem(deed);
                    amount      -= 60000;
                    entry.Stock -= 60000;
                }

                CommodityDeed deed2   = new CommodityDeed();
                Item          newitem = Loot.Construct(entry.CommodityType);
                newitem.Amount = amount;
                deed2.SetCommodity(newitem);
                pack.DropItem(deed2);
                entry.Stock -= amount;
            }

            if (Plot != null && from == Plot.Owner)
            {
                from.SendLocalizedMessage(1150221, string.Format("{0}\t#{1}\t{2}", amount.ToString(), entry.Label, Plot.ShopName != null ? Plot.ShopName : "a shop with no name")); // You have removed ~1_QUANTITY~ units of ~2_ITEMNAME~ from the inventory of "~3_SHOPNAME~"
            }
        }
Ejemplo n.º 4
0
        private void TakeCommodities(Container c, Type type, ref int amount)
        {
            if (c == null)
            {
                return;
            }

            Item[]      items  = c.FindItemsByType(typeof(CommodityDeed));
            List <Item> toSell = new List <Item>();

            for (var index = 0; index < items.Length; index++)
            {
                Item item = items[index];

                if (item is CommodityDeed commodityDeed && commodityDeed.Commodity != null && commodityDeed.Commodity.GetType() == type)
                {
                    Item commodity = commodityDeed.Commodity;

                    if (commodity.Amount <= amount)
                    {
                        toSell.Add(item);
                        amount -= commodity.Amount;
                    }
                    else
                    {
                        CommodityDeed newDeed = new CommodityDeed();
                        Item          newItem = Loot.Construct(type);

                        newItem.Amount = amount;
                        newDeed.SetCommodity(newItem);

                        commodity.Amount -= amount;
                        commodityDeed.InvalidateProperties();
                        toSell.Add(newDeed);
                        amount = 0;
                    }
                }
            }

            for (var index = 0; index < toSell.Count; index++)
            {
                Item item = toSell[index];

                AddInventory(null, item);
            }
        }
Ejemplo n.º 5
0
        private bool GiveItems(Mobile from, Type type, int amt, StorageEntry entry)
        {
            int amount = amt;

            while (amount > 60000)
            {
                CommodityDeed deed = new CommodityDeed();
                Item          item = Loot.Construct(type);
                item.Amount = 60000;
                deed.SetCommodity(item);
                amount -= 60000;

                if (from.Backpack == null || !from.Backpack.TryDropItem(from, deed, false))
                {
                    deed.Delete();
                    return(false);
                }
                else
                {
                    entry.RemoveCommodity(type, 60000);
                }
            }

            CommodityDeed deed2 = new CommodityDeed();
            Item          item2 = Loot.Construct(type);

            item2.Amount = amount;
            deed2.SetCommodity(item2);

            if (from.Backpack == null || !from.Backpack.TryDropItem(from, deed2, false))
            {
                deed2.Delete();
                return(false);
            }
            else
            {
                entry.RemoveCommodity(type, amount);
            }

            return(true);
        }