private int CheckTurnin(Item item) { Type dropType = item.GetType(); int love = 0; foreach (KeyValuePair <Type, int> kvp in Table) { Type checkType = kvp.Key; if (checkType == dropType || dropType.IsSubclassOf(checkType)) { CityLoyaltySystem sys = CityLoyaltySystem.GetCityInstance(City); if (sys != null) { // TODO: If anything adds to treasure, change this if (item is MaritimeCargo) { AddToTreasury(sys, (MaritimeCargo)item); } item.Delete(); love = Table[checkType] * item.Amount; break; } } } return(love); }
public static Type GetRandomTrade(City originCity, City dest, ref int worth, ref string name) { Region region = CityLoyaltySystem.GetCityInstance(originCity).Definition.Region; List <BaseVendor> list = new List <BaseVendor>(region.GetEnumeratedMobiles().OfType <BaseVendor>().Where(bv => bv.GetBuyInfo() != null && bv.GetBuyInfo().Length > 0)); if (list.Count == 0) { return(null); } do { BaseVendor vendor = list[Utility.Random(list.Count)]; IBuyItemInfo[] buyInfo = vendor.GetBuyInfo(); GenericBuyInfo info = buyInfo[Utility.Random(buyInfo.Length)] as GenericBuyInfo; if (!(info is BeverageBuyInfo) && !(info is AnimalBuyInfo) && info != null && info.Type != null && info.Args == null && info.Price < 5000) { list.Clear(); list.TrimExcess(); worth = info.Price; name = info.Name; return(info.Type); } list.Remove(vendor); }while (list.Count > 0); list.Clear(); list.TrimExcess(); return(null); }
private int CheckTurnin(Item item) { Type dropType = item.GetType(); int love = 0; foreach (KeyValuePair <Type, int> kvp in Table) { Type checkType = kvp.Key; if (checkType == dropType || dropType.IsSubclassOf(checkType)) { CityLoyaltySystem sys = CityLoyaltySystem.GetCityInstance(City); if (sys != null) { item.Delete(); love = Table[checkType] * item.Amount; break; } } } return(love); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); City = CityLoyaltySystem.GetCityInstance((City)reader.ReadInt()); if (City != null) { City.Stone = this; } int count = reader.ReadInt(); for (int i = 0; i < count; i++) { BallotBox box = reader.ReadItem() as BallotBox; if (box != null) { if (Boxes == null) { Boxes = new List <BallotBox>(); } Boxes.Add(box); } } }
public override void OnDoubleClick(Mobile from) { if (IsChildOf(from.Backpack)) { CityLoyaltySystem sys = CityLoyaltySystem.GetCityInstance(City); if (CityLoyaltySystem.HasCitizenship(from, City) && sys.GetLoyaltyRating(from) >= LoyaltyRating.Commended) { base.OnDoubleClick(from); } else { from.SendLocalizedMessage(1152361, String.Format("#{0}", CityLoyaltySystem.GetCityLocalization(City))); // You are not sufficiently loyal to ~1_CITY~ to use this. } } }
public override bool OnDragDrop(Mobile from, Item dropped) { if (!CityLoyaltySystem.IsSetup()) { return(false); } if (!Animals && Table != null && Table.Count > 0) { int love = 0; if (dropped is Container) { List <Item> items = new List <Item>(dropped.Items); foreach (Item item in items) { love += CheckTurnin(item); } items.Clear(); items.TrimExcess(); } else { love = CheckTurnin(dropped); } if (love > 0) { CityLoyaltySystem.GetCityInstance(City).AwardLove(from, love); SendMessageTo(from, 1152926); // The City thanks you for your generosity! return(!(dropped is Container)); } else { SendMessageTo(from, 1152927); // Your generosity is appreciated but the City does not require this item. return(false); } } return(false); }
public override void OnClick() { if (Player.Prompt != null) { Player.SendLocalizedMessage(1079166); // You already have a text entry request pending. } else { Player.SendLocalizedMessage(1155865); // Enter amount to deposit: Player.BeginPrompt( (from, text) => { int amount = Utility.ToInt32(text); if (amount > 0) { if (Banker.Withdraw(from, amount, true)) { CityLoyaltySystem.GetCityInstance(Herald.City).AddToTreasury(from, amount, true); Herald.SayTo(from, 1152926); // The City thanks you for your generosity! } else { from.SendLocalizedMessage(1155867); // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction. } } else { from.SendLocalizedMessage(1155867); // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction. } }, (from, text) => { from.SendLocalizedMessage(1155867); // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction. }); } }
protected override void OnTarget(Mobile from, object targeted) { if (targeted is BaseCreature) { BaseCreature bc = targeted as BaseCreature; Type t = bc.GetType(); if (bc.Controlled && !bc.Summoned && bc.GetMaster() == from) { if (Item.Table.ContainsKey(t)) { CityLoyaltySystem sys = CityLoyaltySystem.GetCityInstance(Item.City); if (sys != null) { bc.Delete(); sys.AwardLove(from, Item.Table[t]); Item.SendMessageTo(from, 1152926); // The City thanks you for your generosity! } } else { Item.SendMessageTo(from, 1152929); // That does not look like an animal the City is in need of. } } else { Item.SendMessageTo(from, 1152930); // Erm. Uhh. I don't think that'd enjoy the stables much... } } else { Item.SendMessageTo(from, 1152930); // Erm. Uhh. I don't think that'd enjoy the stables much... } }
public override void OnClick() { CityLoyaltySystem thisSystem = CityLoyaltySystem.GetCityInstance(Guard.City); CityLoyaltySystem theirSystem = CityLoyaltySystem.GetCitizenship(Player); Guard.CheckBannerCooldown(); if (theirSystem != null && thisSystem != null && CityLoyaltySystem.HasCitizenship(Player, Guard.City)) { if (Guard.IsInBannerCooldown(Player)) { Guard.SayTo(Player, 1152364, String.Format("#{0}", CityLoyaltySystem.BannerLocalization(thisSystem.City))); // I have quite a backlog of orders and I cannot satisfy your request for a ~1_ITEM~ right now. } if (theirSystem.GetLoyaltyRating(Player) < LoyaltyRating.Adored) { Guard.SayTo(Player, 1152363, String.Format("#{0}", CityLoyaltySystem.GetCityLocalization(thisSystem.City))); // I apologize, but you are not well-enough renowned in the city of ~1_CITY~ to make this purchase. } else { string args = String.Format("#{0}\t{1}", CityLoyaltySystem.BannerLocalization(thisSystem.City), CityLoyaltySystem.BannerCost.ToString("N0", CultureInfo.GetCultureInfo("en-US"))); Player.SendGump(new ConfirmCallbackGump(Player, 1049004, 1152365, Player, args, Guard.OnConfirm)); } } }