public NomineesGump(PlayerMobile pm, CityLoyaltySystem city) : base(pm, 50, 50) { City = city; pm.CloseGump(typeof(NomineesGump)); }
public CandidatesGump(PlayerMobile pm, CityLoyaltySystem city) : base(pm, 50, 50) { City = city; pm.CloseGump(typeof(CandidatesGump)); }
public override void AddGumpLayout() { base.AddGumpLayout(); if (City == null) { return; } AddHtmlLocalized(30, 40, 285, 200, 1152891, string.Format("#{0}", CityLoyaltySystem.GetCityLocalization(City.City).ToString()), 1, false, true); /*If you choose to declare citizenship with ~1_CITY~, you will be granted the "Citizen" title. * If your loyalty rating to ~1_CITY~ is high enough, you will be able to receive titles with * that city.<br><br>You may only have citizenship in one city at a time. You may renounce * citizenship at any time. After renouncing citizenship, you must wait one week before declaring * citizenship again.<br><br>Note that gaining city titles requires positive loyalty with your city, * and you will be required to donate funds to the city's coffers.<br><br>Are you sure you wish to * declare citizenship with ~1_CITY~?*/ AddHtmlLocalized(115, 280, 150, 16, 1152892, false, false); // Declare Citizenship AddButton(100, 285, 2103, 2104, 1, GumpButtonType.Reply, 0); AddHtmlLocalized(115, 300, 150, 16, 1152889, false, false); // Cancel AddButton(100, 305, 2103, 2104, 2, GumpButtonType.Reply, 0); }
public override void AddGumpLayout() { base.AddGumpLayout(); int gold = Citizenship.GetTitleCost(Title); LoyaltyRating rating = Citizenship.GetMinimumRating(Title); AddHtmlLocalized(60, 40, 300, 20, 1152901, false, false); // Obtain Title AddHtmlLocalized(75, 60, 200, 16, CityLoyaltySystem.GetTitleLocalization(User, Title, Citizenship.City), false, false); AddHtmlLocalized(60, 120, 200, 16, 1152899, false, false); // Loyalty Required: AddHtmlLocalized(60, 140, 200, 16, 1152900, false, false); // Donation Required: AddHtmlLocalized(200, 120, 150, 16, CityLoyaltySystem.RatingLocalization(Citizenship.GetMinimumRating(Title)), false, false); AddHtml(200, 140, 150, 16, Citizenship.GetTitleCost(Title).ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("en-US")), false, false); if (gold > Banker.GetBalance(User)) { AddHtmlLocalized(30, 180, 280, 80, 1152902, false, false); // You do not have enough funds in your bank box to donate for this title. } else if (rating > Citizenship.GetLoyaltyRating(User)) { AddHtmlLocalized(30, 180, 280, 80, 1152903, false, false); // You do not have the required minimum loyalty rating to receive this title. } else { AddHtmlLocalized(60, 345, 150, 16, 1152904, false, false); // Gain Title AddButton(40, 350, 2103, 2104, 1, GumpButtonType.Reply, 0); } AddHtmlLocalized(60, 365, 150, 16, 1152889, false, false); // Cancel AddButton(40, 370, 2103, 2104, 2, GumpButtonType.Reply, 0); }
public static bool ApplyCityTitle(PlayerMobile pm, ObjectPropertyList list, string prefix, int loc) { if (loc == 1154017) { CityLoyaltySystem city = GetCitizenship(pm); if (city != null) { CityLoyaltyEntry entry = city.GetPlayerEntry <CityLoyaltyEntry>(pm, true); if (entry != null && !String.IsNullOrEmpty(entry.CustomTitle)) { prefix = String.Format("{0} {1} the {2}", prefix, pm.Name, entry.CustomTitle); list.Add(1154017, String.Format("{0}\t{1}", prefix, city.Definition.Name)); // ~1_TITLE~ of ~2_CITY~ return(true); } } } else { list.Add(1151487, "{0} \t{1} the \t#{2}", prefix, pm.Name, loc); // ~1NT_PREFIX~~2NT_NAME~~3NT_SUFFIX~ return(true); } return(false); }
public override void OnResponse(RelayInfo info) { base.OnResponse(info); if (!CityLoyaltySystem.IsSetup()) { return; } switch (info.ButtonID) { case 0: break; case 1: SendGump(new CityTitlesGump(User)); break; case 2: SendGump(new RenounceCitizenshipGump(User)); break; case 3: default: int id = info.ButtonID - 100; if (id >= 0 && id < CityLoyaltySystem.Cities.Count) { if (Citizenship == null) { SendGump(new DeclareCitizenshipGump(CityLoyaltySystem.Cities[id], User)); } } break; } }
public static bool ApplyCityTitle(PlayerMobile pm, ref string prefix, ref string name, ref string suffix) { if (String.IsNullOrWhiteSpace(pm.OverheadTitle)) { return(false); } var loc = Utility.ToInt32(pm.OverheadTitle); if (loc != 1154017) { return(false); } CityLoyaltySystem city = GetCitizenship(pm); if (city != null) { CityLoyaltyEntry entry = city.GetPlayerEntry <CityLoyaltyEntry>(pm, true); if (entry != null && !String.IsNullOrEmpty(entry.CustomTitle)) { if (!String.IsNullOrWhiteSpace(suffix) && !suffix.EndsWith(" ")) { suffix += " "; } suffix += String.Format("the {0} of {1}", entry.CustomTitle, city.Definition.Name); return(true); } } return(false); }
public CityStone(CityLoyaltySystem city) : base(0xED4) { City = city; Movable = false; City.Stone = this; }
public override void AddNameProperty(ObjectPropertyList list) { if (City != null) { list.Add(1153887, String.Format("#{0}", CityLoyaltySystem.GetCityLocalization(City.City))); } }
public override void GetProperties(ObjectPropertyList list) { base.GetProperties(list); list.Add(1151737, String.Format("#{0}", CityLoyaltySystem.CityLocalization(Entry.Destination))); // Destination City: ~1_city~ list.Add(1076255); // NO-TRADE int weight = Items.Sum(x => x.Amount); list.Add(1072241, "{0}\t{1}\t{2}\t{3}", Items.Count, DefaultMaxItems, weight, DefaultMaxWeight); // Contents: ~1_COUNT~/~2_MAXCOUNT items, ~3_WEIGHT~/~4_MAXWEIGHT~ stones list.Add(1072210, "75"); // Weight reduction: ~1_PERCENTAGE~% if (Entry.Details != null) { for (int i = 0; i < Entry.Details.Count; i++) { if (Utility.ToInt32(Entry.Details[i].Name) > 0) { list.Add(1116453 + i, String.Format("#{0}\t{1}\t{2}", Entry.Details[i].Name, GetAmount(Entry.Details[i].ItemType), Entry.Details[i].Amount)); // ~1_val~: ~2_val~/~3_val~ } else { list.Add(1116453 + i, String.Format("{0}\t{1}\t{2}", Entry.Details[i].Name, GetAmount(Entry.Details[i].ItemType), Entry.Details[i].Amount)); // ~1_val~: ~2_val~/~3_val~ } } } if (!Expired) { int hours = (int)Math.Max(1, (Expires - DateTime.UtcNow).TotalHours); list.Add(1153090, hours.ToString()); // Lifespan: ~1_val~ hours } }
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 AddNameProperty(ObjectPropertyList list) { if (City != null) { list.Add(1153887, $"#{CityLoyaltySystem.GetCityLocalization(City.City)}"); } }
public bool TryTurnInToSlim(Mobile from, TradeOrderCrate order, SlimTheFence slim) { if (order == null || from == null || slim == null || order.Entry == null) { return(false); } TradeEntry entry = order.Entry; if (!order.Fulfilled) { slim.SayTo(from, 1151732); // This trade order has not been fulfilled. Fill the trade order with all necessary items and try again. } else { CityLoyaltySystem.OnSlimTradeComplete(from, order.Entry); CityTradeEntry pentry = GetPlayerEntry <CityTradeEntry>(from as PlayerMobile, true); if (pentry != null) { pentry.Points++; pentry.DistanceTraveled += entry.Distance; pentry.CompletedSlim++; CheckTitle(pentry); } slim.SayTo(from, 1151736); // Haha! These goods will fetch me quite a bit o' coin! Thanks fer yer help! Here's a little something I was able to get me hands on... order.Delete(); return(true); } return(false); }
public static void OnLogin(LoginEventArgs e) { if (!Enabled) { return; } PlayerMobile pm = e.Mobile as PlayerMobile; if (pm == null) { return; } CityLoyaltySystem sys = GetCitizenship(pm); if (sys != null && sys.ActiveTradeDeal != TradeDeal.None) { CityLoyaltyEntry entry = sys.GetPlayerEntry <CityLoyaltyEntry>(pm, true); if (entry != null && entry.UtilizingTradeDeal) { BuffInfo.AddBuff(pm, new BuffInfo(BuffIcon.CityTradeDeal, 1154168, 1154169, new TextDefinition((int)sys.ActiveTradeDeal), true)); } } }
public override void OnDoubleClick(Mobile from) { if (CityLoyaltySystem.Enabled && CityLoyaltySystem.IsSetup() && from is PlayerMobile pm && pm.InRange(pm.Location, 3)) { BaseGump.SendGump(new CityStoneGump(pm, City)); } }
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 PlayerTitleGump(PlayerMobile pm, PlayerMobile citizen, CityLoyaltySystem sys) : base(pm, 50, 50) { Citizen = citizen; City = sys; pm.CloseGump(typeof(PlayerTitleGump)); }
public InternalEntry(PlayerMobile from, GuardCaptain guard) : base(1152366, 3) // City Banner { Player = from; Guard = guard; Enabled = CityLoyaltySystem.HasCitizenship(from, Guard.City); }
public ChooseTradeDealGump(PlayerMobile pm, CityLoyaltySystem city) : base(75, 75) { User = pm; City = city; AddGumpLayout(); }
public CityElection(CityLoyaltySystem city) { City = city; ElectionEnded = true; Candidates = new List <BallotEntry>(); GetDefaultStartTimes(); }
public AcceptOfficeGump(PlayerMobile pm, CityLoyaltySystem city) : base(50, 50) { User = pm; City = city; pm.CloseGump(typeof(AcceptOfficeGump)); AddGumpLayout(); }
public CityInfoGump(CityLoyaltySystem city) : base(50, 50) { City = city; int page = 0; AddPage(page); AddBackground(0, 0, 500, 400, 5054); AddHtml(0, 15, 400, 20, String.Format("<center>City Info - {0}</center>", city.Definition.Name), false, false); AddLabel(10, 35, 0, "Player"); AddLabel(150, 35, 0, "Love"); AddLabel(225, 35, 0, "Hate"); AddLabel(300, 35, 0, "Title"); AddLabel(450, 35, 0, "Info"); int pageIndex = 0; page++; AddPage(page); AddButton(10, 370, 4014, 4016, 1, GumpButtonType.Reply, 0); AddLabel(45, 370, 0, "BACK"); for (int i = 0; i < city.PlayerTable.Count; i++) { CityLoyaltyEntry entry = city.PlayerTable[i] as CityLoyaltyEntry; if (entry == null) { continue; } pageIndex++; AddHtml(10, 60 + (pageIndex * 25), 140, 20, String.Format("{0}{1}", entry.Player != null ? entry.Player.Name : "Unknown", entry.IsCitizen ? "(Citizen)" : ""), false, false); AddHtml(150, 60 + (pageIndex * 25), 75, 20, entry.Love.ToString(), false, false); AddHtml(225, 60 + (pageIndex * 25), 75, 20, entry.Hate.ToString(), false, false); AddHtml(300, 60 + (pageIndex * 25), 150, 20, String.IsNullOrEmpty(entry.CustomTitle) ? "" : entry.CustomTitle, false, false); AddButton(450, 60 + (pageIndex * 25), 4005, 4007, i + 100, GumpButtonType.Reply, 0); if (pageIndex >= 11 && i < city.PlayerTable.Count - 1) { pageIndex = 0; page++; AddButton(252, 370, 4005, 4007, 0, GumpButtonType.Page, page); AddPage(page); } if (i > 12) { AddButton(228, 370, 4014, 4016, 0, GumpButtonType.Page, page - 1); } } }
public CandidatesGump(PlayerMobile pm, CityLoyaltySystem city) : base(50, 50) { User = pm; City = city; pm.CloseGump(typeof(CandidatesGump)); AddGumpLayout(); }
public virtual void AddTitle(CityTitle title) { if ((Titles & title) == 0) { int loc = CityLoyaltySystem.GetTitleLocalization(Player, title, City); Player.AddRewardTitle(loc); Titles |= title; Player.SendLocalizedMessage(1073625, String.Format("#{0}", loc.ToString())); // The title "~1_TITLE~" has been bestowed upon you. } }
public PlayerTitleGump(PlayerMobile pm, PlayerMobile citizen, CityLoyaltySystem sys) : base(50, 50) { User = pm; Citizen = citizen; City = sys; pm.CloseGump(typeof(PlayerTitleGump)); AddGumpLayout(); }
public static bool HasCitizenship(Mobile from, City city) { if (Cities == null) { return(false); } CityLoyaltySystem sys = Cities.FirstOrDefault(s => s.City == city); return(sys != null && sys.IsCitizen(from)); }
public void RenounceCitizenship() { foreach (int i in Enum.GetValues(typeof(CityTitle))) { Player.RemoveRewardTitle(CityLoyaltySystem.GetTitleLocalization(Player, (CityTitle)i, City), true); } Player.RemoveRewardTitle(1154017, true); IsCitizen = false; Titles = CityTitle.None; }
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 bool TryTurnIn(Mobile from, TradeOrderCrate order, Mobile turninMobile) { if (order == null || from == null || turninMobile == null || order.Entry == null) { return(false); } TradeEntry entry = order.Entry; if (from.AccessLevel == AccessLevel.Player && turninMobile is TradeMinister minister && minister.City != entry.Destination) { turninMobile.SayTo(from, 1151738, string.Format("#{0}", CityLoyaltySystem.GetCityLocalization(entry.Destination))); // Begging thy pardon, but those goods are destined for the City of ~1_city~ }
public static bool HasTradeDeal(Mobile m, TradeDeal deal) { CityLoyaltySystem sys = GetCitizenship(m); if (sys != null) { CityLoyaltyEntry entry = sys.GetPlayerEntry <CityLoyaltyEntry>(m, true); return(sys.ActiveTradeDeal == deal && entry != null && entry.UtilizingTradeDeal); } return(false); }
public static bool HasType(CityLoyaltySystem system, Type t) { return HasType(system.Definition.Region, t); }