/*public override void OnDoubleClick(Mobile from)
		{
			if(from.InRange(this.Location, 3) && from.Backpack != null)
			{
				WarehouseContainer container = MaginciaBazaar.ClaimContainer(from);
				
				if(container != null)
					TryTransferItems(from, container);
			}
		}*/

        public void TryTransferPets(Mobile from, StorageEntry entry)
        {
            if (entry == null)
                return;

            int fees = entry.Funds;

            if (fees < 0)
            {
                int owed = fees * -1;
                SayTo(from, String.Format("It looks like you owe {0}gp as back fees.  How much would you like to pay now?", owed.ToString("###,###,###")));
                from.Prompt = new BackfeePrompt(this, entry);
                return;
            }

            if (!TryPayFunds(from, entry))
            {
                from.SendGump(new BazaarInformationGump(1150681, 1150678)); // Some personal possessions that were equipped on the broker still remain in storage, because your backpack cannot hold them. Please free up space in your backpack and return to claim these items.
                return;
            }

            List<BaseCreature> list = new List<BaseCreature>(entry.Creatures);

            foreach (BaseCreature bc in list)
            {
                if (from.Stabled.Count < AnimalTrainer.GetMaxStabled(from))
                {
                    bc.Blessed = false;
                    bc.ControlOrder = OrderType.Stay;
                    bc.Internalize();
                    bc.IsStabled = true;
                    bc.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully happy
                    from.Stabled.Add(bc);
                    bc.SetControlMaster(null);
                    bc.SummonMaster = null;

                    entry.RemovePet(bc);
                }
                else
                {
                    from.SendGump(new BazaarInformationGump(1150681, 1150678)); // Some personal possessions that were equipped on the broker still remain in storage, because your backpack cannot hold them. Please free up space in your backpack and return to claim these items.
                    return;
                }
            }

            from.SendGump(new BazaarInformationGump(1150681, 1150677)); // There are no longer any items or funds in storage for your former bazaar stall. Thank you for your diligence in recovering your possessions.
            MaginciaBazaar.RemoveFromStorage(from);
        }
			public ClaimStorageEntry(Mobile from, WarehouseSuperintendent mobile) : base(1150681, 3)
			{
				m_Mobile = mobile;
                m_Entry = MaginciaBazaar.GetStorageEntry(from);

                if(m_Entry == null)
                    Flags |= CMEFlags.Disabled;
			}
		public void TryPayBackfee(Mobile from, string text, StorageEntry entry)
		{
			int amount = 0;
            int owed = entry.Funds * -1;

			try
			{
				amount = Convert.ToInt32(text);
				
				if(amount > 0)
				{
					int toDeduct = Math.Min(owed, amount);
					
					if(Banker.Withdraw(from, toDeduct))
					{
						entry.Funds += toDeduct;
                        int newAmount = entry.Funds;

                        if (newAmount >= 0)
							TryTransferPets(from, entry);
						else
							SayTo(from, String.Format("Thank you! You have a remaining balance of {0}gp as backfees!", newAmount * -1));
					}
					else
						SayTo(from, "You don't have enough funds in your bankbox to support that amount.");
				}
				
			}
			catch 
            {
                from.SendMessage("Invalid amount.");
            }
		}
			public BackfeePrompt(WarehouseSuperintendent mobile, StorageEntry entry)
			{
				m_Mobile = mobile;
                m_Entry = entry; ;
			}
        private bool TryPayFunds(Mobile from, StorageEntry entry)
        {
            int amount = entry.Funds;

            if (Banker.Deposit(from, amount, true))
            {
                entry.Funds = 0;
                return true;
            }

            return false;
        }
        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;
        }
		public void TryTransferItems(Mobile from, StorageEntry entry)
		{
            if (entry == null)
                return;

            int fees = entry.Funds;

			if(fees < 0)
			{
                int owed = fees * -1;
				SayTo(from, String.Format("It looks like you owe {0}gp as back fees.  How much would you like to pay now?", owed.ToString("###,###,###")));
				from.Prompt = new BackfeePrompt(this, entry);
                return;
			}

            if (!TryPayFunds(from, entry))
            {
                from.SendGump(new BazaarInformationGump(1150681, 1150678)); // Some personal possessions that were equipped on the broker still remain in storage, because your backpack cannot hold them. Please free up space in your backpack and return to claim these items.
                return;
            }

            Dictionary<Type, int> copy = new Dictionary<Type, int>(entry.CommodityTypes);

            foreach (KeyValuePair<Type, int> commodities in copy)
            {
                Type type = commodities.Key;
                int amt = commodities.Value;

                if (!GiveItems(from, type, amt, entry))
                {
                    from.SendGump(new BazaarInformationGump(1150681, 1150678)); // Some personal possessions that were equipped on the broker still remain in storage, because your backpack cannot hold them. Please free up space in your backpack and return to claim these items.
                    return;
                }
            }

			from.SendGump(new BazaarInformationGump(1150681, 1150677)); // There are no longer any items or funds in storage for your former bazaar stall. Thank you for your diligence in recovering your possessions.
		    MaginciaBazaar.RemoveFromStorage(from);
		}
Example #8
0
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);
			int version = reader.ReadInt();

            m_Enabled = reader.ReadBool();
            m_Phase = (Phase)reader.ReadInt();

			int count = reader.ReadInt();
			for(int i = 0; i < count; i++)
			{
                m_Plots.Add(new MaginciaBazaarPlot(reader));
			}
			
			count = reader.ReadInt();
			for(int i = 0; i < count; i++)
			{
				Mobile m = reader.ReadMobile();
				BidEntry entry = new BidEntry(reader);
				
				if(m != null)
					m_NextAvailable[m] = entry;
			}

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                Mobile m = reader.ReadMobile();

                StorageEntry entry = new StorageEntry(reader);

                if (m != null)
                    m_WarehouseStorage[m] = entry;
            }

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                Mobile m = reader.ReadMobile();
                int amt = reader.ReadInt();

                if (m != null && amt > 0)
                    m_Reserve[m] = amt;
            }
			
			m_Instance = this;

            if (m_Enabled)
                StartTimer();
		}
Example #9
0
		public void AddInventoryToWarehouse(Mobile owner, BaseBazaarBroker broker)
		{
            StorageEntry newEntry = null;

            if (broker is CommodityBroker && ((CommodityBroker)broker).CommodityEntries.Count > 0 && ((CommodityBroker)broker).HasValidEntry())
                newEntry = new StorageEntry(((CommodityBroker)broker).CommodityEntries, broker.BankBalance);
            else if (broker is PetBroker && ((PetBroker)broker).BrokerEntries.Count > 0 && ((PetBroker)broker).HasValidEntry())
                newEntry = new StorageEntry(((PetBroker)broker).BrokerEntries, broker.BankBalance);

            if (newEntry != null)
            {
                m_WarehouseStorage[owner] = newEntry;
                /*Your hired broker has transferred any remaining inventory and funds from 
                 *your stall at the New Magincia Bazaar into storage at the New Magincia 
                 *Warehouse. You must reclaim these items or they will be destroyed! To reclaim 
                 *these items, see the Warehouse Superintendent in New Magincia.<br><br>This 
                 *service is provided free of charge. If you owed your broker any back fees, 
                 *those fees must be paid before you can reclaim your belongings. The storage 
                 *period lasts 7 days starting with the expiration of your lease at the New 
                 *Magincia Bazaar, and this storage period cannot be extended. Claim your 
                 *possessions and gold without delay!<br><br>The expiration time of this 
                 *message coincides with the expiration time of your Warehouse storage.*/

                MaginciaLottoSystem.SendMessageTo(owner, new NewMaginciaMessage(1150676, new TextDefinition(1150674), null));
            }
		}