public static ulong GetBalance(Mobile from, Type currencyType, out Item[] currency, out BankCheck[] checks, 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(); checks = bank.FindItemsByType <BankCheck>(true).Where(c => c.TypeOfCurrency == currencyType).ToArray(); balance = currency.Aggregate(balance, (current, t) => current + (ulong)t.Amount); balance = checks.Aggregate(balance, (current, t) => current + (ulong)t.Worth); } else { currency = new Item[0]; checks = new BankCheck[0]; credit = 0; } return(balance); }
private static void EventSink_Login(LoginEventArgs args) { Mobile from = args.Mobile; if (from.Backpack != null) { List <PlantItem> plants = from.Backpack.FindItemsByType <PlantItem>(); foreach (PlantItem plant in plants) { if (plant.IsGrowable) { plant.PlantSystem.DoGrowthCheck(); } } } BankBox bank = from.FindBankNoCreate(); if (bank != null) { List <PlantItem> plants = bank.FindItemsByType <PlantItem>(); foreach (PlantItem plant in plants) { if (plant.IsGrowable) { plant.PlantSystem.DoGrowthCheck(); } } } }
private static void EventSink_Login(LoginEventArgs args) { Mobile from = args.Mobile; if (from.Backpack != null) { Item[] plants = from.Backpack.FindItemsByType(typeof(PlantItem)); foreach (PlantItem plant in plants) { if (plant.IsGrowable) { plant.PlantSystem.DoGrowthCheck(); } } } BankBox bank = from.FindBankNoCreate(); if (bank != null) { Item[] plants = bank.FindItemsByType(typeof(PlantItem)); foreach (PlantItem plant in plants) { if (plant.IsGrowable) { plant.PlantSystem.DoGrowthCheck(); } } } //Taran: Check for plants in houses the character owns ArrayList houses = new ArrayList(2); houses.AddRange(BaseHouse.GetHouses(from)); for (int i = 0; i < houses.Count; ++i) { BaseHouse house = (BaseHouse)houses[i]; foreach (IEntity entity in house.GetHouseEntities()) { if (entity is Item && !((Item)entity).Deleted) { Item item = (Item)entity; if (item is PlantItem && item.IsLockedDown) { PlantItem plant = (PlantItem)entity; if (plant.IsGrowable) { plant.PlantSystem.DoGrowthCheck(); } } } } } }
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); }
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); }
public static bool DepositUniqueCurrency(Mobile from, Type currencyType, int amount) { BankBox bankBox = from.FindBankNoCreate(); if (bankBox == null) { return(false); } int amountRemaining = amount; Item[] currencyItems = bankBox.FindItemsByType(currencyType); foreach (Item currencyItem in currencyItems) { if (amountRemaining <= 0) { break; } //TEST: FIX PLAYERCLASS BINDING FOR CURRENCIES if ((currencyItem.Amount + amountRemaining) <= 60000) { currencyItem.Amount += amountRemaining; amountRemaining = 0; break; } else { int incrementAmount = 60000 - currencyItem.Amount; currencyItem.Amount += incrementAmount; amountRemaining -= incrementAmount; } } if (amountRemaining > 0) { int currencyStacks = (int)(Math.Floor((double)amountRemaining / 60000)) + 1; int currencyToDeposit = amountRemaining % 60000; bool unableToDropDoubloons = false; for (int a = 0; a < currencyStacks; a++) { Item currencyItem = (Item)Activator.CreateInstance(currencyType); if (currencyStacks <= 1) { currencyItem.Amount = amountRemaining; } else { if (a < (currencyStacks - 1)) { currencyItem.Amount = 60000; } else { currencyItem.Amount = currencyToDeposit; } } if (bankBox.Items.Count < bankBox.MaxItems) { bankBox.DropItem(currencyItem); } else { currencyItem.Delete(); from.SendMessage("Your bank box was too full to receive some of the currency to be deposited!"); return(false); } } } return(true); }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; TextRelay entry0 = info.GetTextEntry(0); string text0 = (entry0 == null ? "0" : entry0.Text.Trim()); BulletinBoardPost post = null; switch (info.ButtonID) { case 1: { Mobile killer = m_Killers[m_Idx]; if (killer != null && !killer.Deleted) { bool emptiedbank = false; //add kills killer.Kills++; killer.ShortTermMurders++; if (killer is PlayerMobile) { ((PlayerMobile)killer).ResetKillTime(); //do they have an existing post? post = FindPost(((PlayerMobile)killer)); //is there a bounty being set? if (balance >= Int32.Parse(text0) && Int32.Parse(text0) > 0) { //withdraw bounty from victims account bank.ConsumeTotal(typeof(Gold), Int32.Parse(text0)); //set bounty ((PlayerMobile)killer).Bounty = ((PlayerMobile)killer).Bounty + Int32.Parse(text0); //make them dread lord killer.Karma = -127; //wipe bank BankBox killerbank = killer.BankBox; if (killerbank.Items.Count > 0) { //add killers gold to his bounty killerbalance = 0; Item[] killergold; if (killerbank != null) { killergold = killerbank.FindItemsByType(typeof(Gold)); for (int i = 0; i < killergold.Length; ++i) { killerbalance += killergold[i].Amount; } killerbank.ConsumeTotal(typeof(Gold), killerbalance); ((PlayerMobile)killer).Bounty += killerbalance; killer.SendAsciiMessage("A bounty hath been issued for thee, and thy worldly goods are hereby confiscated!"); emptiedbank = true; //remove all items in the bank List <Item> list = new List <Item>(); foreach (Item item in killerbank.Items) { list.Add(item); } foreach (Item i in list) { i.Delete(); } } } //make new bounty post if (post != null) { FindEditPost(((PlayerMobile)killer), post); } else { MakePost(((PlayerMobile)killer)); } } /*if (!emptiedbank) * killer.SendAsciiMessage("You have been reported for murder!");*/ } } break; } case 2: { break; } } m_Idx++; if (m_Idx < m_Killers.Count) { from.SendGump(new ReportMurdererGump(from, m_Killers, m_Idx)); } }
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.FindBankNoCreate(); // 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.FindBankNoCreate(); //if( box != null ) // this.Say( 1042759, box.TotalGold.ToString() ); // Thy current bank balance is ~1_AMOUNT~ gold. //else // this.Say( 1042759, "0" ); // Thy current bank balance is ~1_AMOUNT~ gold. if (box != null) { Item[] coins = box.FindItemsByType(new Type[] { CurrencySystem.typeofGold, CurrencySystem.typeofVerite, CurrencySystem.typeofValorite }); int valorite = 0, verite = 0, gold = 0; for (int c = 0; c < coins.Length; c++) { if (coins[c].GetType() == CurrencySystem.typeofGold) { gold += coins[c].Amount; } else if (coins[c].GetType() == CurrencySystem.typeofVerite) { verite += coins[c].Amount; } else if (coins[c].GetType() == CurrencySystem.typeofValorite) { valorite += coins[c].Amount; } } Say(String.Format("Thy current bank balance is {0} valorite, {1} verite, and {2} gold.", valorite, verite, gold)); } else { Say("Thy bank box doth not have any coins."); } 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( 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.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; } } } if (e.Speech.ToLower().IndexOf("exchange") > -1) { BankBox box = e.Mobile.FindBankNoCreate(); if (box != null) { int cc = 0, sc = 0, gc = 0; Point3D ccLoc = Point3D.Zero, scLoc = Point3D.Zero, gcLoc = Point3D.Zero; List <BaseCoin> coins = box.FindItemsByType <BaseCoin>(); coins.ForEach( delegate(BaseCoin coin) { if (coin.GetType() == CurrencySystem.typeofGold) { cc += coin.Amount; ccLoc = coin.Location; } else if (coin.GetType() == CurrencySystem.typeofVerite) { sc += coin.Amount; scLoc = coin.Location; } else if (coin.GetType() == CurrencySystem.typeofValorite) { gc += coin.Amount; gcLoc = coin.Location; } coin.Delete(); }); int[] newAmts = CurrencySystem.Compress(cc, sc, gc); if (newAmts[0] > 0) { Gold gold = new Gold(newAmts[0]); box.AddItem(gold); gold.Location = ccLoc; } if (newAmts[1] > 0) { Verite silver = new Verite(newAmts[1]); box.DropItem(silver); silver.Location = scLoc; } if (newAmts[2] > 0) { Valorite gold = new Valorite(newAmts[2]); box.DropItem(gold); gold.Location = gcLoc; } } } } base.OnSpeech(e); }
public override void OnResponse(NetState state, int index) { Mobile from = state.Mobile; BulletinBoardPost post = null; if (index == 0) { foreach (Mobile killer in m_Killers) { //add kills killer.Kills++; killer.ShortTermMurders++; if (killer != null && !killer.Deleted) { if (killer is PlayerMobile) { ((PlayerMobile)killer).ResetKillTime(); //do they have an existing post? post = ReportMurdererGump.FindPost(((PlayerMobile)killer)); //have they killed too many? if (killer.Kills > 10) { BankBox killerbank = killer.BankBox; int killerbalance = 0; Item[] killergold; ((PlayerMobile)killer).BountyMark = true; //make them dread lord killer.Karma = -127; if (killerbank != null) { killergold = killerbank.FindItemsByType(typeof(Gold)); for (int i = 0; i < killergold.Length; ++i) { killerbalance += killergold[i].Amount; } killerbank.ConsumeTotal(typeof(Gold), killerbalance); ((PlayerMobile)killer).Bounty += killerbalance; killer.SendAsciiMessage("A bounty hath been issued for thee, and thy worldly goods are hereby confiscated!"); //remove all items in the bank List <Item> list = new List <Item>(); foreach (Item item in killerbank.Items) { list.Add(item); } foreach (Item i in list) { i.Delete(); } } //make new bounty post if (post != null) { ReportMurdererGump.FindEditPost(((PlayerMobile)killer), post); } else { ReportMurdererGump.MakePost(((PlayerMobile)killer)); } } } } } } }