Ejemplo n.º 1
0
        public static int GetBalance(Mobile m, out Item[] gold, out Item[] checks)
        {
            double balance = 0;

			if (AccountGold.Enabled && m.Account != null)
            {
                int goldStub;
                m.Account.GetGoldBalance(out goldStub, out balance);

                if (balance > Int32.MaxValue)
                {
                    gold = checks = new Item[0];
                    return Int32.MaxValue;
                }
            }

            Container bank = m.FindBankNoCreate();

            if (bank != null)
            {
                gold = bank.FindItemsByType(typeof(Gold));
                checks = bank.FindItemsByType(typeof(BankCheck));

                balance += gold.OfType<Gold>().Aggregate(0.0, (c, t) => c + t.Amount);
                balance += checks.OfType<BankCheck>().Aggregate(0.0, (c, t) => c + t.Worth);
            }
            else
            {
                gold = checks = new Item[0];
            }

            return (int)Math.Max(0, Math.Min(Int32.MaxValue, balance));
        }
Ejemplo n.º 2
0
		public static ulong GetBalance(Mobile from, Type currencyType, out Item[] currency, out ulong credit)
		{
			ulong balance = 0;

			BankBox bank = from.FindBankNoCreate();
			
			if (bank != null)
			{
				Type cType = bank.Expansion == Expansion.T2A ? typeof(Silver) : typeof(Gold);

				credit = cType == currencyType ? bank.Credit : 0;

				balance += credit;

				currency = bank.FindItemsByType(currencyType, true).ToArray();

				balance = currency.Aggregate(balance, (current, t) => current + (ulong)t.Amount);
			}
			else
			{
				currency = new Item[0];
				credit = 0;
			}

			return balance;
		}
Ejemplo n.º 3
0
        public static int GetBalance(Mobile m)
        {
            double balance = 0;

			if (AccountGold.Enabled && m.Account != null)
            {
                int goldStub;
                m.Account.GetGoldBalance(out goldStub, out balance);

                if (balance > Int32.MaxValue)
                {
                    return Int32.MaxValue;
                }
            }

            Container bank = m.FindBankNoCreate();

            if (bank != null)
            {
                var gold = bank.FindItemsByType<Gold>();
                var checks = bank.FindItemsByType<BankCheck>();

                balance += gold.Aggregate(0.0, (c, t) => c + t.Amount);
                balance += checks.Aggregate(0.0, (c, t) => c + t.Worth);
            }

            return (int)Math.Max(0, Math.Min(Int32.MaxValue, balance));
        }
Ejemplo n.º 4
0
		public override void OnDoubleClick( Mobile from )
		{
			BankBox box = from.FindBankNoCreate();

			if ( box != null && IsChildOf( box ) )
			{
				Delete();

				int deposited = 0;

				int toAdd = m_Worth;

				Gold gold;

				while ( toAdd > 60000 )
				{
					gold = new Gold( 60000 );

					if ( box.TryDropItem( from, gold, false ) )
					{
						toAdd -= 60000;
						deposited += 60000;
					}
					else
					{
						gold.Delete();

						from.AddToBackpack( new BankCheck( toAdd ) );
						toAdd = 0;

						break;
					}
				}

				if ( toAdd > 0 )
				{
					gold = new Gold( toAdd );

					if ( box.TryDropItem( from, gold, false ) )
					{
						deposited += toAdd;
					}
					else
					{
						gold.Delete();

						from.AddToBackpack( new BankCheck( toAdd ) );
					}
				}

				// Gold was deposited in your account:
				from.SendLocalizedMessage( 1042672, true, " " + deposited.ToString() );
			}
			else
			{
				from.SendLocalizedMessage( 1047026 ); // That must be in your bank box to use it.
			}
		}
Ejemplo n.º 5
0
        public static bool Deposit(Mobile from, int amount)
        {
            // If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
            if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount))
            {
                return true;
            }

            var box = from.FindBankNoCreate();

            if (box == null)
            {
                return false;
            }

            var items = new List<Item>();

            while (amount > 0)
            {
                Item item;
                if (amount < 5000)
                {
                    item = new Gold(amount);
                    amount = 0;
                }
                else if (amount <= 1000000)
                {
                    item = new BankCheck(amount);
                    amount = 0;
                }
                else
                {
                    item = new BankCheck(1000000);
                    amount -= 1000000;
                }

                if (box.TryDropItem(from, item, false))
                {
                    items.Add(item);
                }
                else
                {
                    item.Delete();
                    foreach (var curItem in items)
                    {
                        curItem.Delete();
                    }

                    return false;
                }
            }

            return true;
        }
Ejemplo n.º 6
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Deed.Deleted)
                {
                    return;
                }

                int number;

                if (m_Deed.Commodity != null)
                {
                    number = 1047028;                     // The commodity deed has already been filled.
                }

                else if (targeted is Item)
                {
                    BankBox box = from.FindBankNoCreate();

                    // Veteran Rewards mods
                    if (box != null && m_Deed.IsChildOf(box) && ((Item)targeted).IsChildOf(box))
                    {
                        if (m_Deed.SetCommodity((Item)targeted))
                        {
                            m_Deed.Hue = 0x592;
                            number     = 1047030;                         // The commodity deed has been filled.
                        }

                        else
                        {
                            number = 1047027;                             // That is not a commodity the bankers will fill a commodity deed with.
                        }
                    }
                    else
                    {
                        if (Core.ML)
                        {
                            number = 1080526;                             // That must be in your bank box or commodity deed box to use it.
                        }
                        else
                        {
                            number = 1047026;                             // That must be in your bank box to use it.
                        }
                    }
                }
                else
                {
                    number = 1047027;                     // That is not a commodity the bankers will fill a commodity deed with.
                }

                from.SendLocalizedMessage(number);
            }
Ejemplo n.º 7
0
        public static int DepositUpTo(Mobile from, int amount)
        {
            // If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
            if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount))
            {
                return(amount);
            }

            var box = from.FindBankNoCreate();

            if (box == null)
            {
                return(0);
            }

            var amountLeft = amount;

            while (amountLeft > 0)
            {
                Item item;
                int  amountGiven;

                if (amountLeft < 5000)
                {
                    item        = new Gold(amountLeft);
                    amountGiven = amountLeft;
                }
                else if (amountLeft <= 1000000)
                {
                    item        = new BankCheck(amountLeft);
                    amountGiven = amountLeft;
                }
                else
                {
                    item        = new BankCheck(1000000);
                    amountGiven = 1000000;
                }

                if (box.TryDropItem(from, item, false))
                {
                    amountLeft -= amountGiven;
                }
                else
                {
                    item.Delete();
                    break;
                }
            }

            return(amount - amountLeft);
        }
Ejemplo n.º 8
0
        public static bool Deposit(Mobile from, int amount)
        {
            BankBox box = from.FindBankNoCreate();

            if (box == null)
            {
                return(false);
            }

            List <Item> items = new List <Item>();

            while (amount > 0)
            {
                Item item;

                /*if ( amount < 5000 )
                 * {
                 *      item = new Gold( amount );
                 *      amount = 0;
                 * }*/
                if (amount <= 60000)
                {
                    item   = new Gold(amount);
                    amount = 0;
                }
                else
                {
                    item    = new Gold(60000);
                    amount -= 60000;
                }

                if (box.TryDropItem(from, item, false))
                {
                    items.Add(item);
                }
                else
                {
                    item.Delete();
                    foreach (Item curItem in items)
                    {
                        curItem.Delete();
                    }

                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 9
0
        public static int DepositUpTo(Mobile from, Type currencyType, int amount)
        {
            BankBox box = from.FindBankNoCreate();

            if (box != null)
            {
                int amountLeft = amount;

                while (amountLeft > 0)
                {
                    Item item;
                    int  amountGiven;

                    if (amountLeft < 5000)
                    {
                        item = currencyType.CreateInstanceSafe <Item>();

                        item.Stackable = true;
                        item.Amount    = amountLeft;

                        amountGiven = amountLeft;
                    }
                    else if (amountLeft <= 1000000)
                    {
                        item        = new BankCheck(amountLeft);
                        amountGiven = amountLeft;
                    }
                    else
                    {
                        item        = new BankCheck(1000000);
                        amountGiven = 1000000;
                    }

                    if (box.TryDropItem(from, item, false))
                    {
                        amountLeft -= amountGiven;
                    }
                    else
                    {
                        item.Delete();
                        break;
                    }
                }

                return(amount - amountLeft);
            }

            return(0);
        }
Ejemplo n.º 10
0
            public override void OnClick()
            {             // Fixed 1.9.4, uses the same gold check so that players don't get the wrong message when they do not have enough gold in their bank or inventory.
                Container bank = m_From.FindBankNoCreate();

                if ((m_From.Backpack == null || m_From.Backpack.GetAmount(typeof(Gold)) < 30) && (bank == null))                      // || (Banker.Withdraw(typeof(Gold)) < 30)))  //bank.GetAmount( typeof( Gold ) ) < 30 ) )
                {
                    m_Attendant.SayTo(m_From, "Thou dost not have enough gold, not even in thy bank account.");                       // Thou dost not have enough gold, not even in thy bank account.
                }
                else
                {
                    m_Attendant.SayTo(m_From, "I need thirty gold for the carrier pigeon rental.");

                    m_From.Target = new RoomTarget(m_Attendant);
                }
            }
Ejemplo n.º 11
0
        public override void OnDoubleClick(Mobile from)
        {
            BankBox box = from.FindBankNoCreate();

            if (box != null && IsChildOf(box))
            {
                Delete();
                int nGold = this.Amount * 5;
                from.AddToBackpack(new Gold(nGold));
            }
            else
            {
                from.SendLocalizedMessage(1047026);                   // That must be in your bank box to use it.
            }
        }
Ejemplo n.º 12
0
        public void CloneClothes(Mobile m)
        {
            Items.RemoveAll(i => i == null || i.Deleted);
            Items.For((k, v) => v.Delete());

            if (m == null || m.Deleted)
            {
                return;
            }

            m.Items.Where(i => i != null && !i.Deleted && i != m.Backpack && i != m.FindBankNoCreate() && i != m.Mount)
            .Select(CloneItem)
            .Not(i => i == null || i.Deleted)
            .ForEach(AddItem);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Moves all of the given Mobile's items to their bank.
        /// </summary>
        public virtual void PackToBank(Mobile m)
        {
            if (m == null || !m.Player)
            {
                return;
            }

            BankBox  bank = m.FindBankNoCreate();
            Backpack pack = new Backpack();

            pack.Hue = 1157;

            List <Item> items = new List <Item>();

            for (int i = 0; i < m.Items.Count; i++)
            {
                if (m.Items[i] is BankBox || (m.Backpack != null && m.Items[i].Serial == m.Backpack.Serial))
                {
                    continue;
                }

                items.Add(m.Items[i]);
            }

            if (m.Backpack != null)
            {
                for (int i = 0; i < m.Backpack.Items.Count; i++)
                {
                    items.Add(m.Backpack.Items[i]);
                }
            }

            items.ForEach(
                delegate(Item i)
            {
                pack.AddItem(i);
            });
            items.Clear();

            if (bank == null)
            {
                pack.MoveToWorld(m.Location, m.Map);
            }
            else
            {
                bank.AddItem(pack);
            }
        }
Ejemplo n.º 14
0
        public static int DepositUpTo(Mobile from, int amount)
        {
            BankBox box = from.FindBankNoCreate();

            if (box == null)
            {
                return(0);
            }

            int amountLeft = amount;

            while (amountLeft > 0)
            {
                Item item;
                int  amountGiven;

                if (amountLeft < 5000)
                {
                    item        = new Gold(amountLeft);
                    amountGiven = amountLeft;
                }

                else if (amountLeft <= 1000000)
                {
                    item        = new BankCheck(amountLeft);
                    amountGiven = amountLeft;
                }

                else
                {
                    item        = new BankCheck(1000000);
                    amountGiven = 1000000;
                }

                if (box.TryDropItem(from, item, false))
                {
                    amountLeft -= amountGiven;
                }

                else
                {
                    item.Delete();
                    break;
                }
            }

            return(amount - amountLeft);
        }
Ejemplo n.º 15
0
        private bool SpendGold(int amount)
        {
            bool bought   = (Owner.AccessLevel >= AccessLevel.GameMaster);
            bool fromBank = false;

            Container cont = Owner.Backpack;

            if (!bought && cont != null)
            {
                if (cont.ConsumeTotal(typeof(Gold), amount))
                {
                    bought = true;
                }
                else
                {
                    cont = Owner.FindBankNoCreate();
                    if (cont != null && cont.ConsumeTotal(typeof(Gold), amount))
                    {
                        bought   = true;
                        fromBank = true;
                    }
                    else
                    {
                        Owner.SendLocalizedMessage(500192);
                    }
                }
            }

            if (bought)
            {
                if (Owner.AccessLevel >= AccessLevel.GameMaster)
                {
                    Owner.SendMessage("{0} gold would have been withdrawn from your bank if you were not a GM.", amount);
                }
                else if (fromBank)
                {
                    Owner.SendMessage("The total of your purchase is {0} gold, which has been withdrawn from your bank account.  My thanks for your patronage.", amount);
                }
                else
                {
                    Owner.SendMessage("The total of your purchase is {0} gold.  My thanks for your patronage.", amount);
                }
            }

            Owner.PlaySound(0x2A);
            Owner.Animate(32, 5, 1, true, false, 0);
            return(bought);
        }
Ejemplo n.º 16
0
        public static int GetBalance(Mobile m)
        {
            double balance = 0;

            if (AccountGold.Enabled && m.Account != null)
            {
                int goldStub;
                m.Account.GetGoldBalance(out goldStub, out balance);

                if (balance > int.MaxValue)
                {
                    return(int.MaxValue);
                }
            }

            Container bank = m.Player ? m.BankBox : m.FindBankNoCreate();

            if (bank != null)
            {
                List <Gold>      gold   = bank.FindItemsByType <Gold>();
                List <BankCheck> checks = bank.FindItemsByType <BankCheck>();

                double result = 0.0;
                for (var index = 0; index < gold.Count; index++)
                {
                    var gold1 = gold[index];

                    result = result + gold1.Amount;
                }

                balance += result;

                double result1 = 0.0;
                for (var index = 0; index < checks.Count; index++)
                {
                    var check = checks[index];

                    result1 = result1 + check.Worth;
                }

                balance += result1;
            }

            return((int)Math.Max(0, Math.Min(int.MaxValue, balance)));
        }
Ejemplo n.º 17
0
        public static bool Deposit( Mobile from, int amount )
        {
            BankBox box = from.FindBankNoCreate();
            if ( box == null )
                return false;

            List<Item> items = new List<Item>();

            while ( amount > 0 )
            {
                Item item;
                if ( amount < 5000 )
                {
                    item = new Gold( amount );
                    amount = 0;
                }
                else if ( amount <= 1000000 )
                {
                    item = new BankCheck( amount );
                    amount = 0;
                }
                else
                {
                    item = new BankCheck( 1000000 );
                    amount -= 1000000;
                }

                if ( box.TryDropItem( from, item, false ) )
                {
                    items.Add( item );
                }
                else
                {
                    item.Delete();
                    foreach ( Item curItem in items )
                    {
                        curItem.Delete();
                    }

                    return false;
                }
            }

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

            if (from == null)
            {
                return;
            }

            Container cont = from.FindBankNoCreate();

            if (cont == null)
            {
                return;
            }

            switch (info.ButtonID)
            {
            case (int)Buttons.Okay:
            {
                if (from.Backpack.ConsumeTotal(typeof(Gold), 300) == true)
                {
                    //m_box.RenewTime = DateTime.Now + TimeSpan.FromSeconds(30.0);//Testing Purpose
                    m_box.RenewTime = DateTime.Now + TimeSpan.FromDays(30.0);                            //Change How long you want the Rent Time.
                    m_box.Account   = from.Account.Username;
                    m_box.Hue       = 0x482;
                    m_box.Name      = from.Name + "'s Account Deposit Box";
                    from.SendMessage("You successfully bought use of this Account Deposit Box!");
                    from.SendMessage("This Account Deposit Box is now linked to all characters on this account.");
                }
                else
                {
                    from.SendMessage("You do not have enough gold in the Backpack to purchase the Account Deposit Box.");
                }
                break;
            }

            case (int)Buttons.Cancel:
            {
                from.SendMessage("You decide against buying use of this Account Deposit Box.");
                from.CloseGump(typeof(AccountDBoxGump));
                break;
            }
            }
        }
Ejemplo n.º 19
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Deed.Deleted)
                {
                    return;
                }

                int number;

                if (m_Deed.Commodity != null)
                {
                    number = 1047028; // The commodity deed has already been filled.
                }
                else if (targeted is Item item)
                {
                    BankBox          box  = from.FindBankNoCreate();
                    CommodityDeedBox cox  = CommodityDeedBox.Find(m_Deed);
                    GalleonHold      hold = item.RootParent as GalleonHold;

                    // Veteran Rewards mods
                    if (box != null && m_Deed.IsChildOf(box) && item.IsChildOf(box) ||
                        (cox != null && cox.IsSecure && item.IsChildOf(cox)) ||
                        hold != null)
                    {
                        if (m_Deed.SetCommodity(item))
                        {
                            number = 1047030; // The commodity deed has been filled.
                        }
                        else
                        {
                            number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
                        }
                    }
                    else
                    {
                        number = 1080526; // That must be in your bank box or commodity deed box to use it.
                    }
                }
                else
                {
                    number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
                }

                from.SendLocalizedMessage(number);
            }
Ejemplo n.º 20
0
            public override void OnResponse(Network.NetState state, int index)
            {
                if (GuildMenu.BadLeader(m_Mobile, m_Guild))
                {
                    return;
                }

                if (index == 0)   //yes
                {
                    if (TurnOn)
                    {
                        Container bank = m_Mobile.FindBankNoCreate();

                        // Add guild leader as protected
                        if (!m_Guild.AddProtection(m_Mobile))
                        {
                            m_Mobile.SendAsciiMessage("You already have guild protection on another character.");
                            return;
                        }

                        if (bank != null && bank.ConsumeTotal(typeof(Gold), 10000))
                        {
                            m_Guild.LastProtectionPayment = DateTime.Now;
                        }
                        else
                        {
                            m_Guild.RemoveProtection(m_Mobile);
                            m_Mobile.SendAsciiMessage("You lack the required funds in your bank account to enable protection.");
                        }
                    }
                    else
                    {
                        m_Guild.ClearAllProtection();
                    }

                    m_Mobile.SendMenu(new GuildProtectionMenu(m_Mobile, m_Guild));
                }
                else //no
                {
                    m_Mobile.SendMenu(new GuildProtectionMenu(m_Mobile, m_Guild));
                }
            }
Ejemplo n.º 21
0
        public static int GetUniqueCurrencyBalance(Mobile from, Type currencyType)
        {
            int balance = 0;

            Container bankBox = from.FindBankNoCreate();

            Item[] currencyPiles;

            if (bankBox != null)
            {
                currencyPiles = bankBox.FindItemsByType(currencyType);

                for (int i = 0; i < currencyPiles.Length; ++i)
                {
                    balance += currencyPiles[i].Amount;
                }
            }

            return(balance);
        }
Ejemplo n.º 22
0
        public static int GetBalance(Mobile from, Type currencyType, out Item[] currency, out BankCheck[] checks)
        {
            int balance = 0;

            BankBox bank = from.FindBankNoCreate();

            if (bank != null)
            {
                currency = bank.FindItemsByType(currencyType, true).ToArray();
                checks   = bank.FindItemsByType <BankCheck>(true).Where(c => c.TypeOfCurrency == currencyType).ToArray();

                balance += currency.Sum(t => t.Amount);
                balance += checks.Sum(t => t.Worth);
            }
            else
            {
                currency = new Item[0];
                checks   = new BankCheck[0];
            }

            return(balance);
        }
Ejemplo n.º 23
0
        public void BeginStable(Mobile from)
        {
            if (this.Deleted || !from.CheckAlive())
                return;

            Container bank = from.FindBankNoCreate();

            if ((from.Backpack == null || from.Backpack.GetAmount(typeof(Gold)) < 30) && (bank == null || bank.GetAmount(typeof(Gold)) < 30))
            {
                this.SayTo(from, 1042556); // Thou dost not have enough gold, not even in thy bank account.
            }
            else
            {
                /* I charge 30 gold per pet for a real week's stable time.
                * I will withdraw it from thy bank account.
                * Which animal wouldst thou like to stable here?
                */
                from.SendLocalizedMessage(1042558);

                from.Target = new StableTarget(this);
            }
        }
Ejemplo n.º 24
0
        public static int GetBalance(Mobile from, out Item[] gold)
        {
            int balance = 0;

            Container bank = from.FindBankNoCreate();

            if (bank != null)
            {
                gold = bank.FindItemsByType(typeof(Gold));

                for (int i = 0; i < gold.Length; ++i)
                {
                    balance += gold[i].Amount;
                }
            }
            else
            {
                gold = new Item[0];
            }

            return(balance);
        }
Ejemplo n.º 25
0
            protected override void OnTarget(Mobile from, object s)
            {
                Container bank = from.FindBankNoCreate();

                if (s == from)
                {
                    from.SendMessage("You cannot room yourself.");
                }
                else if (s is PlayerMobile)
                {
                    from.SendMessage("That is not a Squire.");
                }
                else if (!(s is Squire))
                {
                    from.SendMessage("That is not a Squire.");
                }
                else
                {
                    BaseCreature squi = ( BaseCreature )s;

                    if (squi.Mounted == true)
                    {
                        from.SendMessage("Please dismount the Squire first, use [Dismount");
                    }
                    else if (squi.Summoned)
                    {
                        from.SendMessage("How did you summon a squire with magic?");
                    }
                    else if (!squi.Alive)
                    {
                        from.SendMessage("Please resurrect the Squire first.");
                    }
                    else
                    {
                        RoomCommandFunctions.Room(from, squi, true);
                    }
                }
            }
Ejemplo n.º 26
0
        public override bool AllowHousing(Mobile from, Point3D p)
        {
            if (this.m_Stone == null)
                return false;

            if (this.m_Stone.IsExpired)
                return true;

            if (this.m_Stone.Deed == null)
                return false;

            Container pack = from.Backpack;

            if (pack != null && this.ContainsDeed(pack))
                return true;

            BankBox bank = from.FindBankNoCreate();

            if (bank != null && this.ContainsDeed(bank))
                return true;

            return false;
        }
Ejemplo n.º 27
0
        public static int GetBalance(Mobile m, out Item[] gold, out Item[] checks)
        {
            long balance = 0;

            if (AccountGold.Enabled && m.Account != null)
            {
                balance = m.Account.GetTotalGold();

                if (balance > int.MaxValue)
                {
                    gold = checks = Array.Empty <Item>();
                    return(int.MaxValue);
                }
            }

            Container bank = m.FindBankNoCreate();

            if (bank != null)
            {
                gold   = bank.FindItemsByType(typeof(Gold));
                checks = bank.FindItemsByType(typeof(BankCheck));

                balance += gold.OfType <Gold>().Aggregate(0L, (c, t) => c + t.Amount);
                if (balance >= int.MaxValue)
                {
                    return(int.MaxValue);
                }

                balance += checks.OfType <BankCheck>().Aggregate(0L, (c, t) => c + t.Worth);
            }
            else
            {
                gold = checks = Array.Empty <Item>();
            }

            return(Math.Max(0, (int)Math.Min(int.MaxValue, balance)));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Moves all of the given Mobile's items to their bank.
        /// </summary>
        public virtual void PackToBank( Mobile m )
        {
            if( m == null || !m.Player )
                return;

            BankBox bank = m.FindBankNoCreate();
            Backpack pack = new Backpack();
            pack.Hue = 1157;

            List<Item> items = new List<Item>();

            for( int i = 0; i < m.Items.Count; i++ )
            {
                if( m.Items[i] is BankBox || (m.Backpack != null && m.Items[i].Serial == m.Backpack.Serial) )
                    continue;

                items.Add(m.Items[i]);
            }

            if( m.Backpack != null )
            {
                for( int i = 0; i < m.Backpack.Items.Count; i++ )
                    items.Add(m.Backpack.Items[i]);
            }

            items.ForEach(
                delegate( Item i )
                {
                    pack.AddItem(i);
                });
            items.Clear();

            if( bank == null )
                pack.MoveToWorld(m.Location, m.Map);
            else
                bank.AddItem(pack);
        }
Ejemplo n.º 29
0
        public void BeginStable(Mobile from)
        {
            if (Deleted || !from.CheckAlive())
            {
                return;
            }

            Container bank = from.FindBankNoCreate();

            if ((from.Backpack == null || from.Backpack.GetAmount(typeof(Gold)) < 500) && (bank == null || bank.GetAmount(typeof(Gold)) < 500))
            {
                SayTo(from, "But who will pay for his stay?");                   // Thou dost not have enough gold, not even in thy bank account.
            }
            else
            {
                /* I charge 30 gold per pet for a real week's stable time.
                 * I will withdraw it from thy bank account.
                 * Which animal wouldst thou like to stable here?
                 */
                SayTo(from, "We charge 500 gold per day for a room at our fine establishment, who wishes to stay here?");

                from.Target = new StableTarget(this);
            }
        }
Ejemplo n.º 30
0
		public static int GetBalance( Mobile from, out Item[] gold, out Item[] checks )
		{
			int balance = 0;

			Container bank = from.FindBankNoCreate();

			if ( bank != null )
			{
				gold = bank.FindItemsByType( typeof( Gold ) );
				checks = bank.FindItemsByType( typeof( BankCheck ) );

				for ( int i = 0; i < gold.Length; ++i )
					balance += gold[i].Amount;

				for ( int i = 0; i < checks.Length; ++i )
					balance += ((BankCheck)checks[i]).Worth;
			}
			else
			{
				gold = checks = new Item[0];
			}

			return balance;
		}
Ejemplo n.º 31
0
        //this checks for money, and withdraws it if necessary
        public bool CheckCost(Mobile from, bool withdraw)
        {
            if (CostToPlay == 0)
            {
                return(true);
            }

            Gold gold = (Gold)from.Backpack.FindItemByType(typeof(Gold));

            if (gold == null || gold.Amount < CostToPlay)
            {
                Container bankbox = from.FindBankNoCreate();

                if (bankbox != null)
                {
                    gold = (Gold)bankbox.FindItemByType(typeof(Gold));

                    if (gold != null && gold.Amount >= CostToPlay)
                    {
                        if (withdraw)
                        {
                            bankbox.ConsumeTotal(typeof(Gold), CostToPlay);
                        }
                        return(true);
                    }
                }
                return(false);
            }

            if (withdraw)
            {
                from.Backpack.ConsumeTotal(typeof(Gold), CostToPlay);
            }

            return(true);
        }
Ejemplo n.º 32
0
			protected override void OnTarget( Mobile from, object targeted )
			{
				if ( m_Deed.Deleted )
					return;

				int number;

				if ( m_Deed.Commodity != null )
				{
					number = 1047028; // The commodity deed has already been filled.
				}
				else if ( targeted is Item )
				{
					BankBox box = from.FindBankNoCreate();
                    string XferResource = "...";
                    int XferAmount = 0;
                    int r = 0;

                    if (box != null && m_Deed.IsChildOf(box) && ((Item)targeted).IsChildOf(box))
                    {
                        // RESOURCE EDIT
                        if (targeted is BaseIngot) // || targeted is BaseBoards || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
                        {
                            from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
                            number = 1047027;
                            m_Deed.Delete();

                            BaseIngot youringots = (BaseIngot)targeted;
                            string s_resource = Convert.ToString(youringots.Resource);
                            XferAmount = youringots.Amount;
                            switch (s_resource)
                            {
                                case "Iron": r = 1; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "DullCopper": r = 2; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "ShadowIron": r = 3; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "Copper": r = 4; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "Bronze": r = 5; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "Gold": r = 6; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "Silver": r = 7; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "Agapite": r = 8; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "Verite": r = 9; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "Valorite": r = 10; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "Jade": r = 11; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "Moonstone": r = 12; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                case "Sunstone": r = 13; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                                //case "": r = 13; box.DropItem(new YaksCommodityDeed(XferAmount, r)); youringots.Delete(); break;
                            }
                        }
                        else if (targeted is BaseLeather) // || targeted is BaseBoards || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
                        {
                            from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
                            number = 1047027;
                            m_Deed.Delete();

                            BaseLeather youritem = (BaseLeather)targeted;
                            string s_resource = Convert.ToString(youritem.Resource);
                            XferAmount = youritem.Amount;
                            switch (s_resource)
                            {
                                case "RegularLeather": r = 101; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "SpinedLeather": r = 102; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "HornedLeather": r = 103; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "BarbedLeather": r = 104; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "DaemonLeather": r = 105; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "DragonLeather": r = 106; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                            }
                        }
                        else if (targeted is BaseScales) // || targeted is BaseBoards || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
                        {
                            from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
                            number = 1047027;
                            m_Deed.Delete();

                            BaseScales youritem = (BaseScales)targeted;
                            string s_resource = Convert.ToString(youritem.Resource);
                            XferAmount = youritem.Amount;
                            switch (s_resource)
                            {
                                case "RedScales": r = 201; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "YellowScales": r = 202; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "BlackScales": r = 203; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "GreenScales": r = 204; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "WhiteScales": r = 205; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "BlueScales": r = 206; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                //case "IceScales": r = 207; box.DropItem(new YaksCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            }
                        }
                        else if (targeted is BaseLog)// || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
                        {
                            from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
                            number = 1047027;
                            m_Deed.Delete();

                            BaseLog youritem = (BaseLog)targeted;
                            string s_resource = Convert.ToString(youritem.Resource);
                            XferAmount = youritem.Amount;
                            switch (s_resource)
                            {
                                case "Regular": r = 301; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Oak": r = 302; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Ash": r = 303; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Yew": r = 304; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Heartwood": r = 305; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Bloodwood": r = 306; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Frostwood": r = 307; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Pine": r = 308; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Cedar": r = 309; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Cherry": r = 310; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Mahogany": r = 311; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            }
                        }
                        else if (targeted is BaseBoards)// || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
                        {
                            from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
                            number = 1047027;
                            m_Deed.Delete();

                            BaseBoards youritem = (BaseBoards)targeted;
                            string s_resource = Convert.ToString(youritem.Resource);
                            XferAmount = youritem.Amount;
                            switch (s_resource)
                            {
                                case "Regular": r = 401; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Oak": r = 402; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Ash": r = 03; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Yew": r = 404; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Heartwood": r = 405; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Bloodwood": r = 406; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Frostwood": r = 407; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Pine": r = 408; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Cedar": r = 409; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Cherry": r = 410; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
                                case "Mahogany": r = 411; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;

                            }
                        }
                        else
                        {
                            if (m_Deed.SetCommodity((Item)targeted))
                            {
                                number = 1047030; // The commodity deed has been filled.
                            }
                            else
                            {
                                number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
                            }
                        }
					}
					else
					{
						number = 1047026; // That must be in your bank box to use it.
					}
				}
				else
				{
					number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
				}

				from.SendLocalizedMessage( number );
			}
Ejemplo n.º 33
0
        public override void OnDoubleClick(Mobile from)
        {
            BankBox box = from.FindBankNoCreate();

            if (box != null && this.IsChildOf(box))
            {
                this.Delete();

                int deposited = 0;

                int toAdd = this.m_Worth;

                Gold gold;

                while (toAdd > 60000)
                {
                    gold = new Gold(60000);

                    if (box.TryDropItem(from, gold, false))
                    {
                        toAdd -= 60000;
                        deposited += 60000;
                    }
                    else
                    {
                        gold.Delete();

                        from.AddToBackpack(new BankCheck(toAdd));
                        toAdd = 0;

                        break;
                    }
                }

                if (toAdd > 0)
                {
                    gold = new Gold(toAdd);

                    if (box.TryDropItem(from, gold, false))
                    {
                        deposited += toAdd;
                    }
                    else
                    {
                        gold.Delete();

                        from.AddToBackpack(new BankCheck(toAdd));
                    }
                }

                // Gold was deposited in your account:
                from.SendLocalizedMessage(1042672, true, " " + deposited.ToString());

                PlayerMobile pm = from as PlayerMobile;

                if (pm != null)
                {
                    QuestSystem qs = pm.Quest;

                    if (qs is Necro.DarkTidesQuest)
                    {
                        QuestObjective obj = qs.FindObjective(typeof(Necro.CashBankCheckObjective));

                        if (obj != null && !obj.Completed)
                            obj.Complete();
                    }

                    if (qs is Haven.UzeraanTurmoilQuest)
                    {
                        QuestObjective obj = qs.FindObjective(typeof(Haven.CashBankCheckObjective));

                        if (obj != null && !obj.Completed)
                            obj.Complete();
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage(1047026); // That must be in your bank box to use it.
            }
        }
        public override void OnDoubleClick(Mobile from)
        {
            BankBox box = from.FindBankNoCreate();
            if (box != null && IsChildOf(box))
            {
                from.SendMessage(88, "Your goods are returned to you.");
                switch (m_Resource)
                {
                    case 0: break;
                    case 1: box.DropItem(new IronIngot(m_Amount)); this.Delete(); break;
                    case 2: box.DropItem(new DullCopperIngot(m_Amount)); this.Delete(); break;
                    case 3: box.DropItem(new ShadowIronIngot(m_Amount)); this.Delete(); break;
                    case 4: box.DropItem(new CopperIngot(m_Amount)); this.Delete(); break;
                    case 5: box.DropItem(new BronzeIngot(m_Amount)); this.Delete(); break;
                    case 6: box.DropItem(new GoldIngot(m_Amount)); this.Delete(); break;
                    case 7: box.DropItem(new SilverIngot(m_Amount)); this.Delete(); break;
                    case 8: box.DropItem(new AgapiteIngot(m_Amount)); this.Delete(); break;
                    case 9: box.DropItem(new VeriteIngot(m_Amount)); this.Delete(); break;
                    case 10: box.DropItem(new ValoriteIngot(m_Amount)); this.Delete(); break;
                    case 11: box.DropItem(new JadeIngot(m_Amount)); this.Delete(); break;
                    case 12: box.DropItem(new MoonstoneIngot(m_Amount)); this.Delete(); break;
                    case 13: box.DropItem(new SunstoneIngot(m_Amount)); this.Delete(); break;
                    //case 13: box.DropItem(new Ingot(m_Amount)); this.Delete(); break;
                    
                    
                    case 101: box.DropItem(new Leather(m_Amount)); this.Delete(); break;
                    case 102: box.DropItem(new SpinedLeather(m_Amount)); this.Delete(); break;
                    case 103: box.DropItem(new HornedLeather(m_Amount)); this.Delete(); break;
                    case 104: box.DropItem(new BarbedLeather(m_Amount)); this.Delete(); break;
                    case 105: box.DropItem(new DaemonLeather(m_Amount)); this.Delete(); break;
                    case 106: box.DropItem(new DragonLeather(m_Amount)); this.Delete(); break;
                    //case 107: box.DropItem(new Leather(m_Amount)); this.Delete(); break;

                    case 201: box.DropItem(new RedScales(m_Amount)); this.Delete(); break;
                    case 202: box.DropItem(new YellowScales(m_Amount)); this.Delete(); break;
                    case 203: box.DropItem(new BlackScales(m_Amount)); this.Delete(); break;
                    case 204: box.DropItem(new GreenScales(m_Amount)); this.Delete(); break;
                    case 205: box.DropItem(new WhiteScales(m_Amount)); this.Delete(); break;
                    case 206: box.DropItem(new BlueScales(m_Amount)); this.Delete(); break;
                    //case 207: box.DropItem(new Scales(m_Amount)); this.Delete(); break;

                    case 301: box.DropItem(new Log(m_Amount)); this.Delete(); break;
                    case 302: box.DropItem(new OakLog(m_Amount)); this.Delete(); break;
                    case 303: box.DropItem(new AshLog(m_Amount)); this.Delete(); break;
                    case 304: box.DropItem(new YewLog(m_Amount)); this.Delete(); break;
                    case 305: box.DropItem(new HeartwoodLog(m_Amount)); this.Delete(); break;
                    case 306: box.DropItem(new BloodwoodLog(m_Amount)); this.Delete(); break;
                    case 307: box.DropItem(new FrostwoodLog(m_Amount)); this.Delete(); break;
                    case 308: box.DropItem(new PineLog(m_Amount)); this.Delete(); break;
                    case 309: box.DropItem(new CedarLog(m_Amount)); this.Delete(); break;
                    case 310: box.DropItem(new CherryLog(m_Amount)); this.Delete(); break;
                    case 311: box.DropItem(new MahoganyLog(m_Amount)); this.Delete(); break;

                    case 401: box.DropItem(new Board(m_Amount)); this.Delete(); break;
                    case 402: box.DropItem(new OakBoard(m_Amount)); this.Delete(); break;
                    case 403: box.DropItem(new AshBoard(m_Amount)); this.Delete(); break;
                    case 404: box.DropItem(new YewBoard(m_Amount)); this.Delete(); break;
                    case 405: box.DropItem(new HeartwoodBoard(m_Amount)); this.Delete(); break;
                    case 406: box.DropItem(new BloodwoodBoard(m_Amount)); this.Delete(); break;
                    case 407: box.DropItem(new FrostwoodBoard(m_Amount)); this.Delete(); break;
                    case 408: box.DropItem(new PineBoard(m_Amount)); this.Delete(); break;
                    case 409: box.DropItem(new CedarBoard(m_Amount)); this.Delete(); break;
                    case 410: box.DropItem(new CherryBoard(m_Amount)); this.Delete(); break;
                    case 411: box.DropItem(new MahoganyBoard(m_Amount)); this.Delete(); break;


                }
            }
            else
            {
                from.SendMessage(88, "The deed only works in your bankbox.");
            }
        }
Ejemplo n.º 35
0
        public static bool Deposit(Mobile from, int amount, bool message = false)
        {
            // If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
            if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount))
            {
                if (message)
                {
                    from.SendLocalizedMessage(1042763, amount.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US"))); // ~1_AMOUNT~ gold was deposited in your account.
                }
                return(true);
            }

            var box = from.Player ? from.BankBox : from.FindBankNoCreate();

            if (box == null)
            {
                return(false);
            }

            var items = new List <Item>();

            while (amount > 0)
            {
                Item item;
                if (amount < 5000)
                {
                    item   = new Gold(amount);
                    amount = 0;
                }
                else if (amount <= 1000000)
                {
                    item   = new BankCheck(amount);
                    amount = 0;
                }
                else
                {
                    item    = new BankCheck(1000000);
                    amount -= 1000000;
                }

                if (box.TryDropItem(from, item, false))
                {
                    items.Add(item);
                }
                else
                {
                    item.Delete();
                    foreach (var curItem in items)
                    {
                        curItem.Delete();
                    }

                    return(false);
                }
            }

            if (message)
            {
                from.SendLocalizedMessage(1042763, amount.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US"))); // ~1_AMOUNT~ gold was deposited in your account.
            }
            return(true);
        }
Ejemplo n.º 36
0
        public override bool OnBuyItems(Mobile buyer, List <BuyItemResponse> list)
        {
            if (!Trading || !IsActiveSeller || CashType == null || !CashType.IsNotNull)
            {
                return(false);
            }

            if (!buyer.CheckAlive())
            {
                return(false);
            }

            if (!CheckVendorAccess(buyer))
            {
                Say("I can't serve you! Company policy.");
                //Say(501522); // I shall not treat with scum like thee!
                return(false);
            }

            UpdateBuyInfo();

            var info         = GetSellInfo();
            var totalCost    = 0;
            var validBuy     = new List <BuyItemResponse>(list.Count);
            var fromBank     = false;
            var fullPurchase = true;
            var controlSlots = buyer.FollowersMax - buyer.Followers;

            foreach (var buy in list)
            {
                var ser    = buy.Serial;
                var amount = buy.Amount;

                if (ser.IsItem)
                {
                    var item = World.FindItem(ser);

                    if (item == null)
                    {
                        continue;
                    }

                    var gbi = LookupDisplayObject(item);

                    if (gbi != null)
                    {
                        ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
                    }
                    else if (item != BuyPack && item.IsChildOf(BuyPack))
                    {
                        if (amount > item.Amount)
                        {
                            amount = item.Amount;
                        }

                        if (amount <= 0)
                        {
                            continue;
                        }

                        foreach (var ssi in info.Where(ssi => ssi.IsSellable(item) && ssi.IsResellable(item)))
                        {
                            totalCost += ssi.GetBuyPriceFor(item) * amount;
                            validBuy.Add(buy);
                            break;
                        }
                    }
                }
                else if (ser.IsMobile)
                {
                    var mob = World.FindMobile(ser);

                    if (mob == null)
                    {
                        continue;
                    }

                    var gbi = LookupDisplayObject(mob);

                    if (gbi != null)
                    {
                        ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
                    }
                }
            }

            if (fullPurchase && validBuy.Count == 0)
            {
                // Thou hast bought nothing!
                SayTo(buyer, 500190);
            }
            else if (validBuy.Count == 0)
            {
                // Your order cannot be fulfilled, please try again.
                SayTo(buyer, 500187);
            }

            if (validBuy.Count == 0)
            {
                return(false);
            }

            var bought = buyer.AccessLevel >= AccessLevel.GameMaster;

            if (!bought && CashType.TypeEquals <ObjectProperty>())
            {
                var cashSource = GetCashObject(buyer) ?? buyer;

                bought = CashProperty.Consume(cashSource, totalCost);

                if (!bought)
                {
                    // Begging thy pardon, but thou cant afford that.
                    SayTo(buyer, 500192);
                    return(false);
                }

                SayTo(buyer, "{0:#,0} {1} has been deducted from your total.", totalCost, CashName.GetString(buyer));
            }

            var isGold = CashType.TypeEquals <Gold>();

            var cont = buyer.Backpack;

            if (!bought && cont != null && isGold)
            {
                VitaNexCore.TryCatch(
                    () =>
                {
                    var lt = ScriptCompiler.FindTypeByName("GoldLedger") ?? Type.GetType("GoldLedger");

                    if (lt == null)
                    {
                        return;
                    }

                    var ledger = cont.FindItemByType(lt);

                    if (ledger == null || ledger.Deleted)
                    {
                        return;
                    }

                    var lp = lt.GetProperty("Gold");

                    if (lp == null)
                    {
                        return;
                    }

                    if (lp.PropertyType.IsEqual <Int64>())
                    {
                        var lg = (long)lp.GetValue(ledger, null);

                        if (lg < totalCost)
                        {
                            return;
                        }

                        lp.SetValue(ledger, lg - totalCost, null);
                        bought = true;
                    }
                    else if (lp.PropertyType.IsEqual <Int32>())
                    {
                        var lg = (int)lp.GetValue(ledger, null);

                        if (lg < totalCost)
                        {
                            return;
                        }

                        lp.SetValue(ledger, lg - totalCost, null);
                        bought = true;
                    }

                    if (bought)
                    {
                        buyer.SendMessage(2125, "{0:#,0} gold has been withdrawn from your ledger.", totalCost);
                    }
                });
            }

            if (!bought)
            {
                ConsumeCurrency(buyer, ref totalCost, ref bought);
            }

            if (!bought && cont != null)
            {
                if (cont.ConsumeTotal(CashType, totalCost))
                {
                    bought = true;
                }
            }

            if (!bought && isGold && Banker.Withdraw(buyer, totalCost))
            {
                bought   = true;
                fromBank = true;
            }

            if (!bought && !isGold)
            {
                cont = buyer.FindBankNoCreate();

                if (cont != null && cont.ConsumeTotal(CashType, totalCost))
                {
                    bought   = true;
                    fromBank = true;
                }
            }

            if (!bought)
            {
                // Begging thy pardon, but thou cant afford that.
                SayTo(buyer, 500192);
                return(false);
            }

            buyer.PlaySound(0x32);

            cont = buyer.Backpack ?? buyer.BankBox;

            foreach (var buy in validBuy)
            {
                var ser    = buy.Serial;
                var amount = buy.Amount;

                if (amount < 1)
                {
                    continue;
                }

                if (ser.IsItem)
                {
                    var item = World.FindItem(ser);

                    if (item == null)
                    {
                        continue;
                    }

                    var gbi = LookupDisplayObject(item);

                    if (gbi != null)
                    {
                        ProcessValidPurchase(amount, gbi, buyer, cont);
                    }
                    else
                    {
                        if (amount > item.Amount)
                        {
                            amount = item.Amount;
                        }

                        if (info.Where(ssi => ssi.IsSellable(item)).Any(ssi => ssi.IsResellable(item)))
                        {
                            Item buyItem;

                            if (amount >= item.Amount)
                            {
                                buyItem = item;
                            }
                            else
                            {
                                buyItem = LiftItemDupe(item, item.Amount - amount) ?? item;
                            }

                            if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
                            {
                                buyItem.MoveToWorld(buyer.Location, buyer.Map);
                            }
                        }
                    }
                }
                else if (ser.IsMobile)
                {
                    var mob = World.FindMobile(ser);

                    if (mob == null)
                    {
                        continue;
                    }

                    var gbi = LookupDisplayObject(mob);

                    if (gbi != null)
                    {
                        ProcessValidPurchase(amount, gbi, buyer, cont);
                    }
                }
            }

            if (fullPurchase)
            {
                if (buyer.AccessLevel >= AccessLevel.GameMaster)
                {
                    SayTo(buyer, true, "I would not presume to charge thee anything.  Here are the goods you requested.");
                }
                else if (fromBank)
                {
                    SayTo(
                        buyer,
                        true,
                        "The total of thy purchase is {0:#,0} {1}, which has been withdrawn from your bank account.  My thanks for the patronage.",
                        totalCost,
                        CashName.GetString(buyer));
                }
                else
                {
                    SayTo(
                        buyer,
                        true,
                        "The total of thy purchase is {0:#,0} {1}.  My thanks for the patronage.",
                        totalCost,
                        CashName.GetString(buyer));
                }
            }
            else
            {
                if (buyer.AccessLevel >= AccessLevel.GameMaster)
                {
                    SayTo(
                        buyer,
                        true,
                        "I would not presume to charge thee anything.  Unfortunately, I could not sell you all the goods you requested.");
                }
                else if (fromBank)
                {
                    SayTo(
                        buyer,
                        true,
                        "The total of thy purchase is {0:#,0} {1}, which has been withdrawn from your bank account.  My thanks for the patronage.  Unfortunately, I could not sell you all the goods you requested.",
                        totalCost,
                        CashName.GetString(buyer));
                }
                else
                {
                    SayTo(
                        buyer,
                        true,
                        "The total of thy purchase is {0:#,0} {1}.  My thanks for the patronage.  Unfortunately, I could not sell you all the goods you requested.",
                        totalCost,
                        CashName.GetString(buyer));
                }
            }

            return(true);
        }
Ejemplo n.º 37
0
			protected override void OnTarget( Mobile from, object targeted )
			{
				if ( m_Deed.Deleted )
					return;

				int number;

				if ( m_Deed.Commodity != null )
				{
					number = 1047028; // The commodity deed has already been filled.
				}
				else if ( targeted is Item )
				{
					BankBox box = from.FindBankNoCreate();
					CommodityDeedBox cox = CommodityDeedBox.Find( m_Deed );

					// Veteran Rewards mods
					if ( box != null && m_Deed.IsChildOf( box ) && ((Item)targeted).IsChildOf( box ) || 
						cox != null && cox.IsSecure && ((Item)targeted).IsChildOf( cox ) )
					{
						if ( m_Deed.SetCommodity( (Item) targeted ) )
						{
							m_Deed.Hue = 0x592;
							number = 1047030; // The commodity deed has been filled.
						}
						else
						{
							number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
						}
					}
					else
					{
						if( Core.ML )
						{
							number = 1080526; // That must be in your bank box or commodity deed box to use it.
						}
						else
						{
							number = 1047026; // That must be in your bank box to use it.
						}
					}
				}
				else
				{
					number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
				}

				from.SendLocalizedMessage( number );
			}
Ejemplo n.º 38
0
		public static bool Deposit(Mobile from, Type currencyType, int amount)
		{
			BankBox box = from.FindBankNoCreate();

			if (box != null)
			{
				var items = new List<Item>();

				while (amount > 0)
				{
					Item item;

					if (amount < 5000)
					{
						item = currencyType.CreateInstanceSafe<Item>();

						item.Stackable = true;
						item.Amount = amount;

						amount = 0;
					}
					else if (amount <= 1000000)
					{
						item = new BankCheck(amount);
						amount = 0;
					}
					else
					{
						item = new BankCheck(1000000);
						amount -= 1000000;
					}

				    BankCheck check = item as BankCheck;

				    if (currencyType.Equals(typeof(DonationCoin)) && item is BankCheck)
				    {
				        check.IsDonation = true;
				        check.Hue = 1153;
				    }
					if (box.TryDropItem(from, item, false))
					{
						items.Add(item);
					}
					else
					{
						item.Delete();

						foreach (Item curItem in items)
						{
							curItem.Delete();
						}

						return false;
					}
				}

				return true;
			}

			return false;
		}
Ejemplo n.º 39
0
        public static bool Deposit(Mobile from, int amount, bool message = false)
        {
            // If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
			if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount))
            {
                if (message)
                    from.SendLocalizedMessage(1042763, amount.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US"))); // ~1_AMOUNT~ gold was deposited in your account.

                return true;
            }

            var box = from.FindBankNoCreate();

            if (box == null)
            {
                return false;
            }

            var items = new List<Item>();

            while (amount > 0)
            {
                Item item;
                if (amount < 5000)
                {
                    item = new Gold(amount);
                    amount = 0;
                }
                else if (amount <= 1000000)
                {
                    item = new BankCheck(amount);
                    amount = 0;
                }
                else
                {
                    item = new BankCheck(1000000);
                    amount -= 1000000;
                }

                if (box.TryDropItem(from, item, false))
                {
                    items.Add(item);
                }
                else
                {
                    item.Delete();
                    foreach (var curItem in items)
                    {
                        curItem.Delete();
                    }

                    return false;
                }
            }

            return true;
        }
Ejemplo n.º 40
0
            protected override void OnTarget( Mobile from, object targeted )
            {
                if ( m_Deed.Deleted )
                    return;

                int number;

                if ( m_Deed.Commodity != null )
                {
                    number = 1047028; // The commodity deed has already been filled.
                }
                else if ( targeted is Item )
                {
                    BankBox box = from.FindBankNoCreate();

                    if ( box != null && m_Deed.IsChildOf( box ) && ((Item)targeted).IsChildOf( box ) )
                    {
                        if ( m_Deed.SetCommodity( (Item) targeted ) )
                        {
                            number = 1047030; // The commodity deed has been filled.
                        }
                        else
                        {
                            number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
                        }
                    }
                    else
                    {
                        number = 1047026; // That must be in your bank box to use it.
                    }
                }
                else
                {
                    number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
                }

                from.SendLocalizedMessage( number );
            }
Ejemplo n.º 41
0
        public override void OnDoubleClick( Mobile from )
        {
            int number;

            BankBox box = from.FindBankNoCreate();

            if ( m_Commodity != null )
            {
                if ( box != null && IsChildOf( box ) )
                {
                    number = 1047031; // The commodity has been redeemed.

                    box.DropItem( m_Commodity );

                    m_Commodity = null;
                    Delete();
                }
                else
                {
                    number = 1047024; // To claim the resources ....
                }
            }
            else if ( box == null || !IsChildOf( box ) )
            {
                number = 1047026; // That must be in your bank box to use it.
            }
            else
            {
                number = 1047029; // Target the commodity to fill this deed with.

                from.Target = new InternalTarget( this );
            }

            from.SendLocalizedMessage( number );
        }
Ejemplo n.º 42
0
		public override void OnDoubleClick( Mobile from )
		{
			int number;

			BankBox box = from.FindBankNoCreate();

			if( (box == null || !IsChildOf( box )) )
			{
				if( Core.ML )
				{
					number = 1080526; // That must be in your bank box or commodity deed box to use it.
				}
				else
				{
					number = 1047026; // That must be in your bank box to use it.
				}
			}
			else
			{
				number = 1047029; // Target the commodity to fill this deed with.

				from.Target = new InternalTarget( this );
			}

			from.SendLocalizedMessage( number );
		}
Ejemplo n.º 43
0
        public void Purchase_Callback(Mobile from, bool okay, object state)
        {
            if (this.Deleted || this.m_State != HouseRaffleState.Active || !from.CheckAlive() || this.HasEntered(from) || this.IsAtIPLimit(from))
                return;

            Account acc = from.Account as Account;

            if (acc == null)
                return;

            if (okay)
            {
                Container bank = from.FindBankNoCreate();

                if (this.m_TicketPrice == 0 || (from.Backpack != null && from.Backpack.ConsumeTotal(typeof(Gold), this.m_TicketPrice)) || (bank != null && bank.ConsumeTotal(typeof(Gold), this.m_TicketPrice)))
                {
                    this.m_Entries.Add(new RaffleEntry(from));

                    from.SendMessage(MessageHue, "You have successfully entered the plot's raffle.");
                }
                else
                {
                    from.SendMessage(MessageHue, "You do not have the {0} required to enter the raffle.", this.FormatPrice());
                }
            }
            else
            {
                from.SendMessage(MessageHue, "You have chosen not to enter the raffle.");
            }
        }
Ejemplo n.º 44
0
        public static int DepositUpTo(Mobile from, int amount)
        {
            // If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
			if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount))
            {
                return amount;
            }

            var box = from.FindBankNoCreate();

            if (box == null)
            {
                return 0;
            }

            var amountLeft = amount;
            while (amountLeft > 0)
            {
                Item item;
                int amountGiven;

                if (amountLeft < 5000)
                {
                    item = new Gold(amountLeft);
                    amountGiven = amountLeft;
                }
                else if (amountLeft <= 1000000)
                {
                    item = new BankCheck(amountLeft);
                    amountGiven = amountLeft;
                }
                else
                {
                    item = new BankCheck(1000000);
                    amountGiven = 1000000;
                }

                if (box.TryDropItem(from, item, false))
                {
                    amountLeft -= amountGiven;
                }
                else
                {
                    item.Delete();
                    break;
                }
            }

            return amount - amountLeft;
        }
Ejemplo n.º 45
0
		public void BeginStable( Mobile from )
		{
			if ( Deleted || !from.CheckAlive() )
				return;

			Container bank = from.FindBankNoCreate();

			if ( ( from.Backpack == null || from.Backpack.GetAmount( typeof( Gold ) ) < 30 ) && ( bank == null || bank.GetAmount( typeof( Gold ) ) < 30 ) )
			{
				SayTo( from, 1042556 ); // Thou dost not have enough gold, not even in thy bank account.
			}
			else
			{
				/* I charge 30 gold per pet for a real week's stable time.
				 * I will withdraw it from thy bank account.
				 * Which animal wouldst thou like to stable here?
				 */
				from.SendLocalizedMessage(1042558);

				from.Target = new StableTarget( this );
			}
		}
Ejemplo n.º 46
0
        public void EndStable(Mobile from, BaseCreature pet)
        {
            if (Deleted || !from.CheckAlive())
            {
                return;
            }

            if (pet.Body.IsHuman)
            {
                SayTo(from, 502672); // HA HA HA! Sorry, I am not an inn.
            }
            else if (!pet.Controlled)
            {
                SayTo(from, 1048053); // You can't stable that!
            }
            else if (pet.ControlMaster != from)
            {
                SayTo(from, 1042562); // You do not own that pet!
            }
            else if (pet.Summoned || pet.AI == AIType.AI_Familiar)
            {
                SayTo(from, 502673); // I can not stable summoned creatures.
            }
            else if ((pet is PackLlama || pet is PackHorse) && pet.Backpack != null && pet.Backpack.Items.Count > 0)
            {
                SayTo(from, 1042563); // You need to unload your pet.
            }
            else if (pet.Combatant != null && pet.InRange(pet.Combatant, 12) && pet.Map == pet.Combatant.Map)
            {
                SayTo(from, 1042564); // I'm sorry.  Your pet seems to be busy.
            }
            else
            {
                var       amount = pet.Str * 2;
                Container bank   = from.FindBankNoCreate();

                SayTo(from, true, $"I charge {amount} to take care of that {pet.Name}.");

                if (@from.Backpack != null && @from.Backpack.ConsumeTotal(typeof(Gold), amount) ||
                    bank != null && bank.ConsumeTotal(typeof(Gold), amount))
                {
                    pet.ControlTarget = null;
                    pet.ControlOrder  = OrderType.Stay;
                    pet.Internalize();

                    pet.SetControlMaster(null);
                    pet.SummonMaster = null;

                    pet.IsStabled = true;
                    pet.StabledBy = from;

                    var petClaimTicket = new PetClaimTicket {
                        Name = $"Pet claim ticket - Name: {pet.Name}"
                    };
                    petClaimTicket.Stabled = pet;

                    var cont = from.Backpack;
                    if (cont == null || !cont.TryDropItem(from, petClaimTicket, false))
                    {
                        petClaimTicket.MoveToWorld(from.Location, from.Map);
                    }

                    SayTo(from, true, $"Keep this ticket and give it to me when you want {pet.Name} back.");
                }
                else
                {
                    SayTo(from, 502677); // But thou hast not the funds in thy bank account!
                }
            }
        }
Ejemplo n.º 47
0
        public bool IsUsableBy(Mobile from)
        {
            Item root = RootParent as Item;

            return(IsChildOf(from.Backpack) || IsChildOf(from.FindBankNoCreate()) || IsLockedDown && IsAccessibleTo(from) || root != null && root.IsSecure && root.IsAccessibleTo(from));
        }
Ejemplo n.º 48
0
		public static int GetBalance(Mobile from, Type currencyType, out Item[] currency, out BankCheck[] checks)
		{
			int balance = 0;

			BankBox bank = from.FindBankNoCreate();

			if (bank != null)
			{
				currency = bank.FindItemsByType(currencyType, true).ToArray();
				checks = bank.FindItemsByType<BankCheck>(true).Where(c => c.TypeOfCurrency == currencyType).ToArray();

				balance += currency.Sum(t => t.Amount);
				balance += checks.Sum(t => t.Worth);
			}
			else
			{
				currency = new Item[0];
				checks = new BankCheck[0];
			}

			return balance;
		}
Ejemplo n.º 49
0
		public override void OnDoubleClick( Mobile from )
		{
			int number;

			BankBox box = from.FindBankNoCreate();
			CommodityDeedBox cox = CommodityDeedBox.Find( this );
			
			// Veteran Rewards mods
			if ( m_Commodity != null )
			{
				if ( box != null && IsChildOf( box ) )
				{
					number = 1047031; // The commodity has been redeemed.

					box.DropItem( m_Commodity );

					m_Commodity = null;
					Delete();
				}
				else if ( cox != null )
				{
					if ( cox.IsSecure )
					{
						number = 1047031; // The commodity has been redeemed.

						cox.DropItem( m_Commodity );

						m_Commodity = null;
						Delete();
					}
					else
						number = 1080525; // The commodity deed box must be secured before you can use it.
				}
				else
				{
					if( Core.ML )
					{
						number = 1080526; // That must be in your bank box or commodity deed box to use it.
					}
					else
					{
						number = 1047024; // To claim the resources ....
					}
				}
			}
			else if ( cox != null && !cox.IsSecure )
			{
				number = 1080525; // The commodity deed box must be secured before you can use it.
			}
			else if ( ( box == null || !IsChildOf( box ) ) && cox == null )
			{
				if( Core.ML )
				{
					number = 1080526; // That must be in your bank box or commodity deed box to use it.
				}
				else
				{
					number = 1047026; // That must be in your bank box to use it.
				}
			}
			else
			{
				number = 1047029; // Target the commodity to fill this deed with.

				from.Target = new InternalTarget( this );
			}

			from.SendLocalizedMessage( number );
		}
Ejemplo n.º 50
0
        public static bool BuyItem(Mobile buyer, MarketEntry entry)
        {
            if (buyer == null || !buyer.Alive)
            {
                buyer.SendMessage("You cannot purchase a market order while knocked out.");
            }
            else if (buyer == entry.Seller)
            {
                buyer.SendMessage("You cannot purchase something from yourself.");
            }
            else
            {
                IEntity entity = World.FindEntity(entry.ObjectSerial);

                if (entity == null || IsSold(entry))
                {
                    buyer.SendMessage("The order has expired.");
                }
                else
                {
                    Type[]    coinTypes      = new Type[] { Curr.typeofCopper, Curr.typeofSilver, Curr.typeofGold };
                    int[]     compressedCost = Curr.Compress(entry.Cost, 0, 0);
                    Container cont           = buyer.FindBankNoCreate();

                    if (cont != null && cont.ConsumeTotal(coinTypes, compressedCost) == -1)
                    {
                        if (entity is Item)
                        {
                            Item item = (Item)entity;
                            cont = buyer.Backpack;

                            if (cont != null && !cont.TryDropItem(buyer, item, false))
                            {
                                item.MoveToWorld(buyer.Location, buyer.Map);
                            }

                            CloseOrder(entry);

                            if (buyer.HasGump(typeof(MarketGump)))
                            {
                                buyer.CloseGump(typeof(MarketGump));
                                buyer.SendGump(new MarketGump(entry.Category, 0));
                            }

                            return(true);
                        }
                        else if (entity is Mobile)
                        {
                            Mobile mob = (Mobile)entity;
                            mob.Direction = (Direction)Utility.Random(8);
                            mob.MoveToWorld(buyer.Location, buyer.Map);
                            mob.PlaySound(mob.GetIdleSound());

                            if (mob is BaseCreature)
                            {
                                ((BaseCreature)mob).SetControlMaster(buyer);
                            }

                            CloseOrder(entry);

                            if (buyer.HasGump(typeof(MarketGump)))
                            {
                                buyer.CloseGump(typeof(MarketGump));
                                buyer.SendGump(new MarketGump(entry.Category, 0));
                            }

                            return(true);
                        }
                    }
                    else
                    {
                        buyer.SendMessage("You cannot afford that item.");
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 51
0
        public void EndStable(Mobile from, BaseCreature pet)
        {
            if (this.Deleted || !from.CheckAlive())
                return;

            if (!pet.Controlled || pet.ControlMaster != from)
            {
                from.SendLocalizedMessage(1042562); // You do not own that pet!
            }
            else if (pet.IsDeadPet)
            {
                from.SendLocalizedMessage(1049668); // Living pets only, please.
            }
            else if (pet.Summoned)
            {
                from.SendLocalizedMessage(502673); // I can not stable summoned creatures.
            }
            #region Mondain's Legacy
            else if (pet.Allured)
            {
                from.SendLocalizedMessage(1048053); // You can't stable that!
            }
            #endregion
            else if (pet.Body.IsHuman)
            {
                from.SendLocalizedMessage(502672); // HA HA HA! Sorry, I am not an inn.
            }
            else if ((pet is PackLlama || pet is PackHorse || pet is Beetle) && (pet.Backpack != null && pet.Backpack.Items.Count > 0))
            {
                from.SendLocalizedMessage(1042563); // You need to unload your pet.
            }
            else if (pet.Combatant != null && pet.InRange(pet.Combatant, 12) && pet.Map == pet.Combatant.Map)
            {
                from.SendLocalizedMessage(1042564); // I'm sorry.  Your pet seems to be busy.
            }
            else if (from.Stabled.Count >= GetMaxStabled(from))
            {
                from.SendLocalizedMessage(1042565); // You have too many pets in the stables!
            }
            else
            {
                Container bank = from.FindBankNoCreate();

                if (bank != null && bank.ConsumeTotal(typeof(Gold), 30))
                {
                    pet.ControlTarget = null;
                    pet.ControlOrder = OrderType.Stay;
                    pet.Internalize();

                    pet.SetControlMaster(null);
                    pet.SummonMaster = null;

                    pet.IsStabled = true;

                    if (Core.SE)
                        pet.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully happy

                    from.Stabled.Add(pet);

                    this.UsesRemaining -= 1;

                    from.SendLocalizedMessage(502679); // Very well, thy pet is stabled. Thou mayst recover it by saying 'claim' to me. In one real world week, I shall sell it off if it is not claimed!
                }
                else
                {
                    from.SendLocalizedMessage(502677); // But thou hast not the funds in thy bank account!
                }
            }
        }
Ejemplo n.º 52
0
        public virtual void ConsumeCurrency(Mobile buyer, ref double totalCost, ref bool bought, ref bool fromBank)
        {
            if (!bought && CashType.TypeEquals <ObjectProperty>())
            {
                var cashSource = GetCashObject(buyer) ?? buyer;

                bought = CashProperty.Consume(cashSource, totalCost);

                if (bought)
                {
                    SayTo(buyer, "{0:#,0} {1} has been deducted from your total.", totalCost, CashName.GetString(buyer));
                }
                else
                {
                    // Begging thy pardon, but thou cant afford that.
                    SayTo(buyer, 500192);
                }

                return;
            }

            var isGold = CashType.TypeEquals <Gold>();

            var cont = buyer.Backpack;

            if (!bought && cont != null && isGold)
            {
                try
                {
                    var lt = ScriptCompiler.FindTypeByName("GoldLedger") ?? Type.GetType("GoldLedger");

                    if (lt != null)
                    {
                        var ledger = cont.FindItemByType(lt);

                        if (ledger != null && !ledger.Deleted)
                        {
                            var lp = lt.GetProperty("Gold");

                            if (lp != null)
                            {
                                if (lp.PropertyType.IsEqual <Int64>())
                                {
                                    var lg = (long)lp.GetValue(ledger, null);

                                    if (lg >= totalCost)
                                    {
                                        lp.SetValue(ledger, lg - (long)totalCost, null);
                                        bought = true;
                                    }
                                }
                                else if (lp.PropertyType.IsEqual <Int32>())
                                {
                                    var lg = (int)lp.GetValue(ledger, null);

                                    if (lg >= totalCost)
                                    {
                                        lp.SetValue(ledger, lg - (int)totalCost, null);
                                        bought = true;
                                    }
                                }

                                if (bought)
                                {
                                    buyer.SendMessage(2125, "{0:#,0} gold has been withdrawn from your ledger.", totalCost);
                                    return;
                                }
                            }
                        }
                    }
                }
                catch
                { }
            }

            if (!bought && cont != null && ConsumeCash(CashType, cont, totalCost))
            {
                bought = true;
            }

            if (!bought && isGold)
            {
                if (totalCost <= Int32.MaxValue)
                {
                    if (Banker.Withdraw(buyer, (int)totalCost))
                    {
                        bought   = true;
                        fromBank = true;
                    }
                }
                else if (buyer.Account != null && AccountGold.Enabled)
                {
                    if (buyer.Account.WithdrawCurrency(totalCost / AccountGold.CurrencyThreshold))
                    {
                        bought   = true;
                        fromBank = true;
                    }
                }
            }

            if (!bought && !isGold)
            {
                cont = buyer.FindBankNoCreate();

                if (cont != null && ConsumeCash(CashType, cont, totalCost))
                {
                    bought   = true;
                    fromBank = true;
                }
            }
        }
Ejemplo n.º 53
0
        public void EndStable(Mobile from, BaseCreature pet)
        {
            if (Deleted || !from.CheckAlive())
            {
                return;
            }

            if (!pet.Controlled || pet.ControlMaster != from)
            {
                from.SendLocalizedMessage(1042562);                 // You do not own that pet!
            }
            else if (pet.IsDeadPet)
            {
                from.SendLocalizedMessage(1049668);                 // Living pets only, please.
            }
            else if (pet.Summoned)
            {
                from.SendLocalizedMessage(502673);                 // I can not stable summoned creatures.
            }
            #region Mondain's Legacy
            else if (pet.Allured)
            {
                from.SendLocalizedMessage(1048053);                 // You can't stable that!
            }
            #endregion
            else if (pet.Body.IsHuman)
            {
                from.SendLocalizedMessage(502672);                 // HA HA HA! Sorry, I am not an inn.
            }
            else if ((pet is PackLlama || pet is PackHorse || pet is Beetle) && (pet.Backpack != null && pet.Backpack.Items.Count > 0))
            {
                from.SendLocalizedMessage(1042563);                 // You need to unload your pet.
            }
            else if (pet.Combatant != null && pet.InRange(pet.Combatant, 12) && pet.Map == pet.Combatant.Map)
            {
                from.SendLocalizedMessage(1042564);                 // I'm sorry.  Your pet seems to be busy.
            }
            else if (from.Stabled.Count >= GetMaxStabled(from))
            {
                from.SendLocalizedMessage(1042565);                 // You have too many pets in the stables!
            }
            else
            {
                Container bank = from.FindBankNoCreate();

                if (bank != null && bank.ConsumeTotal(typeof(Gold), 30))
                {
                    pet.ControlTarget = null;
                    pet.ControlOrder  = OrderType.Stay;
                    pet.Internalize();

                    pet.SetControlMaster(null);
                    pet.SummonMaster = null;

                    pet.IsStabled = true;

                    if (Core.SE)
                    {
                        pet.Loyalty = BaseCreature.MaxLoyalty;                         // Wonderfully happy
                    }
                    from.Stabled.Add(pet);

                    UsesRemaining -= 1;

                    from.SendLocalizedMessage(502679);                     // Very well, thy pet is stabled. Thou mayst recover it by saying 'claim' to me. In one real world week, I shall sell it off if it is not claimed!
                }
                else
                {
                    from.SendLocalizedMessage(502677);                     // But thou hast not the funds in thy bank account!
                }
            }
        }
Ejemplo n.º 54
0
		public static int DepositUpTo(Mobile from, Type currencyType, int amount)
		{
			BankBox box = from.FindBankNoCreate();

			if (box != null)
			{
				int amountLeft = amount;

				while (amountLeft > 0)
				{
					Item item;
					int amountGiven;

					if (amountLeft < 5000)
					{
						item = currencyType.CreateInstanceSafe<Item>();

						item.Stackable = true;
						item.Amount = amountLeft;

						amountGiven = amountLeft;
					}
					else if (amountLeft <= 1000000)
					{
						item = new BankCheck(amountLeft);
						amountGiven = amountLeft;
					}
					else
					{
						item = new BankCheck(1000000);
						amountGiven = 1000000;
					}

					if (box.TryDropItem(from, item, false))
					{
						amountLeft -= amountGiven;
					}
					else
					{
						item.Delete();
						break;
					}
				}

				return amount - amountLeft;
			}

			return 0;
		}
Ejemplo n.º 55
0
		public static void WithdrawUpTo(Mobile from, int amount, Item[] currency, BankCheck[] checks, ulong credit)
		{
			for (int i = 0; amount > 0 && i < currency.Length; ++i)
			{
				int consume = Math.Min(currency[i].Amount, amount);
				currency[i].Consume(consume);
				amount -= consume;
			}

			for (int i = 0; amount > 0 && i < checks.Length; ++i)
			{
				BankCheck check = checks[i];

				int consume = Math.Min(check.Worth, amount);
				check.ConsumeWorth(consume);
				amount -= consume;
			}

			BankBox bank = from.FindBankNoCreate();

			if (bank != null) // sanity check?
			{
				ulong cons = Math.Min((ulong)amount, credit);
				bank.Credit -= cons;
				amount -= (int)cons;
			}
		}
Ejemplo n.º 56
0
        //code to finish adding an item - accessed by the add item target
        public void AddItem(Mobile from, object targeted)
        {
            if (from != null && !CanUse(from))
            {
                from.SendMessage("You no longer can use that");
                return;
            }

            //keep track of the item
            Item item = null;

            //keep track of the deed if it's a commodity deeds
            Item deed = null;

            int entryindex;

            if (!(targeted is Item))
            {
                if (from != null)
                {
                    from.SendMessage("this only works on items.");
                }
                return;
            }

            item = (Item)targeted;

            if (from != null && !item.IsChildOf(from.Backpack))
            {
                BankBox box = from.FindBankNoCreate();

                if (box == null || !item.IsChildOf(box))
                {
                    from.SendMessage("you can only add items from your backpack or bank box");
                    return;
                }
            }


            //Handle commodity deed insertion
            if (item is CommodityDeed)
            {
                if (((CommodityDeed)item).Commodity == null)
                {
                    if (from != null)
                    {
                        from.SendMessage("there is nothing to add in that commodity deed.");
                    }
                    return;
                }
                //store the deed reference
                deed = item;

                //reference the commodity within the deed
                item = ((CommodityDeed)item).Commodity;
            }

            //this uses the overloadable comparison for the appropriate store entries, so that custom store entries
            //can provide custom comparisons with items through their Match() methods
            entryindex = StoreEntry.IndexOfItem(_StoreEntries, item, true);

            if (entryindex == -1)
            {
                if (from != null)
                {
                    from.SendMessage("that cannot be stored in this.");
                }
                return;
            }

            //reference the item store entry
            StoreEntry entry = _StoreEntries[entryindex];

            if (!entry.Add(item))
            {
                if (from != null)
                {
                    from.SendMessage("that quantity cannot fit in this.");
                }
                return;
            }

            //don't delete items that are stuck in a stash list
            if (!(entry is StashEntry))
            {
                //delete the item after
                if (deed != null)
                {
                    deed.Delete();
                }
                else
                {
                    entry.AbsorbItem(item);
                }
            }



            //start next add and give another cursor
            if (from != null)
            {
                AddItem(from);

                //resend the gump after it's all done
                if (!ItemStoreGump.RefreshGump(from))
                {
                    //send a new gump if there's no existing one up
                    from.SendGump(new ItemStoreGump(from, this));
                }
            }
        }
Ejemplo n.º 57
0
		public virtual bool OnBuyItems( Mobile buyer, List<BuyItemResponse> list )
		{
			if ( !IsActiveSeller )
				return false;

			if ( !buyer.CheckAlive() )
				return false;

			if ( !CheckVendorAccess( buyer ) )
			{
				Say( 501522 ); // I shall not treat with scum like thee!
				return false;
			}

			UpdateBuyInfo();

			IBuyItemInfo[] buyInfo = this.GetBuyInfo();
			IShopSellInfo[] info = GetSellInfo();
			int totalCost = 0;
			List<BuyItemResponse> validBuy = new List<BuyItemResponse>( list.Count );
			Container cont;
			bool bought = false;
			bool fromBank = false;
			bool fullPurchase = true;
			int controlSlots = buyer.FollowersMax - buyer.Followers;

			foreach ( BuyItemResponse buy in list )
			{
				Serial ser = buy.Serial;
				int amount = buy.Amount;

				if ( ser.IsItem )
				{
					Item item = World.FindItem( ser );

					if ( item == null )
						continue;

					GenericBuyInfo gbi = LookupDisplayObject( item );

					if ( gbi != null )
					{
						ProcessSinglePurchase( buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost );
					}
					else if ( item != this.BuyPack && item.IsChildOf( this.BuyPack ) )
					{
						if ( amount > item.Amount )
							amount = item.Amount;

						if ( amount <= 0 )
							continue;

						foreach ( IShopSellInfo ssi in info )
						{
							if ( ssi.IsSellable( item ) )
							{
								if ( ssi.IsResellable( item ) )
								{
									totalCost += ssi.GetBuyPriceFor( item ) * amount;
									validBuy.Add( buy );
									break;
								}
							}
						}
					}
				}
				else if ( ser.IsMobile )
				{
					Mobile mob = World.FindMobile( ser );

					if ( mob == null )
						continue;

					GenericBuyInfo gbi = LookupDisplayObject( mob );

					if ( gbi != null )
						ProcessSinglePurchase( buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost );
				}
			}//foreach

			if ( fullPurchase && validBuy.Count == 0 )
				SayTo( buyer, 500190 ); // Thou hast bought nothing!
			else if ( validBuy.Count == 0 )
				SayTo( buyer, 500187 ); // Your order cannot be fulfilled, please try again.

			if ( validBuy.Count == 0 )
				return false;

			bought = ( buyer.AccessLevel >= AccessLevel.GameMaster );

			cont = buyer.Backpack;
			if ( !bought && cont != null )
			{
				if ( cont.ConsumeTotal( typeof( Gold ), totalCost ) )
					bought = true;
				else if ( totalCost < 2000 )
					SayTo( buyer, 500192 ); // Begging thy pardon, but thou canst not afford that.
			}

			if ( !bought && totalCost >= 2000 )
			{
				cont = buyer.FindBankNoCreate();
				if ( cont != null && cont.ConsumeTotal( typeof( Gold ), totalCost ) )
				{
					bought = true;
					fromBank = true;
				}
				else
				{
					SayTo( buyer, 500191 ); //Begging thy pardon, but thy bank account lacks these funds.
				}
			}

			if ( !bought )
				return false;
			else
				buyer.PlaySound( 0x32 );

			cont = buyer.Backpack;
			if ( cont == null )
				cont = buyer.BankBox;

			foreach ( BuyItemResponse buy in validBuy )
			{
				Serial ser = buy.Serial;
				int amount = buy.Amount;

				if ( amount < 1 )
					continue;

				if ( ser.IsItem )
				{
					Item item = World.FindItem( ser );

					if ( item == null )
						continue;

					GenericBuyInfo gbi = LookupDisplayObject( item );

					if ( gbi != null )
					{
						ProcessValidPurchase( amount, gbi, buyer, cont );
					}
					else
					{
						if ( amount > item.Amount )
							amount = item.Amount;

						foreach ( IShopSellInfo ssi in info )
						{
							if ( ssi.IsSellable( item ) )
							{
								if ( ssi.IsResellable( item ) )
								{
									Item buyItem;
									if ( amount >= item.Amount )
									{
										buyItem = item;
									}
									else
									{
										buyItem = Mobile.LiftItemDupe( item, item.Amount - amount );

										if ( buyItem == null )
											buyItem = item;
									}

									if ( cont == null || !cont.TryDropItem( buyer, buyItem, false ) )
										buyItem.MoveToWorld( buyer.Location, buyer.Map );

									break;
								}
							}
						}
					}
				}
				else if ( ser.IsMobile )
				{
					Mobile mob = World.FindMobile( ser );

					if ( mob == null )
						continue;

					GenericBuyInfo gbi = LookupDisplayObject( mob );

					if ( gbi != null )
						ProcessValidPurchase( amount, gbi, buyer, cont );
				}
			}//foreach

			if ( fullPurchase )
			{
				if ( buyer.AccessLevel >= AccessLevel.GameMaster )
					SayTo( buyer, true, "I would not presume to charge thee anything.  Here are the goods you requested." );
				else if ( fromBank )
					SayTo( buyer, true, "The total of thy purchase is {0} gold, which has been withdrawn from your bank account.  My thanks for the patronage.", totalCost );
				else
					SayTo( buyer, true, "The total of thy purchase is {0} gold.  My thanks for the patronage.", totalCost );
			}
			else
			{
				if ( buyer.AccessLevel >= AccessLevel.GameMaster )
					SayTo( buyer, true, "I would not presume to charge thee anything.  Unfortunately, I could not sell you all the goods you requested." );
				else if ( fromBank )
					SayTo( buyer, true, "The total of thy purchase is {0} gold, which has been withdrawn from your bank account.  My thanks for the patronage.  Unfortunately, I could not sell you all the goods you requested.", totalCost );
				else
					SayTo( buyer, true, "The total of thy purchase is {0} gold.  My thanks for the patronage.  Unfortunately, I could not sell you all the goods you requested.", totalCost );
			}

			return true;
		}
Ejemplo n.º 58
0
 public bool IsUsableBy(Mobile from)
 {
     Item root = this.RootParent as Item;
     return this.IsChildOf(from.Backpack) || this.IsChildOf(from.FindBankNoCreate()) || this.IsLockedDown && this.IsAccessibleTo(from) || root != null && root.IsSecure && root.IsAccessibleTo(from);
 }
Ejemplo n.º 59
0
		public override void OnDoubleClick(Mobile from)
		{
			BankBox box = from.FindBankNoCreate();

			if (box != null && IsChildOf(box))
			{
				Delete();

				int deposited = 0;

				int toAdd = m_Worth;

				Item currency;

				while (toAdd >= 60000)
				{
					currency = TypeOfCurrency.CreateInstanceSafe<Item>();

					currency.Stackable = true;
					currency.Amount = 60000;

					if (box.TryDropItem(from, currency, false))
					{
						toAdd -= 60000;
						deposited += 60000;
					}
					else
					{
						currency.Delete();

						from.AddToBackpack(new BankCheck(toAdd));
						toAdd = 0;

						break;
					}
				}

				if (toAdd > 0)
				{
					currency = TypeOfCurrency.CreateInstanceSafe<Item>();

					currency.Stackable = true;
					currency.Amount = toAdd;

					if (box.TryDropItem(from, currency, false))
					{
						deposited += toAdd;
					}
					else
					{
						currency.Delete();

						from.AddToBackpack(new BankCheck(toAdd));
					}
				}

				// Gold was deposited in your account:
				from.SendLocalizedMessage(1042672, true, " " + deposited.ToString("#,0"));

				var pm = from as PlayerMobile;

				if (pm != null)
				{
					QuestSystem qs = pm.Quest;

					if (qs is DarkTidesQuest)
					{
						QuestObjective obj = qs.FindObjective(typeof(CashBankCheckObjective));

						if (obj != null && !obj.Completed)
						{
							obj.Complete();
						}
					}

					if (qs is UzeraanTurmoilQuest)
					{
						QuestObjective obj = qs.FindObjective(typeof(Engines.Quests.Haven.CashBankCheckObjective));

						if (obj != null && !obj.Completed)
						{
							obj.Complete();
						}
					}
				}
			}
			else
			{
				from.SendLocalizedMessage(1047026); // That must be in your bank box to use it.
			}
		}
Ejemplo n.º 60
0
		public static int DepositUpTo( Mobile from, int amount )
		{
			BankBox box = from.FindBankNoCreate();
			if ( box == null )
				return 0;

			int amountLeft = amount;
			while ( amountLeft > 0 )
			{
				Item item;
				int amountGiven;

				if ( amountLeft < 5000 )
				{
					item = new Gold( amountLeft );
					amountGiven = amountLeft;
				}
				else if ( amountLeft <= 1000000 )
				{
					item = new BankCheck( amountLeft );
					amountGiven = amountLeft;
				}
				else
				{
					item = new BankCheck( 1000000 );
					amountGiven = 1000000;
				}

				if ( box.TryDropItem( from, item, false ) )
				{
					amountLeft -= amountGiven;
				}
				else
				{
					item.Delete();
					break;
				}
			}

			return amount - amountLeft;
		}