public override bool OnCopperGiven(Mobile from, Copper dropped) { if (from is PlayerMobile && dropped.Amount == JoinCost) { PlayerMobile pm = (PlayerMobile)from; if (pm.NpcGuild == this.NpcGuild) { SayTo(from, 501047); // Thou art already a member of our guild. } else if (pm.NpcGuild != NpcGuild.None) { SayTo(from, 501046); // Thou must resign from thy other guild first. } else if (pm.GameTime < JoinGameAge || (pm.CreationTime + JoinAge) > DateTime.Now) { SayTo(from, 501048); // You are too young to join my guild... } else if (CheckCustomReqs(pm)) { SayWelcomeTo(from); pm.NpcGuild = this.NpcGuild; pm.NpcGuildJoinTime = DateTime.Now; pm.NpcGuildGameTime = pm.GameTime; dropped.Delete(); return(true); } return(false); } return(base.OnCopperGiven(from, dropped)); }
public override bool OnCopperGiven(Mobile from, Copper dropped) { string message = "Are you trying to bribe me to win?"; this.Say(message); return(false); }
public void ExpireContract() { BankBox box = m_Issuer.BankBox; if (box != null) { Delete(); int deposited = 0; int toAdd = m_Copper; Copper copper; while (toAdd > 60000) { copper = new Copper(60000); if (box.TryDropItem(m_Issuer, copper, false)) { toAdd -= 60000; deposited += 60000; } else { copper.Delete(); m_Issuer.AddToBackpack(new BankCheck(toAdd)); toAdd = 0; break; } } if (toAdd > 0) { copper = new Copper(toAdd); if (box.TryDropItem(m_Issuer, copper, false)) { deposited += toAdd; } else { copper.Delete(); m_Issuer.AddToBackpack(new BankCheck(toAdd)); } } // Gold was deposited in your account: m_Issuer.SendLocalizedMessage(1042672, true, " " + deposited.ToString()); } /*else * { * //from.SendLocalizedMessage( 1047026 ); // That must be in your bank box to use it. * }*/ }
public string ToString(IFormatProvider provider) { return (Platinum.ToString(provider) + "p " + Gold.ToString(provider) + "g " + Silver.ToString(provider) + "s " + Copper.ToString(provider) + "c"); }
public void TestMethod1() { IMaterial material1 = new Iron(); IWeapon weapon1 = new SwortManufacture(material1).Manufacture(); IMaterial material2 = new Copper(); IWeapon weapon2 = new SwortManufacture(material2).Manufacture(); }
public override void OnDoubleClick(Mobile from) { BankBox box = from.FindBankNoCreate(); if (box != null && IsChildOf(box)) { Delete(); int deposited = 0; int toAdd = m_Worth; Copper copper; while (toAdd > 60000) { copper = new Copper(60000); if (box.TryDropItem(from, copper, false)) { toAdd -= 60000; deposited += 60000; } else { copper.Delete(); from.AddToBackpack(new BankCheck(toAdd)); toAdd = 0; break; } } if (toAdd > 0) { copper = new Copper(toAdd); if (box.TryDropItem(from, copper, false)) { deposited += toAdd; } else { copper.Delete(); from.AddToBackpack(new BankCheck(toAdd)); } } // Gold was deposited in your account: from.SendLocalizedMessage(1042672, true, " " + deposited.ToString()); } else { from.SendLocalizedMessage(1047026); // That must be in your bank box to use it. } }
public static List <Card> VictoryAndTreasures() { return(new List <Card> { Copper.Get(), Silver.Get(), Gold.Get(), Estate.Get(), Duchy.Get(), Province.Get() }); }
private static List <Pile> VictoryAndTreasures(bool two) { return(new List <Pile> { new Pile(Copper.Get(), 60), new Pile(Silver.Get(), 40), new Pile(Gold.Get(), 30), new Pile(Estate.Get(), two ? 8 : 12), new Pile(Duchy.Get(), two ? 8 : 12), new Pile(Province.Get(), two ? 8 : 12) }); }
/**<summary>Saves the xml to be modified for use in Terraria.</summary>*/ public static void SaveXmlConfiguration() { try { string configPath = Path.Combine(Patcher.ExeDirectory, CoinReplacer.ConfigName); XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null)); XmlElement replacer = doc.CreateElement("RupeeReplacer"); doc.AppendChild(replacer); XmlElement element = doc.CreateElement("CopperCoin"); element.SetAttribute("Color", Copper.ToString()); replacer.AppendChild(element); element = doc.CreateElement("SilverCoin"); element.SetAttribute("Color", Silver.ToString()); replacer.AppendChild(element); element = doc.CreateElement("GoldCoin"); element.SetAttribute("Color", Gold.ToString()); replacer.AppendChild(element); element = doc.CreateElement("PlatinumCoin"); element.SetAttribute("Color", Platinum.ToString()); replacer.AppendChild(element); element = doc.CreateElement("CoinGun"); element.SetAttribute("Enabled", CoinGun.ToString()); replacer.AppendChild(element); element = doc.CreateElement("LuckyCoin"); element.SetAttribute("Enabled", LuckyCoin.ToString()); replacer.AppendChild(element); element = doc.CreateElement("CoinRing"); element.SetAttribute("Enabled", CoinRing.ToString()); replacer.AppendChild(element); element = doc.CreateElement("CoinPortal"); element.SetAttribute("Enabled", CoinPortal.ToString()); replacer.AppendChild(element); doc.Save(configPath); } catch (Exception ex) { throw new Exception("Failed to save " + CoinReplacer.ConfigName, ex); } }
public int GetAmount() { int amount = Copper.GetValueOrDefault(); if (Silver.HasValue) { amount += (Silver.Value * 100); } if (Gold.HasValue) { amount += (Gold.Value * 100 * 100); } return(amount); }
public override bool OnCopperGiven(Mobile from, Copper dropped) { if (from is PlayerMobile && dropped.Amount == 700) { PlayerMobile pm = (PlayerMobile)from; if (pm.NpcGuild == NpcGuild.ThievesGuild) { from.AddToBackpack(new DisguiseKit()); dropped.Delete(); return(true); } } return(base.OnCopperGiven(from, dropped)); }
public static bool Deposit( Mobile from, int amount ) { BankBox box = from.BankBox; if ( box == null ) return false; ArrayList items = new ArrayList(); while ( amount > 0 ) { Item item; if ( amount < 5000 ) { item = new Copper( 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 override void GenerateResources() { Random rnd = new Random(); //Si pas de ressource, on regenère de 0 if (Resources.Count == 0) { Wood w = new Wood(rnd.Next(0, 10)); base.Resources.Add(w); Stone s = new Stone(rnd.Next(0, 30)); base.Resources.Add(s); Water wa = new Water(rnd.Next(0, 10)); base.Resources.Add(wa); Coal co = new Coal(rnd.Next(0, 30)); base.Resources.Add(co); Copper cop = new Copper(rnd.Next(0, 30)); base.Resources.Add(cop); Gold go = new Gold(rnd.Next(0, 5)); base.Resources.Add(go); Iron ir = new Iron(rnd.Next(0, 30)); base.Resources.Add(ir); Silver si = new Silver(rnd.Next(0, 10)); base.Resources.Add(si); } else { foreach (Resource r in Resources) { r.Quantity += r.Quantity / 2; } } }
public static GameObject BuildGameObject(XmlElement element) { string type = element.GetAttribute("type"); switch (type) { case "money": return(Money.Build(element)); case "wood": return(Wood.Build(element)); case "weapon": return(Weapon.Build(element)); case "coal": return(Coal.Build(element)); case "copper": return(Copper.Build(element)); case "gold": return(Gold.Build(element)); case "iron": return(Iron.Build(element)); case "silver": return(Silver.Build(element)); case "leather": return(Leather.Build(element)); case "meat": return(Meat.Build(element)); case "sand": return(Sand.Build(element)); case "stone": return(Stone.Build(element)); case "water": return(Water.Build(element)); case "wheat": return(Wheat.Build(element)); default: return(null); } }
//GOVERNMENT protected virtual void OnRentPaid() { if( AssignTreasury() ) { Copper copper = new Copper(); copper.Amount = Price; if( Treasury is BaseContainer ) ( (BaseContainer)Treasury ).DropAndStack( copper ); } }
public static int DepositUpTo( Mobile from, int amount ) { BankBox box = from.BankBox; if ( box == null ) return 0; int amountLeft = amount; while ( amountLeft > 0 ) { Item item; int amountGiven; if ( amountLeft < 5000 ) { item = new Copper( 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; }
private void UpdateAmount() { StringsToCurrency(Gold.ToString(), Silver.ToString(), Copper.ToString()); }
protected override void OnTick() { m_AContract.m_TimeLeft = m_AContract.m_TimeLeft - 1; if (m_AContract.m_TimeLeft > 0) { if (m_AContract.m_Debug == true) { m_ContractTimer = new ExpireContractDebugTimer(m_AContract.m_TimeLeft, m_AContract); } else { m_ContractTimer = new ExpireContractTimer(m_AContract.m_TimeLeft, m_AContract); } m_ContractTimer.Start(); } else { if (m_AContract.m_Issuer != null) { BankBox box = m_AContract.m_Issuer.BankBox; if (box != null) { int deposited = 0; int toAdd = m_AContract.m_Copper; Copper copper; while (toAdd > 60000) { copper = new Copper(60000); if (box.TryDropItem(m_AContract.m_Issuer, copper, false)) { toAdd -= 60000; deposited += 60000; } else { copper.Delete(); m_AContract.m_Issuer.AddToBackpack(new BankCheck(toAdd)); toAdd = 0; break; } } if (toAdd > 0) { copper = new Copper(toAdd); if (box.TryDropItem(m_AContract.m_Issuer, copper, false)) { deposited += toAdd; } else { copper.Delete(); m_AContract.m_Issuer.AddToBackpack(new BankCheck(toAdd)); } } // Gold was deposited in your account: m_AContract.m_Issuer.SendLocalizedMessage(1042672, true, " " + deposited.ToString()); } /*else * { * //from.SendLocalizedMessage( 1047026 ); // That must be in your bank box to use it. * }*/ } m_AContract.m_Expired = true; } }
public override void OnDoubleClick( Mobile from ) { if( from == null || !from.InRange( this.Location, 2 ) || !from.InLOS( this.Location ) || !from.Alive || from.Paralyzed ) { from.SendMessage( "You are too far away." ); return; } if( m_Owner == null ) { bool haschest = false; foreach( Item item in from.GetItemsInRange( 10 ) ) { if( item is BaseStorageContainer ) { BaseStorageContainer cont = item as BaseStorageContainer; if( cont.Owner == from ) haschest = true; } } if( haschest ) { from.SendMessage( "You already have a storage box in this area." ); return; } Container pack = from.Backpack; if ( !pack.ConsumeTotal( typeof( Copper ), m_Price ) ) { from.SendMessage( "You need to be carrying " + m_Price + " copper coins in order to purchase this storage box." ); } else { m_Owner = from; m_OwnersName = from.Name; if( m_OwnersName.EndsWith( "s" ) ) m_OwnersName = m_OwnersName + "'"; else m_OwnersName = m_OwnersName + "'s"; this.Name = "" + m_OwnersName + " Storage Box"; Key key = new Key(); uint newlock = Key.RandomValue(); this.KeyValue = newlock; this.Locked = true; key.KeyValue = newlock; pack.DropItem( key ); this.LastRent = DateTime.Now; from.SendMessage( "A key to the storage box has been placed in your backpack and " + m_Price + " copper coins have been charged from you." ); Copper copper = new Copper( m_Price ); if( this.Nation != Nation.None && this.AssignTreasury() ) { if( this.Treasury is BaseContainer ) ( (BaseContainer)this.Treasury ).DropAndStack( copper ); } } } else base.OnDoubleClick( from ); }
public virtual bool CheckAtDestination() { EDI dest = GetDestination(); if (dest == null) { return(false); } Mobile escorter = GetEscorter(); if (escorter == null) { return(false); } if (dest.Contains(Location)) { Say(1042809, escorter.Name); // We have arrived! I thank thee, ~1_PLAYER_NAME~! I have no further need of thy services. Here is thy pay. // not going anywhere m_Destination = null; m_DestinationString = null; Container cont = escorter.Backpack; if (cont == null) { cont = escorter.BankBox; } Copper cc = new Copper(90, 180); if (!cont.TryDropItem(escorter, cc, false)) { cc.MoveToWorld(escorter.Location, escorter.Map); } StopFollow(); SetControlMaster(null); m_EscortTable.Remove(escorter); BeginDelete(); Misc.Titles.AwardFame(escorter, 10, true); bool gainedPath = false; PlayerMobile pm = escorter as PlayerMobile; if (pm != null) { if (pm.CompassionGains > 0 && DateTime.Now > pm.NextCompassionDay) { pm.NextCompassionDay = DateTime.MinValue; pm.CompassionGains = 0; } if (pm.CompassionGains >= 5) // have already gained 5 times in one day, can gain no more { pm.SendLocalizedMessage(1053004); // You must wait about a day before you can gain in compassion again. } else if (VirtueHelper.Award(pm, VirtueName.Compassion, 200, ref gainedPath)) { if (gainedPath) { pm.SendLocalizedMessage(1053005); // You have achieved a path in compassion! } else { pm.SendLocalizedMessage(1053002); // You have gained in compassion. } pm.NextCompassionDay = DateTime.Now + TimeSpan.FromDays(1.0); // in one day CompassionGains gets reset to 0 ++pm.CompassionGains; } else { pm.SendLocalizedMessage(1053003); // You have achieved the highest path of compassion and can no longer gain any further. } } return(true); } return(false); }
public void TestPrintElectronShellCfg_All() { IElement testSubject;; testSubject = new Hydrogen(); Console.WriteLine($"Hydrogen {testSubject.PrintElectronShellCfg()}"); testSubject = new Helium(); Console.WriteLine($"Helium {testSubject.PrintElectronShellCfg()}"); testSubject = new Lithium(); Console.WriteLine($"Lithium {testSubject.PrintElectronShellCfg()}"); testSubject = new Beryllium(); Console.WriteLine($"Beryllium {testSubject.PrintElectronShellCfg()}"); testSubject = new Boron(); Console.WriteLine($"Boron {testSubject.PrintElectronShellCfg()}"); testSubject = new Carbon(); Console.WriteLine($"Carbon {testSubject.PrintElectronShellCfg()}"); testSubject = new Nitrogen(); Console.WriteLine($"Nitrogen {testSubject.PrintElectronShellCfg()}"); testSubject = new Oxygen(); Console.WriteLine($"Oxygen {testSubject.PrintElectronShellCfg()}"); testSubject = new Fluorine(); Console.WriteLine($"Fluorine {testSubject.PrintElectronShellCfg()}"); testSubject = new Neon(); Console.WriteLine($"Neon {testSubject.PrintElectronShellCfg()}"); testSubject = new Sodium(); Console.WriteLine($"Sodium {testSubject.PrintElectronShellCfg()}"); testSubject = new Magnesium(); Console.WriteLine($"Magnesium {testSubject.PrintElectronShellCfg()}"); testSubject = new Aluminum(); Console.WriteLine($"Aluminum {testSubject.PrintElectronShellCfg()}"); testSubject = new Silicon(); Console.WriteLine($"Silicon {testSubject.PrintElectronShellCfg()}"); testSubject = new Phosphorus(); Console.WriteLine($"Phosphorus {testSubject.PrintElectronShellCfg()}"); testSubject = new Sulfur(); Console.WriteLine($"Sulfur {testSubject.PrintElectronShellCfg()}"); testSubject = new Chlorine(); Console.WriteLine($"Chlorine {testSubject.PrintElectronShellCfg()}"); testSubject = new Argon(); Console.WriteLine($"Argon {testSubject.PrintElectronShellCfg()}"); testSubject = new Potassium(); Console.WriteLine($"Potassium {testSubject.PrintElectronShellCfg()}"); testSubject = new Calcium(); Console.WriteLine($"Calcium {testSubject.PrintElectronShellCfg()}"); testSubject = new Scandium(); Console.WriteLine($"Scandium {testSubject.PrintElectronShellCfg()}"); testSubject = new Titanium(); Console.WriteLine($"Titanium {testSubject.PrintElectronShellCfg()}"); testSubject = new Vanadium(); Console.WriteLine($"Vanadium {testSubject.PrintElectronShellCfg()}"); testSubject = new Chromium(); Console.WriteLine($"Chromium {testSubject.PrintElectronShellCfg()}"); testSubject = new Manganese(); Console.WriteLine($"Manganese {testSubject.PrintElectronShellCfg()}"); testSubject = new Iron(); Console.WriteLine($"Iron {testSubject.PrintElectronShellCfg()}"); testSubject = new Cobalt(); Console.WriteLine($"Cobalt {testSubject.PrintElectronShellCfg()}"); testSubject = new Nickel(); Console.WriteLine($"Nickel {testSubject.PrintElectronShellCfg()}"); testSubject = new Copper(); Console.WriteLine($"Copper {testSubject.PrintElectronShellCfg()}"); testSubject = new Zinc(); Console.WriteLine($"Zinc {testSubject.PrintElectronShellCfg()}"); testSubject = new Gallium(); Console.WriteLine($"Gallium {testSubject.PrintElectronShellCfg()}"); testSubject = new Germanium(); Console.WriteLine($"Germanium {testSubject.PrintElectronShellCfg()}"); testSubject = new Arsenic(); Console.WriteLine($"Arsenic {testSubject.PrintElectronShellCfg()}"); testSubject = new Selenium(); Console.WriteLine($"Selenium {testSubject.PrintElectronShellCfg()}"); testSubject = new Bromine(); Console.WriteLine($"Bromine {testSubject.PrintElectronShellCfg()}"); testSubject = new Krypton(); Console.WriteLine($"Krypton {testSubject.PrintElectronShellCfg()}"); testSubject = new Rubidium(); Console.WriteLine($"Rubidium {testSubject.PrintElectronShellCfg()}"); testSubject = new Strontium(); Console.WriteLine($"Strontium {testSubject.PrintElectronShellCfg()}"); testSubject = new Yttrium(); Console.WriteLine($"Yttrium {testSubject.PrintElectronShellCfg()}"); testSubject = new Zirconium(); Console.WriteLine($"Zirconium {testSubject.PrintElectronShellCfg()}"); testSubject = new Niobium(); Console.WriteLine($"Niobium {testSubject.PrintElectronShellCfg()}"); testSubject = new Molybdenum(); Console.WriteLine($"Molybdenum {testSubject.PrintElectronShellCfg()}"); testSubject = new Technetium(); Console.WriteLine($"Technetium {testSubject.PrintElectronShellCfg()}"); testSubject = new Ruthenium(); Console.WriteLine($"Ruthenium {testSubject.PrintElectronShellCfg()}"); testSubject = new Rhodium(); Console.WriteLine($"Rhodium {testSubject.PrintElectronShellCfg()}"); testSubject = new Palladium(); Console.WriteLine($"Palladium {testSubject.PrintElectronShellCfg()}"); testSubject = new Silver(); Console.WriteLine($"Silver {testSubject.PrintElectronShellCfg()}"); testSubject = new Cadmium(); Console.WriteLine($"Cadmium {testSubject.PrintElectronShellCfg()}"); testSubject = new Indium(); Console.WriteLine($"Indium {testSubject.PrintElectronShellCfg()}"); testSubject = new Tin(); Console.WriteLine($"Tin {testSubject.PrintElectronShellCfg()}"); testSubject = new Antimony(); Console.WriteLine($"Antimony {testSubject.PrintElectronShellCfg()}"); testSubject = new Tellurium(); Console.WriteLine($"Tellurium {testSubject.PrintElectronShellCfg()}"); testSubject = new Iodine(); Console.WriteLine($"Iodine {testSubject.PrintElectronShellCfg()}"); testSubject = new Xenon(); Console.WriteLine($"Xenon {testSubject.PrintElectronShellCfg()}"); testSubject = new Cesium(); Console.WriteLine($"Cesium {testSubject.PrintElectronShellCfg()}"); testSubject = new Barium(); Console.WriteLine($"Barium {testSubject.PrintElectronShellCfg()}"); }
public override void OnDoubleClick( Mobile from ) { if( !from.Alive || from.Paralyzed || !from.InRange( this, 2 ) || !from.InLOS( this ) ) { from.SendMessage( "That is too far away." ); return; } if( this.CoffinSlave == null && from.AccessLevel > AccessLevel.Player ) { from.SendMessage( "Creating a slave for the coffin." ); DiabloDungeonCoffinSlave slave = new DiabloDungeonCoffinSlave(); slave.Map = this.Map; slave.Location = new Point3D( this.X - 1, this.Y, this.Z ); this.CoffinSlave = slave; slave.CoffinMaster = this; return; } if( this.CanBeOpened ) { this.m_LastTimeOpened = DateTime.Now; int chance = Utility.RandomMinMax( 1, 100 ); if( chance > 70 ) { from.SendMessage( "You have found some copper coins inside the coffin!" ); chance = Utility.RandomMinMax( 3, 6 ); Copper copper = new Copper( chance ); Container pack = from.Backpack; pack.DropItem( copper ); } else { from.SendMessage( "You have disturbed the undead!" ); BaseCreature skeleton = new Skeleton() as BaseCreature; if( chance < 20 ) skeleton = new SkeletalSoldier() as BaseCreature; skeleton.FightMode = FightMode.Closest; bool validLocation = false; Point3D loc = this.Location; for ( int j = 0; !validLocation && j < 10; ++j ) { int x = X + Utility.Random( 3 ) - 1; int y = Y + Utility.Random( 3 ) - 1; int z = this.Map.GetAverageZ( x, y ); if ( validLocation = this.Map.CanFit( x, y, this.Z, 16, false, false ) ) loc = new Point3D( x, y, Z ); else if ( validLocation = this.Map.CanFit( x, y, z, 16, false, false ) ) loc = new Point3D( x, y, z ); } skeleton.MoveToWorld( loc, this.Map ); skeleton.Combatant = from; skeleton.VanishTime = DateTime.Now + TimeSpan.FromHours( 1 ); skeleton.VanishEmote = "*crumbles into dust*"; skeleton.PlaySound( 1169 ); } } else from.SendMessage( "The coffin appears to be empty." ); }
/// <summary> /// Creates a new card based on how many cards have already been made. /// </summary> /// <param name="card"> /// The name of the card to be created. /// </param> /// <returns> /// The new created card. /// </returns> public static Card CreateCard(CardName card) { Contract.Requires(card != CardName.Backside & card != CardName.Empty); Contract.Ensures(Contract.Result<Card>().Name == card); Card c; switch (card) { case CardName.Copper: c = new Copper(); break; case CardName.Silver: c = new Silver(); break; case CardName.Gold: c = new Gold(); break; case CardName.Curse: c = new Curse(); break; case CardName.Estate: c = new Estate(); break; case CardName.Duchy: c = new Duchy(); break; case CardName.Province: c = new Province(); break; case CardName.Gardens: c = new Gardens(); break; case CardName.Cellar: c = new Cellar(); break; case CardName.Chapel: c = new Chapel(); break; case CardName.Chancellor: c = new Chancellor(); break; case CardName.Village: c = new Village(); break; case CardName.Woodcutter: c = new Woodcutter(); break; case CardName.Workshop: c = new Workshop(); break; case CardName.Feast: c = new Feast(); break; case CardName.Moneylender: c = new Moneylender(); break; case CardName.Remodel: c = new Remodel(); break; case CardName.Smithy: c = new Smithy(); break; case CardName.ThroneRoom: c = new ThroneRoom(); break; case CardName.CouncilRoom: c = new CouncilRoom(); break; case CardName.Festival: c = new Festival(); break; case CardName.Laboratory: c = new Laboratory(); break; case CardName.Library: c = new Library(); break; case CardName.Market: c = new Market(); break; case CardName.Mine: c = new Mine(); break; case CardName.Adventurer: c = new Adventurer(); break; case CardName.Bureaucrat: c = new Bureaucrat(); break; case CardName.Militia: c = new Militia(); break; case CardName.Spy: c = new Spy(); break; case CardName.Thief: c = new Thief(); break; case CardName.Witch: c = new Witch(); break; case CardName.Moat: c = new Moat(); break; default: throw new NotImplementedException("Tried to create a card that was not implemented when CardFactory was last updated."); } c.Initialize(card, CardsMade[card]); CardsMade[card] += 1; createdCards.Add(c, true); return c; }
public override void OnDoubleClick( Mobile from ) { BankBox box = from.BankBox; if ( box != null && IsChildOf( box ) ) { Delete(); int deposited = 0; int toAdd = m_Worth; Copper gold; while ( toAdd > 60000 ) { gold = new Copper( 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 Copper( toAdd ); if ( box.TryDropItem( from, gold, false ) ) { deposited += toAdd; } else { gold.Delete(); from.AddToBackpack( new BankCheck( toAdd ) ); } } // Gold was deposited in your account: from.SendMessage( "A total of " + deposited + " copper coins was deposited in your account." ); } else { from.SendLocalizedMessage( 1047026 ); // That must be in your bank box to use it. } }
public static void Deposit( Container cont, int amount ) { while ( amount > 0 ) { Item item; if ( amount < 5000 ) { item = new Copper( amount ); amount = 0; } else if ( amount <= 1000000 ) { item = new BankCheck( amount ); amount = 0; } else { item = new BankCheck( 1000000 ); amount -= 1000000; } cont.DropItem( item ); } }
//public int WithdrawFromTreasury(int withdrawal) //{ // if (Treasury == null || Treasury.Deleted) // return 0; // int amount = 0; // ArrayList list = new ArrayList(); // foreach (Item item in Treasury.Items) // { // if (item is Copper) // { // amount += item.Amount; // list.Add(item); // } // else if (item is Silver) // { // Copper c = new Copper(); // c.Amount = item.Amount * 10; // Treasury.Items.Add(c); // item.Delete(); // list.Add(c); // amount += c.Amount; // } // else if (item is Gold) // { // Copper c = new Copper(); // c.Amount = item.Amount * 100; // Treasury.Items.Add(c); // item.Delete(); // list.Add(c); // amount += c.Amount; // } // } // if (amount < withdrawal) // { // amount = 0; // withdrawal = withdrawal - amount; // } // else // amount -= withdrawal; // for (int i = 0; i < list.Count; i++) // { // Item item = list[i] as Item; // item.Delete(); // } // Treasury.AddItem(new Copper(amount)); // return withdrawal; //} public int WithdrawFromTreasury(int withdrawal) { if (Treasury == null || Treasury.Deleted) return 0; int amount = 0; //int count = Treasury.Items.Count; //for (int i = 0; i < count; i++) // converting silver and gold to copper //{ // if (Treasury.Items[i] is Silver) // { // amount += (Treasury.Items[i].Amount * 10); // Treasury.Items[i].Delete(); // } // if (Treasury.Items[i] is Gold) // { // amount += (Treasury.Items[i].Amount * 100); // Treasury.Items[i].Delete(); // } //} //Treasury.DropItem(new Copper(amount)); // Dropping converted coins into the treasury. ArrayList addList = new ArrayList(); ArrayList deleteList = new ArrayList(); foreach (Item item in Treasury.Items) { if (item is Silver || item is Gold) { Copper c = new Copper(); if (item is Silver) c.Amount = item.Amount * 10; else if (item is Gold) c.Amount = item.Amount * 100; addList.Add(c); deleteList.Add(item); } } foreach (Item copper in addList) { Treasury.AddItem(copper); } foreach (Item coin in deleteList) { Treasury.RemoveItem(coin); } //count = Treasury.Items.Count; amount = Treasury.GetAmount(typeof(Copper)); if (amount < withdrawal) withdrawal = withdrawal - amount; Treasury.ConsumeUpTo(typeof(Copper), withdrawal); return withdrawal; }
public override bool OnBuyItems( Mobile buyer, ArrayList list ) { if ( !IsActiveSeller ) return false; if ( !buyer.CheckAlive() ) return false; if ( !CheckVendorAccess( buyer ) ) { Say( 501522 ); //I shall not treat with scum like thee! return false; } VendorEntry[] buyInfo = (VendorEntry[])m_CustomBuyList.ToArray( typeof( VendorEntry ) ); int totalCost = 0; ArrayList validBuy = new ArrayList( list.Count ); Container cont; bool bought = false; bool fromBank = false; bool fullPurchase = true; int controlSlots = buyer.FollowersMax - buyer.Followers; foreach ( BuyItemResponse buy in list ) { Serial ser = buy.Serial; int amount = buy.Amount; if ( ser.IsItem ) { Item item = World.FindItem( ser ); if ( item == null ) { this.Say( "I am sorry. I could not find in the stock the item you wish to buy." ); continue; } if ( item.RootParent == this ) { if ( amount > item.Amount ) amount = item.Amount; if ( amount <= 0 ) continue; foreach ( VendorEntry entry in buyInfo ) { if ( entry.Type == item.GetType() ) { totalCost += entry.Price * amount; validBuy.Add( buy ); break; } } } } } if ( fullPurchase && validBuy.Count == 0 ) SayTo( buyer, 500190 ); //Thou hast bought nothing! else if ( validBuy.Count == 0 ) SayTo( buyer, 500187 ); //Your order cannot be fulfilled, please try again. if ( validBuy.Count == 0 ) return false; bought = ( buyer.AccessLevel >= AccessLevel.GameMaster ); cont = buyer.Backpack; if ( !bought && cont != null ) { if ( cont.ConsumeTotal( typeof( Copper ), totalCost ) ) bought = true; else if ( totalCost < 2000 ) SayTo( buyer, 500192 ); //Begging thy pardon, but thou casnt afford that. } if ( !bought && totalCost >= 2000 ) { cont = buyer.BankBox; if ( cont != null && cont.ConsumeTotal( typeof( Copper ), totalCost ) ) { bought = true; fromBank = true; } else { SayTo( buyer, 500191 ); //Begging thy pardon, but thy bank account lacks these funds. } } if ( !bought ) return false; else buyer.PlaySound( 0x32 ); cont = buyer.Backpack; if ( cont == null ) cont = buyer.BankBox; foreach ( BuyItemResponse buy in validBuy ) { Serial ser = buy.Serial; int amount = buy.Amount; if ( amount < 1 ) continue; if ( ser.IsItem ) { Item item = World.FindItem( ser ); if ( item == null ) continue; GenericBuyInfo gbi = LookupDisplayObject( item ); if ( gbi != null ) { ProcessValidPurchase( amount, gbi, buyer, cont ); } else { if ( amount > item.Amount ) amount = item.Amount; foreach ( VendorEntry entry in buyInfo ) { if ( item.GetType() == entry.Type ) { Item buyItem; if ( amount >= item.Amount ) { buyItem = item; } else { buyItem = Mobile.LiftItemDupe( item, item.Amount - amount ); if ( buyItem == null ) buyItem = item; } if ( cont == null || !cont.TryDropItem( buyer, buyItem, false ) ) buyItem.MoveToWorld( buyer.Location, buyer.Map ); break; } } } } } if( buyer.AccessLevel == AccessLevel.Player ) { cont = this.BuyPack; if( this is Treasurer && ( (Treasurer)this ).Nation != Nation.None && ( ( ( (Treasurer)this ).Treasury != null && !( (Treasurer)this ).Treasury.Deleted ) || ( (Treasurer)this ).AssignTreasury() ) ) { cont = ( (Treasurer)this ).Treasury; } Copper copper = new Copper(); copper.Amount = totalCost; if( cont is BaseContainer ) ( (BaseContainer)cont ).DropAndStack( copper ); } if ( fullPurchase ) { if ( buyer.AccessLevel >= AccessLevel.GameMaster ) SayTo( buyer, true, "I would not presume to charge thee anything. Here are the goods you requested." ); else if ( fromBank ) SayTo( buyer, true, "The total of thy purchase is {0} copper, which has been withdrawn from your bank account. My thanks for the patronage.", totalCost ); else SayTo( buyer, true, "The total of thy purchase is {0} copper. My thanks for the patronage.", totalCost ); } else { if ( buyer.AccessLevel >= AccessLevel.GameMaster ) SayTo( buyer, true, "I would not presume to charge thee anything. Unfortunately, I could not sell you all the goods you requested." ); else if ( fromBank ) SayTo( buyer, true, "The total of thy purchase is {0} copper, which has been withdrawn from your bank account. My thanks for the patronage. Unfortunately, I could not sell you all the goods you requested.", totalCost ); else SayTo( buyer, true, "The total of thy purchase is {0} copper. My thanks for the patronage. Unfortunately, I could not sell you all the goods you requested.", totalCost ); } return true; }
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.typeofCopper, CurrencySystem.typeofSilver, CurrencySystem.typeofGold }); int gold = 0, silver = 0, copper = 0; for (int c = 0; c < coins.Length; c++) { if (coins[c].GetType() == CurrencySystem.typeofCopper) { copper += coins[c].Amount; } else if (coins[c].GetType() == CurrencySystem.typeofSilver) { silver += coins[c].Amount; } else if (coins[c].GetType() == CurrencySystem.typeofGold) { gold += coins[c].Amount; } } Say(String.Format("Thy current bank balance is {0} gold, {1} silver, and {2} copper.", gold, silver, copper)); } 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.typeofCopper) { cc += coin.Amount; ccLoc = coin.Location; } else if (coin.GetType() == CurrencySystem.typeofSilver) { sc += coin.Amount; scLoc = coin.Location; } else if (coin.GetType() == CurrencySystem.typeofGold) { gc += coin.Amount; gcLoc = coin.Location; } coin.Delete(); }); int[] newAmts = CurrencySystem.Compress(cc, sc, gc); if (newAmts[0] > 0) { Copper copper = new Copper(newAmts[0]); box.AddItem(copper); copper.Location = ccLoc; } if (newAmts[1] > 0) { Silver silver = new Silver(newAmts[1]); box.DropItem(silver); silver.Location = scLoc; } if (newAmts[2] > 0) { Gold gold = new Gold(newAmts[2]); box.DropItem(gold); gold.Location = gcLoc; } } } } base.OnSpeech(e); }