public bool HasTurnIn(Mobile from, TradeMinister minister) { if (from == null || minister == null || !ActiveTrades.ContainsKey(from) || ActiveTrades[from] == null) { return(false); } TradeOrderCrate crate = ActiveTrades[from]; return(crate.Entry != null && crate.Entry.Origin != minister.City); }
public bool TryOfferTrade(Mobile from, TradeMinister minister) { if (from == null || from.Backpack == null) { return(true); } if (ActiveTrades.ContainsKey(from)) { minister.SayTo(from, 1151722); // It appears you are already delivering a trade order. Deliver your current order before requesting another. } else { City origin = minister.City; City destination; do { destination = CityLoyaltySystem.GetRandomCity(); }while (destination == origin); int distance = GetDistance(minister, destination); int trades = Utility.RandomMinMax(1, GetMaxTrades(from)); TradeEntry entry = new TradeEntry(destination, origin, distance); TradeOrderCrate crate = new TradeOrderCrate(from, entry); GetPlayerEntry <CityTradeEntry>(from as PlayerMobile, true); for (int i = 0; i < trades; i++) { int worth = 1; string name = null; Type t = GetRandomTrade(origin, destination, ref worth, ref name); int amount = Utility.RandomList(5, 10, 15, 20); entry.Details.Add(new TradeEntry.TradeDetails(t, worth, amount, name)); } if (from.Backpack == null || !from.Backpack.TryDropItem(from, crate, false)) { crate.Delete(); from.SendLocalizedMessage(114456); // Your backpack cannot hold the Trade Order. Free up space and speak to the Trade Minister again. } ActiveTrades[from] = crate; return(true); } return(false); }
public City Clone() { return(new City { Name = Name, DateString = Date.ToString(), Buildings = Buildings.Select(b => b.Clone()).ToList(), Stats = Stats.Select(s => s.Clone()).ToList(), ActiveTrades = ActiveTrades.Select(t => t.Clone()).ToList(), AvailableTradeConsumers = AvailableTradeConsumers.Select(c => c.Clone()).ToList(), AvailableTradeProducers = AvailableTradeProducers.Select(p => p.Clone()).ToList() }); }
public override void ProcessKill(Mobile victim, Mobile damager) { if (victim is BaseCreature && Ambushers != null && Ambushers.ContainsKey((BaseCreature)victim)) { if (ActiveTrades.ContainsKey(damager)) { TradeOrderCrate crate = ActiveTrades[damager]; if (crate.Entry != null) { crate.Entry.Kills++; } } Ambushers.Remove((BaseCreature)victim); } }
public bool TryOfferTrade(Mobile from, TradeMinister minister) { if (from == null || from.Backpack == null) { return(true); } if (ActiveTrades.ContainsKey(from)) { minister.SayTo(from, 1151722); // It appears you are already delivering a trade order. Deliver your current order before requesting another. } else if (KrampusEncounterActive && (KrampusEvent.Instance.Krampus != null || KrampusEvent.Instance.KrampusSpawning)) { Point3D p = KrampusEvent.Instance.SpawnLocation; Map map = KrampusEvent.Instance.SpawnMap; minister.SayTo( from, 1158790, string.Format("{0}\t{1}", WorldLocationInfo.GetLocationString(p, map), Sextant.GetCoords(p, map)), 1150); // Take notice! The vile Krampus has been spotted near ~2_where~ at ~1_coords~! New Trade Orders are suspended until Krampus has been defeated! } else { City origin = minister.City; City destination; do { destination = CityLoyaltySystem.GetRandomCity(); }while (destination == origin); int distance = GetDistance(minister, destination); int trades = Utility.RandomMinMax(1, GetMaxTrades(from)); TradeEntry entry = new TradeEntry(destination, origin, distance); TradeOrderCrate crate = new TradeOrderCrate(from, entry); GetPlayerEntry <CityTradeEntry>(from as PlayerMobile, true); for (int i = 0; i < trades; i++) { int worth = 1; string name = null; Type t = GetRandomTrade(origin, destination, ref worth, ref name); if (t != null) { if (entry.Details.Any(x => x.ItemType.Name == t.Name)) { continue; } int amount = Utility.RandomList(5, 10, 15, 20); entry.Details.Add(new TradeEntry.TradeDetails(t, worth, amount, name)); } else { minister.SayTo(from, "There are no trades available at this time."); return(false); } } if (from.Backpack == null || !from.Backpack.TryDropItem(from, crate, false)) { crate.Delete(); from.SendLocalizedMessage(114456); // Your backpack cannot hold the Trade Order. Free up space and speak to the Trade Minister again. } ActiveTrades[from] = crate; return(true); } return(false); }
public static bool HasTrade(Mobile from) { return(ActiveTrades.ContainsKey(from)); }