コード例 #1
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1 && !m_House.Deleted)
            {
                if (m_House.IsOwner(m_Mobile))
                {
                    if (m_House.MovingCrate != null || m_House.InternalizedVendors.Count > 0)
                    {
                        m_Mobile.SendLocalizedMessage(1080455);                         // You can not resize your house at this time. Please remove all items fom the moving crate and try again.
                        return;
                    }
                    else if (!Guilds.Guild.NewGuildSystem && m_House.FindGuildstone() != null)
                    {
                        m_Mobile.SendLocalizedMessage(501389);                         // You cannot redeed a house with a guildstone inside.
                        return;
                    }

                    /*else if ( m_House.PlayerVendors.Count > 0 )
                     * {
                     *      m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving.
                     *      return;
                     * }*/
                    else if (m_House.HasRentedVendors && m_House.VendorInventories.Count > 0)
                    {
                        m_Mobile.SendLocalizedMessage(1062679);                         // You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house.
                        return;
                    }
                    else if (m_House.HasRentedVendors)
                    {
                        m_Mobile.SendLocalizedMessage(1062680);                         // You cannot do that that while you still have contract vendors in your house.
                        return;
                    }
                    else if (m_House.VendorInventories.Count > 0)
                    {
                        m_Mobile.SendLocalizedMessage(1062681);                         // You cannot do that that while you still have unclaimed contract vendor inventory in your house.
                        return;
                    }

                    if (m_Mobile.AccessLevel >= AccessLevel.GameMaster)
                    {
                        m_Mobile.SendMessage("You do not get a refund for your house as you are not a player");
                        m_House.RemoveKeys(m_Mobile);
                        new TempNoHousingRegion(m_House, m_Mobile);
                        m_House.Delete();
                    }
                    else
                    {
                        Item toGive = null;

                        if (m_House.IsAosRules)
                        {
                            if (m_House.Price > 0)
                            {
                                toGive = new BankCheck(m_House.Price);
                            }
                            else
                            {
                                toGive = m_House.GetDeed();
                            }
                        }
                        else
                        {
                            toGive = m_House.GetDeed();

                            if (toGive == null && m_House.Price > 0)
                            {
                                toGive = new BankCheck(m_House.Price);
                            }
                        }

                        if (toGive != null)
                        {
                            BankBox box = m_Mobile.BankBox;

                            if (box.TryDropItem(m_Mobile, toGive, false))
                            {
                                if (toGive is BankCheck)
                                {
                                    m_Mobile.SendLocalizedMessage(1060397, ((BankCheck)toGive).Worth.ToString());                                     // ~1_AMOUNT~ gold has been deposited into your bank box.
                                }
                                m_House.RemoveKeys(m_Mobile);
                                new TempNoHousingRegion(m_House, m_Mobile);
                                m_House.Delete();
                            }
                            else
                            {
                                toGive.Delete();
                                m_Mobile.SendLocalizedMessage(500390);                                 // Your bank box is full.
                            }
                        }
                        else
                        {
                            m_Mobile.SendMessage("Unable to refund house.");
                        }
                    }
                }
                else
                {
                    m_Mobile.SendLocalizedMessage(501320);                     // Only the house owner may do this.
                }
            }
            else if (info.ButtonID == 0)
            {
                m_Mobile.CloseGump(typeof(ConfirmHouseResize));
                m_Mobile.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, m_Mobile, m_House));
            }
        }
コード例 #2
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            if (!e.Handled && e.Mobile.InRange(this.Location, 12))
            {
                for (int i = 0; i < e.Keywords.Length; ++i)
                {
                    int keyword = e.Keywords[i];

                    switch (keyword)
                    {
                    case 0x0000:                             // *withdraw*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500389);                                               // I will not do business with a criminal!
                            break;
                        }

                        string[] split = e.Speech.Split(' ');

                        if (split.Length >= 2)
                        {
                            int amount;

                            try
                            {
                                amount = Convert.ToInt32(split[1]);
                            }
                            catch
                            {
                                break;
                            }

                            if (amount > 5000)
                            {
                                this.Say(500381);                                                   // Thou canst not withdraw so much at one time!
                            }
                            else if (amount > 0)
                            {
                                BankBox box = e.Mobile.BankBox;

                                if (box == null || !box.ConsumeTotal(typeof(Gold), amount))
                                {
                                    this.Say(500384);                                                       // Ah, art thou trying to fool me? Thou hast not so much gold!
                                }
                                else
                                {
                                    e.Mobile.AddToBackpack(new Gold(amount));

                                    this.Say(1010005);                                                       // Thou hast withdrawn gold from thy account.
                                }
                            }
                        }

                        break;
                    }

                    case 0x0001:                             // *balance*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500389);                                               // I will not do business with a criminal!
                            break;
                        }

                        BankBox box = e.Mobile.BankBox;

                        if (box != null)
                        {
                            this.Say(1042759, box.TotalGold.ToString());                                               // Thy current bank balance is ~1_AMOUNT~ gold.
                        }

                        break;
                    }

                    case 0x0002:                             // *bank*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500378);                                               // Thou art a criminal and cannot access thy bank box.
                            break;
                        }

                        BankBox box = e.Mobile.BankBox;

                        if (box != null)
                        {
                            box.Open();
                        }

                        break;
                    }

                    case 0x0003:                             // *check*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500389);                                               // I will not do business with a criminal!
                            break;
                        }

                        string[] split = e.Speech.Split(' ');

                        if (split.Length >= 2)
                        {
                            int amount;

                            try
                            {
                                amount = Convert.ToInt32(split[1]);
                            }
                            catch
                            {
                                break;
                            }

                            if (amount < 5000)
                            {
                                this.Say(1010006);                                                   // We cannot create checks for such a paltry amount of gold!
                            }
                            else if (amount > 1000000)
                            {
                                this.Say(1010007);                                                   // Our policies prevent us from creating checks worth that much!
                            }
                            else
                            {
                                BankCheck check = new BankCheck(amount);

                                BankBox box = e.Mobile.BankBox;

                                if (box == null || !box.TryDropItem(e.Mobile, check, false))
                                {
                                    this.Say(500386);                                                       // There's not enough room in your bankbox for the check!
                                    check.Delete();
                                }
                                else if (!box.ConsumeTotal(typeof(Gold), amount))
                                {
                                    this.Say(500384);                                                       // Ah, art thou trying to fool me? Thou hast not so much gold!
                                    check.Delete();
                                }
                                else
                                {
                                    this.Say(1042673, AffixType.Append, amount.ToString(), "");                                                       // Into your bank box I have placed a check in the amount of:
                                }
                            }
                        }

                        break;
                    }
                    }
                }
            }

            base.OnSpeech(e);
        }
コード例 #3
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1 && !m_House.Deleted)
            {
                if (m_House.IsOwner(m_Mobile))
                {
                    if (m_House.MovingCrate != null || m_House.InternalizedVendors.Count > 0)
                    {
                        return;
                    }
                    else if (!Guilds.Guild.NewGuildSystem && m_House.FindGuildstone() != null)
                    {
                        m_Mobile.SendLocalizedMessage(501389);                           // You cannot redeed a house with a guildstone inside.
                        return;
                    }

                    /*else if ( m_House.PlayerVendors.Count > 0 )
                     * {
                     *      m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving.
                     *      return;
                     * }*/
                    else if (m_House.HasRentedVendors && m_House.VendorInventories.Count > 0)
                    {
                        m_Mobile.SendLocalizedMessage(1062679);                           // You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house.
                        return;
                    }
                    else if (m_House.HasRentedVendors)
                    {
                        m_Mobile.SendLocalizedMessage(1062680);                           // You cannot do that that while you still have contract vendors in your house.
                        return;
                    }
                    else if (m_House.VendorInventories.Count > 0)
                    {
                        m_Mobile.SendLocalizedMessage(1062681);                           // You cannot do that that while you still have unclaimed contract vendor inventory in your house.
                        return;
                    }

                    if (m_Mobile.AccessLevel >= AccessLevel.GameMaster)
                    {
                        m_Mobile.SendMessage("You do not get a refund for your house as you are not a player");
                        m_House.RemoveKeys(m_Mobile);
                        m_House.Delete();
                    }
                    else
                    {
                        Item      toGive = null;
                        BankCheck check  = null;
                        BankBox   box    = m_Mobile.BankBox;

                        if (m_House.IsAosRules)
                        {
                            if (m_House.Price > 0)
                            {
                                check = new BankCheck(m_House.Price);
                            }

                            toGive = m_House.GetDeed();
                        }
                        else
                        {
                            toGive = m_House.GetDeed();

                            if (toGive == null && m_House.Price > 0)
                            {
                                check = new BankCheck(m_House.Price);
                            }
                        }

                        if (check != null)
                        {
                            if (box.TryDropItem(m_Mobile, check, false))
                            {
                                m_Mobile.SendLocalizedMessage(1060397, check.Worth.ToString());                                   // ~1_AMOUNT~ gold has been deposited into your bank box.
                            }
                            else
                            {
                                check.Delete();
                                if (toGive != null)
                                {
                                    toGive.Delete();
                                }
                                m_Mobile.SendLocalizedMessage(500390);                                   // Your bank box is full.
                                return;
                            }
                        }

                        if (toGive != null)
                        {
                            if (box.TryDropItem(m_Mobile, toGive, false))
                            {
                                PlayerMobile pm = m_Mobile as PlayerMobile;

                                if (pm != null && pm.HasDonated)
                                {
                                    m_House.KillVendors();
                                    HouseDecayingCrate crate = m_House.MoveAllDecayingToCrate();
                                    if (crate.Items.Count == 0)
                                    {
                                        crate.Delete();
                                    }
                                    else
                                    {
                                        m_Mobile.BankBox.DropItem(crate);
                                    }
                                }

                                m_Mobile.CloseGump(typeof(ConfirmCommitGump));

                                m_House.RemoveKeys(m_Mobile);
                                m_House.Delete();
                            }
                            else
                            {
                                if (check != null)
                                {
                                    check.Delete();
                                }
                                toGive.Delete();
                                m_Mobile.SendLocalizedMessage(500390);                                   // Your bank box is full.
                                return;
                            }
                        }
                        else if (TestCenter.Enabled)
                        {
                            m_Mobile.SendMessage("This house cannot be refunded during beta.  Please contact a Gamemaster for replacement options.");
                        }
                        else
                        {
                            m_Mobile.SendMessage("Your house cannot be refunded.");
                        }
                    }
                }
                else
                {
                    m_Mobile.SendLocalizedMessage(501320);                       // Only the house owner may do this.
                }
            }
        }
コード例 #4
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 1 && !m_House.Deleted)
            {
                if (m_House.IsOwner(m_Mobile))
                {
                    if (m_House.MovingCrate != null || m_House.InternalizedVendors.Count > 0)
                    {
                        return;
                    }
                    else if (!Guilds.Guild.NewGuildSystem && m_House.FindGuildstone() != null)
                    {
                        m_Mobile.SendLocalizedMessage(501389);                           // You cannot redeed a house with a guildstone inside.
                        return;
                    }

                    /*else if ( m_House.PlayerVendors.Count > 0 )
                     * {
                     *      m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving.
                     *      return;
                     * }*/
                    else if (m_House.HasRentedVendors && m_House.VendorInventories.Count > 0)
                    {
                        m_Mobile.SendLocalizedMessage(1062679);                           // You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house.
                        return;
                    }
                    else if (m_House.HasRentedVendors)
                    {
                        m_Mobile.SendLocalizedMessage(1062680);                           // You cannot do that that while you still have contract vendors in your house.
                        return;
                    }
                    else if (m_House.VendorInventories.Count > 0)
                    {
                        m_Mobile.SendLocalizedMessage(1062681);                           // You cannot do that that while you still have unclaimed contract vendor inventory in your house.
                        return;
                    }

                    Item toGive = null;

                    if (m_House.IsAosRules)
                    {
                        if (m_House.Price > 0)
                        {
                            toGive = new BankCheck(m_House.Price);
                        }
                        else
                        {
                            toGive = m_House.GetDeed();
                        }
                    }
                    else
                    {
                        toGive = m_House.GetDeed();

                        if (toGive == null && m_House.Price > 0)
                        {
                            toGive = new BankCheck(m_House.Price);
                        }
                    }

                    if (toGive != null)
                    {
                        BankBox box = m_Mobile.BankBox;

                        if (box != null && box.TryDropItem(m_Mobile, toGive, false))
                        {
                            if (toGive is BankCheck)
                            {
                                m_Mobile.SendLocalizedMessage(1060397, ((BankCheck)toGive).Worth.ToString());                                   // ~1_AMOUNT~ gold has been deposited into your bank box.
                            }
                            m_House.RemoveKeys(m_Mobile);
                            m_House.Delete();
                        }
                        else
                        {
                            toGive.Delete();
                            m_Mobile.SendLocalizedMessage(500390);                               // Your bank box is full.
                        }
                    }
                    else
                    {
                        m_Mobile.SendMessage("Unable to refund house.");
                    }
                }
                else
                {
                    m_Mobile.SendLocalizedMessage(501320);                       // Only the house owner may do this.
                }
            }
        }
コード例 #5
0
ファイル: Banker.cs プロジェクト: zerodowned/angelisland
        public override void OnSpeech(SpeechEventArgs e)
        {
            if (!e.Handled && e.Mobile.InRange(this.Location, 12))
            {
                for (int i = 0; i < e.Keywords.Length; ++i)
                {
                    int keyword = e.Keywords[i];

                    switch (keyword)
                    {
                    case 0x0000:                             // *withdraw*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500389);                                       // I will not do business with a criminal!
                            break;
                        }

                        string[] split = e.Speech.Split(' ');

                        if (split.Length >= 2)
                        {
                            int amount;

                            try
                            {
                                amount = Convert.ToInt32(split[1]);
                            }
                            catch
                            {
                                break;
                            }

                            if (amount > 5000)
                            {
                                this.Say(500381);                                           // Thou canst not withdraw so much at one time!
                            }
                            else if (amount > 0)
                            {
                                BankBox box = e.Mobile.BankBox;

                                if (box == null || !box.ConsumeTotal(typeof(Gold), amount))
                                {
                                    this.Say(500384);                                               // Ah, art thou trying to fool me? Thou hast not so much gold!
                                }
                                else
                                {
                                    e.Mobile.AddToBackpack(new Gold(amount));

                                    this.Say(1010005);                                               // Thou hast withdrawn gold from thy account.
                                }
                            }
                        }

                        break;
                    }

                    case 0x0001:                             // *balance*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500389);                                       // I will not do business with a criminal!
                            break;
                        }

                        BankBox box = e.Mobile.BankBox;

                        if (box != null)
                        {
                            this.Say(1042759, box.TotalGold.ToString());                                       // Thy current bank balance is ~1_AMOUNT~ gold.
                        }

                        break;
                    }

                    case 0x0002:                             // *bank*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500378);                                       // Thou art a criminal and cannot access thy bank box.
                            break;
                        }

                        if (e.Mobile.Player == true)
                        {
                            if (e.Mobile is PlayerMobile)
                            {
                                PlayerMobile pm = e.Mobile as PlayerMobile;

                                if (DateTime.Now - pm.LastStoleAt < TimeSpan.FromMinutes(2))
                                {
                                    this.Say(500378);                                             // Thou art a criminal and cannot access thy bank box.
                                    break;
                                }

                                //check that we're not actively involved in a fight:
                                bool bBreak = false;
                                for (int a = 0; a < pm.Aggressed.Count; a++)
                                {
                                    AggressorInfo info = (AggressorInfo)pm.Aggressed[a];
                                    if (!info.Expired)
                                    {
                                        if (info.Attacker == pm && info.Defender is PlayerMobile)
                                        {
                                            this.Say("You seem to be busy to bank, come back when you're not fighting.");
                                            bBreak = true;
                                            break;
                                        }
                                    }
                                }
                                if (bBreak)
                                {
                                    break;
                                }
                            }
                        }
                        BankBox box = e.Mobile.BankBox;

                        if (box != null)
                        {
                            box.Open();
                        }

                        break;
                    }

                    case 0x0003:                             // *check*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500389);                                       // I will not do business with a criminal!
                            break;
                        }

                        string[] split = e.Speech.Split(' ');

                        if (split.Length >= 2)
                        {
                            int amount;

                            try
                            {
                                amount = Convert.ToInt32(split[1]);
                            }
                            catch
                            {
                                break;
                            }

                            if (amount < 5000)
                            {
                                this.Say(1010006);                                           // We cannot create checks for such a paltry amount of gold!
                            }
                            else if (amount > 1000000)
                            {
                                this.Say(1010007);                                           // Our policies prevent us from creating checks worth that much!
                            }
                            else
                            {
                                BankCheck check = new BankCheck(amount);

                                BankBox box = e.Mobile.BankBox;

                                if (box == null || !box.TryDropItem(e.Mobile, check, false))
                                {
                                    this.Say(500386);                                               // There's not enough room in your bankbox for the check!
                                    check.Delete();
                                }
                                else if (!box.ConsumeTotal(typeof(Gold), amount))
                                {
                                    this.Say(500384);                                               // Ah, art thou trying to fool me? Thou hast not so much gold!
                                    check.Delete();
                                }
                                else
                                {
                                    this.Say(1042673, AffixType.Append, amount.ToString(), "");                                               // Into your bank box I have placed a check in the amount of:
                                }
                            }
                        }

                        break;
                    }
                    }
                }
            }

            base.OnSpeech(e);
        }
コード例 #6
0
ファイル: Banker.cs プロジェクト: tflynt91/TrueUO
        public static void HandleSpeech(Mobile vendor, SpeechEventArgs e)
        {
            if (!e.Handled && e.Mobile.InRange(vendor, 12))
            {
                if (e.Mobile.Map.Rules != MapRules.FeluccaRules && vendor is BaseVendor && !((BaseVendor)vendor).CheckVendorAccess(e.Mobile))
                {
                    return;
                }

                foreach (int keyword in e.Keywords)
                {
                    switch (keyword)
                    {
                    case 0x0000:     // *withdraw*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            // I will not do business with a criminal!
                            vendor.Say(500389);
                            break;
                        }

                        string[] split = e.Speech.Split(' ');

                        if (split.Length >= 2)
                        {
                            int amount;

                            Container pack = e.Mobile.Backpack;

                            if (!int.TryParse(split[1], out amount))
                            {
                                break;
                            }

                            if (amount > 60000)
                            {
                                // Thou canst not withdraw so much at one time!
                                vendor.Say(500381);
                            }
                            else if (pack == null || pack.Deleted || !(pack.TotalWeight < pack.MaxWeight) ||
                                     !(pack.TotalItems < pack.MaxItems))
                            {
                                // Your backpack can't hold anything else.
                                vendor.Say(1048147);
                            }
                            else if (amount > 0)
                            {
                                BankBox box = e.Mobile.Player ? e.Mobile.BankBox : e.Mobile.FindBankNoCreate();

                                if (box == null || !Withdraw(e.Mobile, amount))
                                {
                                    // Ah, art thou trying to fool me? Thou hast not so much gold!
                                    vendor.Say(500384);
                                }
                                else
                                {
                                    pack.DropItem(new Gold(amount));

                                    // Thou hast withdrawn gold from thy account.
                                    vendor.Say(1010005);
                                }
                            }
                        }
                    }
                    break;

                    case 0x0001:     // *balance*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            // I will not do business with a criminal!
                            vendor.Say(500389);
                            break;
                        }

                        if (AccountGold.Enabled && e.Mobile.Account is Account)
                        {
                            vendor.Say(1155855, string.Format("{0:#,0}\t{1:#,0}",
                                                              e.Mobile.Account.TotalPlat,
                                                              e.Mobile.Account.TotalGold), 0x3BC);

                            vendor.Say(1155848, string.Format("{0:#,0}", ((Account)e.Mobile.Account).GetSecureAccountAmount(e.Mobile)), 0x3BC);
                        }
                        else
                        {
                            // Thy current bank balance is ~1_AMOUNT~ gold.
                            vendor.Say(1042759, GetBalance(e.Mobile).ToString("#,0"));
                        }
                    }
                    break;

                    case 0x0002:     // *bank*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            // Thou art a criminal and cannot access thy bank box.
                            vendor.Say(500378);
                            break;
                        }

                        e.Mobile.BankBox.Open();
                    }
                    break;

                    case 0x0003:     // *check*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            // I will not do business with a criminal!
                            vendor.Say(500389);
                            break;
                        }

                        if (AccountGold.Enabled && e.Mobile.Account != null)
                        {
                            vendor.Say("We no longer offer a checking service.");
                            break;
                        }

                        string[] split = e.Speech.Split(' ');

                        if (split.Length >= 2)
                        {
                            int amount;

                            if (!int.TryParse(split[1], out amount))
                            {
                                break;
                            }

                            if (amount < 5000)
                            {
                                // We cannot create checks for such a paltry amount of gold!
                                vendor.Say(1010006);
                            }
                            else if (amount > 1000000)
                            {
                                // Our policies prevent us from creating checks worth that much!
                                vendor.Say(1010007);
                            }
                            else
                            {
                                BankCheck check = new BankCheck(amount);

                                BankBox box = e.Mobile.BankBox;

                                if (!box.TryDropItem(e.Mobile, check, false))
                                {
                                    // There's not enough room in your bankbox for the check!
                                    vendor.Say(500386);
                                    check.Delete();
                                }
                                else if (!box.ConsumeTotal(typeof(Gold), amount))
                                {
                                    // Ah, art thou trying to fool me? Thou hast not so much gold!
                                    vendor.Say(500384);
                                    check.Delete();
                                }
                                else
                                {
                                    // Into your bank box I have placed a check in the amount of:
                                    vendor.Say(1042673, AffixType.Append, amount.ToString("#,0"), "");
                                }
                            }
                        }
                    }
                    break;
                    }
                }
            }
        }
コード例 #7
0
ファイル: Banker.cs プロジェクト: tflynt91/TrueUO
        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);
            }

            BankBox box = from.Player ? from.BankBox : 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);
                }
            }

            if (message)
            {
                from.SendLocalizedMessage(1042763, amount.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US"))); // ~1_AMOUNT~ gold was deposited in your account.
            }
            return(true);
        }
コード例 #8
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 0)
            {
                return;
            }

            Mobile    from = sender.Mobile;
            HouseSign sign = m_House.Sign;

            if (m_House.Deleted || sign == null || sign.Deleted || !from.CheckAlive())
            {
                return;
            }

            if (from.Map != sign.Map || !from.InRange(sign, 5))
            {
                // You must be within five paces of the house sign to use this option.
                from.SendLocalizedMessage(1062429);
                return;
            }

            int index = info.ButtonID - 1;

            if (index < 0 || index >= m_Inventories.Count)
            {
                return;
            }

            var inventory = (VendorInventory)m_Inventories[index];

            if (inventory.Owner != from || !m_House.VendorInventories.Contains(inventory))
            {
                return;
            }

            int totalItems      = 0;
            int givenToBackpack = 0;
            int givenToBankBox  = 0;

            for (int i = inventory.Items.Count - 1; i >= 0; i--)
            {
                Item item = inventory.Items[i];

                if (item.Deleted)
                {
                    inventory.Items.RemoveAt(i);
                    continue;
                }

                totalItems += 1 + item.TotalItems;

                if (from.PlaceInBackpack(item))
                {
                    inventory.Items.RemoveAt(i);
                    givenToBackpack += 1 + item.TotalItems;
                }
                else
                {
                    BankBox box = from.FindBank(m_House.Expansion) ?? from.BankBox;

                    if (box.TryDropItem(from, item, false))
                    {
                        inventory.Items.RemoveAt(i);
                        givenToBankBox += 1 + item.TotalItems;
                    }
                }
            }

            from.SendMessage(
                "The vendor you selected had {0:#,0} items in its inventory, and {1:#,0} {2} in its account.",
                totalItems,
                inventory.Currency,
                inventory.TypeOfCurrency.Name);

            int givenGold = Banker.DepositUpTo(from, inventory.TypeOfCurrency, inventory.Currency);

            inventory.Currency -= givenGold;

            from.SendMessage("{0:#,0} {1} has been deposited into your bank box.", givenGold, inventory.TypeOfCurrency.Name);

            // ~1_COUNT~ items have been removed from the shop inventory and placed in your backpack.
            // ~2_BANKCOUNT~ items were removed from the shop inventory and placed in your bank box.
            from.SendLocalizedMessage(1062437, givenToBackpack.ToString("#,0") + "\t" + givenToBankBox.ToString("#,0"));

            if (inventory.Currency > 0 || inventory.Items.Count > 0)
            {
                // Some of the shop inventory would not fit in your backpack or bank box.
                // Please free up some room and try again.
                from.SendLocalizedMessage(1062440);
            }
            else
            {
                inventory.Delete();

                // The shop is now empty of inventory and funds, so it has been deleted.
                from.SendLocalizedMessage(1062438);
            }
        }
コード例 #9
0
ファイル: Banker.cs プロジェクト: Frazurbluu/runuo-1
        public override void OnSpeech(SpeechEventArgs e)
        {
            if (!e.Handled && e.Mobile.InRange(this.Location, 12))
            {
                for (int i = 0; i < e.Keywords.Length; ++i)
                {
                    int keyword = e.Keywords[i];

                    switch (keyword)
                    {
                    case 0x0000:                             // *withdraw*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500389);                                       // I will not do business with a criminal!
                            break;
                        }

                        string[] split = e.Speech.Split(' ');

                        if (split.Length >= 2)
                        {
                            int amount;

                            Container pack = e.Mobile.Backpack;

                            if (!int.TryParse(split[1], out amount))
                            {
                                break;
                            }

                            if ((!Core.ML && amount > 5000) || (Core.ML && amount > 60000))
                            {
                                this.Say(500381);                                           // Thou canst not withdraw so much at one time!
                            }
                            else if (pack == null || pack.Deleted || !(pack.TotalWeight < pack.MaxWeight) || !(pack.TotalItems < pack.MaxItems))
                            {
                                this.Say(1048147);                                         // Your backpack can't hold anything else.
                            }
                            else if (amount > 0)
                            {
                                BankBox box = e.Mobile.FindBankNoCreate();

                                if (box == null || !Withdraw(e.Mobile, amount))
                                {
                                    this.Say(500384);                                             // Ah, art thou trying to fool me? Thou hast not so much gold!
                                }
                                else
                                {
                                    pack.DropItem(new Gold(amount));

                                    this.Say(1010005);                                             // Thou hast withdrawn gold from thy account.
                                }
                            }
                        }

                        break;
                    }

                    case 0x0001:                             // *balance*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500389);                                       // I will not do business with a criminal!
                            break;
                        }

                        if (AccountGold.Enabled && e.Mobile.Account != null)
                        {
                            this.Say(1155855, String.Format("{0:#,0}\t{1:#,0}", e.Mobile.Account.TotalPlat, e.Mobile.Account.TotalGold));                                       // Thy current bank balance is ~1_AMOUNT~ platinum and ~2_AMOUNT~ gold.
                        }
                        else
                        {
                            this.Say(1042759, GetBalance(e.Mobile).ToString("#,0"));                                       // Thy current bank balance is ~1_AMOUNT~ gold.
                        }

                        break;
                    }

                    case 0x0002:                             // *bank*
                    {
                        e.Handled = true;

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500378);                                       // Thou art a criminal and cannot access thy bank box.
                            break;
                        }

                        e.Mobile.BankBox.Open();

                        break;
                    }

                    case 0x0003:                             // *check*
                    {
                        e.Handled = true;

                        if (AccountGold.Enabled)
                        {
                            break;
                        }

                        if (e.Mobile.Criminal)
                        {
                            this.Say(500389);                                       // I will not do business with a criminal!
                            break;
                        }

                        string[] split = e.Speech.Split(' ');

                        if (split.Length >= 2)
                        {
                            int amount;

                            if (!int.TryParse(split[1], out amount))
                            {
                                break;
                            }

                            if (amount < 5000)
                            {
                                this.Say(1010006);                                           // We cannot create checks for such a paltry amount of gold!
                            }
                            else if (amount > 1000000)
                            {
                                this.Say(1010007);                                           // Our policies prevent us from creating checks worth that much!
                            }
                            else
                            {
                                BankCheck check = new BankCheck(amount);

                                BankBox box = e.Mobile.BankBox;

                                if (!box.TryDropItem(e.Mobile, check, false))
                                {
                                    this.Say(500386);                                               // There's not enough room in your bankbox for the check!
                                    check.Delete();
                                }
                                else if (!box.ConsumeTotal(typeof(Gold), amount))
                                {
                                    this.Say(500384);                                               // Ah, art thou trying to fool me? Thou hast not so much gold!
                                    check.Delete();
                                }
                                else
                                {
                                    this.Say(1042673, AffixType.Append, amount.ToString(), "");                                               // Into your bank box I have placed a check in the amount of:
                                }
                            }
                        }

                        break;
                    }
                    }
                }
            }

            base.OnSpeech(e);
        }