public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { int playerCount = reader.ReadInt(); for (int x = 0; x < playerCount; x++) { var mobile = reader.ReadMobile(); if (mobile != null && !mobile.Deleted) { int gold = reader.ReadInt(); if (gold > 0) { Timer.DelayCall(TimeSpan.FromTicks(1), () => { var check = new BankCheck(gold); mobile.BankBox.Open(); if (!mobile.BankBox.TryDropItem(mobile, check, false)) { mobile.AddToBackpack(check); } Timer.DelayCall(TimeSpan.FromTicks(1), () => { mobile.BankBox.Close(); }); }); } } } } }
public static void Deposit(Container cont, int amount) { 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; } cont.DropItem(item); } }
private static int Partition(List <BankCheck> arr, int left, int right) { BankCheck pivot = arr[left]; while (true) { while (CompareBankCheck(arr[left], pivot) < 0) { left++; } while (CompareBankCheck(arr[right], pivot) > 0) { right--; } if (left < right) { if (arr[left] == arr[right]) { return(right); } BankCheck temp = arr[left]; arr[left] = arr[right]; arr[right] = temp; } else { return(right); } } }
public static int GetBalance(Mobile from, out Gold[] gold, out BankCheck[] checks) { int balance = 0; Container bank = from.FindBankNoCreate(); if (bank != null) { gold = bank.FindItemsByType <Gold>().ToArray(); checks = bank.FindItemsByType <BankCheck>().ToArray(); for (int i = 0; i < gold.Length; ++i) { balance += gold[i].Amount; } for (int i = 0; i < checks.Length; ++i) { balance += checks[i].Worth; } } else { gold = new Gold[0]; checks = new BankCheck[0]; } return(balance); }
public static int CompareBankCheck(BankCheck b1, BankCheck b2) { // return (String.Compare(b1.BankId, b2.BankId) == 0) ? String.Compare(b1.AccountId, b2.AccountId) : String.Compare(b1.BankId, b2.BankId); return((b1.BankId.CompareTo(b2.BankId) == 0) ? b1.AccountId.CompareTo(b2.AccountId) : b1.BankId.CompareTo(b2.BankId)); }
public override void GiveRewards() { //Random gold amount to add BankCheck gold = new BankCheck(Utility.RandomMinMax(5000, 6000)); if (!Owner.AddToBackpack(gold)) { gold.MoveToWorld(Owner.Location, Owner.Map); } //Adding Quest Reward Token(s) for (int x = 0; x < 1; x++) { RandomTalisman talisman = new RandomTalisman(); if (!Owner.AddToBackpack(talisman)) { talisman.MoveToWorld(Owner.Location, Owner.Map); } } Item bonusitem; bonusitem = new RamaRobe(); //Adding Bonus Item #1 if (!Owner.AddToBackpack(bonusitem)) { bonusitem.MoveToWorld(Owner.Location, Owner.Map); } base.GiveRewards(); }
public void SetBuyIn(PlayerMobile pm, int amount) { Item i = CheckForGoldSources(pm, amount); if (i is Gold) { i.Amount -= amount; Handeling.BuyIn += amount; } else { BankCheck check = (BankCheck)i; check.Worth -= amount; Handeling.BuyIn += amount; } if (i.Amount <= 0) { i.Delete(); return; } if (i is BankCheck) { BankCheck check = (BankCheck)i; if (check.Worth > 0) { if (check.Worth < 5000) { if (check.Parent is BankBox) { BankBox box = (BankBox)check.Parent; Gold g = new Gold(check.Worth); box.DropItem(g); check.Delete(); } if (check.Parent is Backpack) { Backpack pack = (Backpack)check.Parent; Gold g = new Gold(check.Worth); pack.DropItem(g); check.Delete(); } } } else { check.Delete(); } } pm.SendMessage("The funds have been gathered."); }
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; }
public static void SalaryPayment() { ArrayList payment = new ArrayList(); foreach (Item item in World.Items.Values) { if (item is SalaryChest) { payment.Add(item); } } foreach (Item item in payment) { SalaryChest chest = item as SalaryChest; if (!chest.Active) { continue; } if (chest.Employer == null || chest.Employer.AccessLevel >= AccessLevel.GameMaster) { Item check = chest.FindItemByType(typeof(BankCheck)); if (check != null) { BankCheck dropcheck = check as BankCheck; dropcheck.Worth += chest.Salary; } else { chest.DropItem(new BankCheck(chest.Salary)); } } else { Container cont = chest.Employer.FindBankNoCreate(); if (cont != null && Banker.Withdraw(chest.Employer, chest.Salary)) { Item check = chest.FindItemByType(typeof(BankCheck)); if (check != null) { BankCheck dropcheck = check as BankCheck; dropcheck.Worth += chest.Salary; } else { chest.DropItem(new BankCheck(chest.Salary)); } } else { chest.Active = false; } } } }
private static void getGold(string charUID, Mobile pm) { int amount = 0; // montants d'or int bankboxAmount = 0; string backpack = getPlayerItemSerial(charUID, SphereFiles.backFile); // sac du joueur string bankbox = getPlayerItemSerial(charUID, SphereFiles.bankFile); // banque du joueur // On parcourt le fichier qui contient tous les enregistrements d'or foreach (string line in File.ReadAllLines(SphereFiles.goldFile)) { if (line.StartsWith("AMOUNT=")) { amount = Int32.Parse(line.Split('=')[1]); } if (amount > 0 && line.StartsWith("CONT=") && line.Split('=')[1] == backpack) { Item gold = new Gold(amount); Container pack = pm.Backpack; if (pack != null) { pack.DropItem(gold); } else { gold.Delete(); } amount = 0; } else if (amount > 0 && line.StartsWith("CONT=") && line.Split('=')[1] == bankbox) { bankboxAmount += amount; amount = 0; //Item gold = new Gold(amount); //Container bank = pm.BankBox; //if (bank != null) // bank.DropItem(gold); //else // gold.Delete(); } } if (bankboxAmount > 0) { Container bank = pm.BankBox; if (bank != null) { BankCheck check = new BankCheck(bankboxAmount); check.Name = "Or Banque"; bank.DropItem(check); } } bankboxAmount = 0; }
public static bool Withdraw(Mobile from, int amount, bool message = false) { // If for whatever reason the TOL checks fail, we should still try old methods for withdrawing currency. if (AccountGold.Enabled && from.Account != null && from.Account.WithdrawGold(amount)) { if (message) { from.SendLocalizedMessage(1155856, amount.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US"))); // ~1_AMOUNT~ gold has been removed from your bank box. } return(true); } Item[] gold, checks; int balance = GetBalance(from, out gold, out checks); if (balance < amount) { return(false); } for (int i = 0; amount > 0 && i < gold.Length; ++i) { if (gold[i].Amount <= amount) { amount -= gold[i].Amount; gold[i].Delete(); } else { gold[i].Amount -= amount; amount = 0; } } for (int i = 0; amount > 0 && i < checks.Length; ++i) { BankCheck check = (BankCheck)checks[i]; if (check.Worth <= amount) { amount -= check.Worth; check.Delete(); } else { check.Worth -= amount; amount = 0; } } if (message) { from.SendLocalizedMessage(1155856, amount.ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US"))); // ~1_AMOUNT~ gold has been removed from your bank box. } return(true); }
public static int DepositUpTo(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(amount); } var box = from.Player ? from.BankBox : 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); }
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); }
public static bool WithdrawPackAndBank(Mobile from, Type currencyType, int amount) { ulong totalCurrency = 0; Item[] packCurrency; Item[] bankCurrency; BankCheck[] bankChecks; ulong credit; if (from.Backpack != null) { packCurrency = from.Backpack.FindItemsByType(currencyType, true).ToArray(); totalCurrency = packCurrency.Aggregate(totalCurrency, (current, t) => current + (ulong)t.Amount); } else { packCurrency = new Item[0]; } if (totalCurrency < (ulong)amount) { totalCurrency += GetBalance(from, currencyType, out bankCurrency, out bankChecks, out credit); } else { bankCurrency = new Item[0]; bankChecks = new BankCheck[0]; credit = 0; } if (amount > 0) { if (totalCurrency >= (ulong)amount) { for (int i = 0; amount > 0 && i < packCurrency.Length; ++i) { int consume = Math.Min(packCurrency[i].Amount, amount); packCurrency[i].Consume(consume); amount -= consume; } if (amount > 0) { WithdrawUpTo(from, amount, bankCurrency, bankChecks, credit); } return(true); } return(false); } return(true); }
public override void GiveRewards() { //Random gold amount to add BankCheck gold = new BankCheck(Utility.RandomMinMax(200, 300)); if (!Owner.AddToBackpack(gold)) { gold.MoveToWorld(Owner.Location, Owner.Map); } //Adding Quest Reward Token(s) for (int x = 0; x < 1; x++) { RandomTalisman talisman = new RandomTalisman(); if (!Owner.AddToBackpack(talisman)) { talisman.MoveToWorld(Owner.Location, Owner.Map); } } Item bonusitem; bonusitem = new Bandage(10); //Adding Bonus Item #1 if (!Owner.AddToBackpack(bonusitem)) { bonusitem.MoveToWorld(Owner.Location, Owner.Map); } Item item; //Add Reward Item #1 item = new AdventurersMachete(); if (item is BaseWeapon) { BaseRunicTool.ApplyAttributesTo((BaseWeapon)item, Utility.RandomMinMax(1, 4), 10, 50); } if (item is BaseArmor) { BaseRunicTool.ApplyAttributesTo((BaseArmor)item, Utility.RandomMinMax(1, 4), 10, 50); } if (item is BaseJewel) { BaseRunicTool.ApplyAttributesTo((BaseJewel)item, Utility.RandomMinMax(1, 4), 10, 50); } if (item is BaseHat) { BaseRunicTool.ApplyAttributesTo((BaseHat)item, Utility.RandomMinMax(1, 4), 10, 50); } if (!Owner.AddToBackpack(item)) { item.MoveToWorld(Owner.Location, Owner.Map); } base.GiveRewards(); }
public override void GiveRewards() { //Give Gold to player in form of a bank check BankCheck gold = new BankCheck(Utility.RandomMinMax(500, 1000)); if (!Owner.AddToBackpack(gold)) { gold.MoveToWorld(Owner.Location, Owner.Map); } base.GiveRewards(); }
public override void GiveRewards() { //Random gold amount to add BankCheck gold = new BankCheck(Utility.RandomMinMax(100, 150)); if (!Owner.AddToBackpack(gold)) { gold.MoveToWorld(Owner.Location, Owner.Map); } base.GiveRewards(); }
public Item CheckForGoldSources(PlayerMobile pm, int amount) { List <Gold> gold_piles = new List <Gold>(); List <BankCheck> checks = new List <BankCheck>(); Backpack pack = (Backpack)pm.Backpack; BankBox bank = (BankBox)pm.BankBox; foreach (Item i in pack.Items) { if (i is Gold) { gold_piles.Add((Gold)i); } else if (i is BankCheck) { checks.Add((BankCheck)i); } } foreach (Item i in bank.Items) { if (i is Gold) { gold_piles.Add((Gold)i); } else if (i is BankCheck) { checks.Add((BankCheck)i); } } for (int i = 0; i < gold_piles.Count; ++i) { Gold gold = (Gold)gold_piles[i]; if (gold.Amount >= amount) { return(gold); } } for (int i = 0; i < checks.Count; ++i) { BankCheck check = (BankCheck)checks[i]; if (check.Worth >= amount) { return(check); } } return(null); }
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.Player ? from.BankBox : 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); }
public bool AddGoldCheck(BankCheck check) { if (!GoldLedger) { return(false); } check.Worth = (int)AddGoldAmount((ulong)check.Worth); if (check.Worth == 0) { check.Consume(); return(true); } return(false); }
public void PayBuyIn(PlayerMobile pm, int teamid) { if (Handeling.BuyIn <= 0) { return; } int playercount = 0; int sharecount = 0; IEnumerator key = Handeling.Teams.Keys.GetEnumerator(); for (int i = 0; i < Handeling.Teams.Count; ++i) { key.MoveNext(); Field_Team d_team = (Field_Team)Handeling.Teams[(int)key.Current]; for (int i2 = 0; i2 < d_team.Players.Count; ++i2) { object o = (object)d_team.Players[i2]; if (o != "@null") { playercount += 1; } if ((int)key.Current == teamid && o != "@null") { sharecount += 1; } } } int goldshare = (playercount * Handeling.BuyIn) / sharecount; BankBox box = (BankBox)pm.BankBox; if (goldshare >= 5000) { BankCheck check = new BankCheck(goldshare); box.DropItem(check); } else { Gold gold = new Gold(goldshare); box.DropItem(gold); } pm.SendMessage(String.Format("Congragulations! you have won {0}gp.", goldshare.ToString())); }
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); }
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); }
public static void CashCheck(Mobile from, BankCheck check) { BankBox box = from.BankBox; if (box != null) { int deposited = 0; int toAdd = check.Worth; check.Delete(); 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)); } } } }
public static bool Withdraw(Mobile from, int amount) { Item[] gold, checks; int balance = GetBalance(from, out gold, out checks); if (balance < amount) { return(false); } for (int i = 0; amount > 0 && i < gold.Length; ++i) { if (gold[i].Amount <= amount) { amount -= gold[i].Amount; gold[i].Delete(); } else { gold[i].Amount -= amount; amount = 0; } } for (int i = 0; amount > 0 && i < checks.Length; ++i) { BankCheck check = (BankCheck)checks[i]; if (check.Worth <= amount) { amount -= check.Worth; check.Delete(); } else { check.Worth -= amount; amount = 0; // cash this check - don't leave tiny checks in the users bank if (check.Worth < 5000) { CashCheck(from, check); } } } return(true); }
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); }
public virtual void AwardWinnings(Mobile m, int amount) { if (m == null) { return; } if (m.Backpack != null && amount > 0) { // give them a check for the winnings BankCheck check = new BankCheck(amount); check.Name = String.Format(XmlPoints.GetText(m, 100300), ChallengeName); // "Prize from {0}" m.AddToBackpack(check); XmlPoints.SendText(m, 100301, amount); // "You have received a bank check for {0}" } }
public static bool Withdraw(Mobile from, int amount) { Item[] gold, checks; int balance = GetBalance(from, out gold, out checks); if (balance < amount && Arya.Savings.SavingsAccount.BalanceGold(from) < amount - balance) { return(false); } for (int i = 0; amount > 0 && i < gold.Length; ++i) { if (gold[i].Amount <= amount) { amount -= gold[i].Amount; gold[i].Delete(); } else { gold[i].Amount -= amount; amount = 0; } } for (int i = 0; amount > 0 && i < checks.Length; ++i) { BankCheck check = (BankCheck)checks[i]; if (check.Worth <= amount) { amount -= check.Worth; check.Delete(); } else { check.Worth -= amount; amount = 0; } } if (amount > 0) { Arya.Savings.SavingsAccount.WithdrawGold(from, amount); } return(true); }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { m_Mobile.Frozen = false; int ButtonID = info.ButtonID; switch (ButtonID) { case 1: { int amount = Utility.ToInt32(info.GetTextEntry(1).Text); if (amount > 0) { if (m_Mobile.BankBox.TotalGold >= amount) { if (amount > 5000) { BankCheck bc = new BankCheck(amount); m_Mobile.Backpack.DropItem(bc); m_Mobile.SendMessage(Locale.GetLocale(m_Mobile).BANK_STONE_WITHDRAW_GOT_CHEQUE, amount); } else { Gold g = new Gold(amount); m_Mobile.Backpack.DropItem(g); m_Mobile.SendMessage(Locale.GetLocale(m_Mobile).BANK_STONE_WITHDRAW_GOT_GOLD, amount); } } else { m_Mobile.SendMessage(Locale.GetLocale(m_Mobile).BANK_STONE_WITHDRAW_NOT_ENOUGH); } } else { m_Mobile.SendMessage(Locale.GetLocale(m_Mobile).BANK_STONE_WITHDRAW_INVALID); } break; } } }
private static int GetGoldInContainer(Container c) { int iGold = 0; Item[] golds = c.FindItemsByType(typeof(Gold), true); foreach (Item g in golds) { iGold += g.Amount; } Item[] checks = c.FindItemsByType(typeof(BankCheck), true); foreach (Item i in checks) { BankCheck bc = (BankCheck)i; iGold += bc.Worth; } return(iGold); }
private void PayWinning(Mobile player, int amount) { int amountToGive = amount; if (amount > m_Machine.GoldInMachine) { amountToGive = m_Machine.GoldInMachine; m_Machine.GoldInMachine = 0; } else m_Machine.GoldInMachine -= amountToGive; if (!Banker.Deposit(player, amountToGive)) { while ( amountToGive > 0 ) { Item item; if ( amountToGive <= 1000000 ) { item = new BankCheck( amountToGive ); amountToGive = 0; } else { item = new BankCheck( 1000000 ); amountToGive -= 1000000; } player.AddToBackpack(item); } player.SendMessage("Your bank box is full, so your reward has been added your backpack. Please clear some room in your bank"); } Effects.PlaySound(m_Machine.Location, m_Machine.Map, 0x36); // Coin Sound }