Exemplo n.º 1
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            Mobile m = e.Mobile;

            if (XmlScript.HasTrigger(this, TriggerName.onSpeech) &&
                UberScriptTriggers.Trigger(this, e.Mobile, TriggerName.onSpeech, null, e.Speech))
            {
                return;
            }

            if (!e.Handled && m.InRange(Location, 12))
            {
                string speech = e.Speech.Trim().ToLower();

                if (e.HasKeyword(0x00))                 // *withdraw*
                {
                    e.Handled = true;

                    if (!CheckVendorAccess(m))
                    {
                        Say(500389);                         // I will not do business with a criminal!
                    }
                    else
                    {
                        string[] split = e.Speech.Split(' ');

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

                            Container pack = m.Backpack;

                            if (Int32.TryParse(split[1], out amount))
                            {
                                if (amount > 60000)
                                {
                                    Say(500381);                                     // Thou canst not withdraw so much at one time!
                                }
                                else if (amount > 0)
                                {
                                    BankBox box = m.FindBankNoCreate();

                                    if (box == null || !WithdrawCredit(m, TypeOfCurrency, amount))
                                    {
                                        Say("Ah, art thou trying to fool me? Thou hast not so much {0}!", TypeOfCurrency.Name);
                                    }
                                    else
                                    {
                                        Item currency = TypeOfCurrency.CreateInstanceSafe <Item>();

                                        currency.Stackable = true;
                                        currency.Amount    = amount;

                                        if (pack != null && !pack.Deleted && pack.TryDropItem(m, currency, false))
                                        {
                                            Say("Thou hast withdrawn {0} from thy account.", TypeOfCurrency.Name);
                                            //Say(1010005); // Thou hast withdrawn gold from thy account.
                                        }
                                        else
                                        {
                                            currency.Delete();

                                            box.Credit += (ulong)amount;

                                            Say(1048147);                                             // Your backpack can't hold anything else.
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if (e.HasKeyword(0x01))                 // *balance*
                {
                    e.Handled = true;

                    if (!CheckVendorAccess(m))
                    {
                        Say(500389);                         // I will not do business with a criminal!
                    }
                    else
                    {
                        BankBox box = m.FindBankNoCreate();

                        if (box != null)
                        {
                            Say("Thy current bank balance is {0:#,0} {1}.", (ulong)GetBalance(m, TypeOfCurrency) + box.Credit, TypeOfCurrency.Name);
                        }
                        else
                        {
                            Say("Thy current bank balance is 0 {0}.", TypeOfCurrency.Name);
                        }
                    }
                }
                else if (e.HasKeyword(0x02))                 // *bank*
                {
                    e.Handled = true;

                    if (!CheckVendorAccess(m))
                    {
                        Say(500378);                         // Thou art a criminal and cannot access thy bank box.
                    }
                    else
                    {
                        m.BankBox.Open();
                    }
                }
                else if (e.HasKeyword(0x03))                 // *check*
                {
                    e.Handled = true;

                    if (!CheckVendorAccess(m))
                    {
                        Say(500389);                         // I will not do business with a criminal!
                    }
                    else
                    {
                        string[] split = e.Speech.Split(' ');

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

                            if (int.TryParse(split[1], out amount))
                            {
                                if (amount < 5000)
                                {
                                    Say("We cannot create checks for such a paltry amount of {0}!", TypeOfCurrency.Name);
                                    //Say(1010006); // We cannot create checks for such a paltry amount of gold!
                                }
                                else if (amount > 1000000)
                                {
                                    Say(1010007);                                     // Our policies prevent us from creating checks worth that much!
                                }
                                else
                                {
                                    var check = new BankCheck(amount);

                                    BankBox box = m.BankBox;

                                    if (!box.TryDropItem(m, check, false))
                                    {
                                        Say(500386);                                         // There's not enough room in your bankbox for the check!
                                        check.Delete();
                                    }
                                    else if (!WithdrawCredit(m, TypeOfCurrency, amount))
                                    {
                                        Say("Ah, art thou trying to fool me? Thou hast not so much {0}!", TypeOfCurrency.Name);
                                        //Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold!
                                        check.Delete();
                                    }
                                    else
                                    {
                                        // Into your bank box I have placed a check in the amount of:
                                        Say(1042673, AffixType.Append, Utility.MoneyFormat(amount, m), "");
                                    }
                                }
                            }
                        }
                    }
                }
                else if (speech.IndexOf("deposit", StringComparison.Ordinal) > -1 || speech.IndexOf("credit", StringComparison.Ordinal) > -1)
                {
                    e.Handled = true;

                    if (!CheckVendorAccess(m))
                    {
                        Say(500389);                         // I will not do business with a criminal!
                    }
                    else
                    {
                        BankBox box = m.FindBankNoCreate();

                        if (box == null || box.Items.Count == 0)
                        {
                            Say("Ah, art thou trying to fool me? Thou hast nothing to deposit!");
                        }
                        else
                        {
                            Item[]      currency = box.FindItemsByType(TypeOfCurrency, true).ToArray();
                            BankCheck[] checks   = box.FindItemsByType <BankCheck>(true).ToArray();

                            foreach (Item c in currency)
                            {
                                ulong amount = Math.Min(box.Credit + (ulong)c.Amount, BankBox.MaxCredit);
                                c.Consume((int)(amount - box.Credit));
                                box.Credit = amount;
                            }

                            foreach (BankCheck c in checks)
                            {
                                ulong amount = Math.Min(box.Credit + (ulong)c.Worth, BankBox.MaxCredit);
                                c.ConsumeWorth((int)(amount - box.Credit));

                                box.Credit = amount;
                            }

                            Say(
                                box.Credit == BankBox.MaxCredit
                                                                        ? "You have reached the maximum limit.  We do not have the facilities to deposit more {0} and bank checks."
                                                                        : "I have deposited all of the {0} and bank checks from your bank box.",
                                TypeOfCurrency.Name);

                            Say("You currently have {0:#,0} {1} stored in credit.", box.Credit, TypeOfCurrency.Name);
                        }
                    }
                }
            }

            base.OnSpeech(e);
        }
Exemplo n.º 2
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.
            }
        }