示例#1
0
        public virtual void AwardHate(Mobile from, double hate)
        {
            CityLoyaltyEntry entry = GetPlayerEntry <CityLoyaltyEntry>(from, true);

            if (entry.Love > 10)
            {
                double convert = entry.Hate / 75;
                entry.Love -= (int)convert;
                entry.Hate += (int)convert;
            }

            entry.Hate += (int)hate;

            if (entry.ShowGainMessage)
            {
                from.SendLocalizedMessage(1152321, Definition.Name); // Your deeds in the city of ~1_name~ are worthy of censure.
            }

            if (from == Governor && entry.LoyaltyRating < LoyaltyRating.Unknown)
            {
                Governor = null;
            }

            if (from == GovernorElect && entry.LoyaltyRating < LoyaltyRating.Unknown)
            {
                GovernorElect = null;
            }
        }
示例#2
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            TextRelay        relay = info.GetTextEntry(1);
            CityLoyaltyEntry entry = City.GetPlayerEntry <CityLoyaltyEntry>(Citizen);

            if (relay == null || String.IsNullOrEmpty(relay.Text))
            {
                entry.CustomTitle = null;
                User.SendMessage("You have removed their title.");
                Citizen.SendMessage("{0} has removed your city title.", User.Name);
                //TODO: Clilocs???
            }
            else
            {
                string text = Utility.FixHtml(relay.Text);

                if (Server.Guilds.BaseGuildGump.CheckProfanity(text) && text.Trim().Length > 3)
                {
                    User.AddRewardTitle(1154017); // ~1_TITLE~ of ~2_CITY~
                    entry.CustomTitle = text.Trim();

                    if (User != Citizen)
                    {
                        User.SendMessage("You have bestowed {0} the title: {1} of {2}.", Citizen.Name, text, City.Definition.Name);
                    }

                    Citizen.SendLocalizedMessage(1155605, String.Format("{0}\t{1}", text, City.Definition.Name)); // Thou hath been bestowed the title ~1_TITLE~! - ~1_TITLE~ of ~2_CITY~
                }
                else
                {
                    User.SendLocalizedMessage(501179); // That title is disallowed.
                }
            }
        }
示例#3
0
        public override void OnResponse(RelayInfo info)
        {
            if (info.ButtonID == 500)
            {
                User.SendGump(new LoyaltyRatingGump(User));
            }

            if (info.ButtonID == 501)
            {
                if (Citizenship != null)
                {
                    CityLoyaltyEntry entry = Citizenship.GetPlayerEntry <CityLoyaltyEntry>(User);

                    if (entry != null)
                    {
                        if (entry.ShowGainMessage)
                        {
                            entry.ShowGainMessage = false;
                            User.SendLocalizedMessage(1157160); //You will no longer receive City Loyalty gain messages.
                        }
                        else
                        {
                            entry.ShowGainMessage = true;
                            User.SendLocalizedMessage(1157161); //You will now receive City Loyalty gain messages.
                        }
                    }
                }

                Refresh();
            }
        }
示例#4
0
        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);
        }
示例#5
0
        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));
                }
            }
        }
示例#6
0
        public void RenounceCitizenship(Mobile from)
        {
            CityLoyaltyEntry entry = GetPlayerEntry <CityLoyaltyEntry>(from, true);

            if (entry != null)
            {
                entry.RenounceCitizenship();

                if (from == Governor)
                {
                    _Governor = null;

                    if (Stone != null)
                    {
                        Stone.InvalidateProperties();
                    }
                }

                if (from == GovernorElect)
                {
                    _GovernorElect = null;

                    if (Stone != null)
                    {
                        Stone.InvalidateProperties();
                    }
                }

                _CitizenWait[from] = DateTime.UtcNow + TimeSpan.FromDays(CitizenJoinWait);
            }
        }
示例#7
0
        public virtual void AwardLove(Mobile from, double love, bool message = true)
        {
            CityLoyaltyEntry entry = GetPlayerEntry <CityLoyaltyEntry>(from, true);

            if (entry.Hate > 10)
            {
                double convert = entry.Hate / 75;
                entry.Neutrality += (int)convert;
                entry.Hate       -= (int)convert;
            }

            foreach (CityLoyaltySystem sys in Cities.Where(s => s.City != this.City))
            {
                CityLoyaltyEntry e = sys.GetPlayerEntry <CityLoyaltyEntry>(from, true);

                if (e.Love > 10)
                {
                    double convert = e.Love / 75;
                    e.Love       -= (int)convert;
                    e.Neutrality += (int)convert;
                }
            }

            if (message)
            {
                from.SendLocalizedMessage(1152320, Definition.Name); // Your deeds in the city of ~1_name~ are worthy of praise.
            }
            entry.Love += (int)love;
        }
示例#8
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);
        }
示例#9
0
        public void TryUtilizeTradeDeal(Mobile m)
        {
            CityLoyaltyEntry entry = GetPlayerEntry <CityLoyaltyEntry>(m, true);

            if (entry != null)
            {
                if (ActiveTradeDeal == TradeDeal.None)
                {
                    HeraldMessage(m, 1154064); // The City doth nay currently have a Trade Deal in place, perhaps ye should petition the Governor to make such a deal...
                }
                else if (entry.UtilizingTradeDeal)
                {
                    HeraldMessage(m, 1154063); // Thou hath already claimed the benefit of the Trade Deal today!
                }
                else if (entry.LoyaltyRating < LoyaltyRating.Respected)
                {
                    HeraldMessage(m, 1154062); // Begging thy pardon, but thou must be at least Respected within the City to claim the benefits of a Trade Deal!
                }
                else
                {
                    entry.UtilizingTradeDeal = true;
                    BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.CityTradeDeal, 1154168, 1154169, new TextDefinition((int)ActiveTradeDeal), true));

                    m.SendLocalizedMessage(1154075); // You gain the benefit of your City's Trade Deal!
                }
            }
        }
示例#10
0
文件: Gumps.cs 项目: pallop/Servuo
        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);
                }
            }
        }
示例#11
0
        public bool IsCitizen(Mobile from)
        {
            if (from.AccessLevel > AccessLevel.Player)
            {
                return(true);
            }

            CityLoyaltyEntry entry = GetPlayerEntry <CityLoyaltyEntry>(from);

            return(entry != null && entry.IsCitizen);
        }
示例#12
0
        public virtual bool HasTitle(Mobile from, CityTitle title)
        {
            CityLoyaltyEntry entry = GetPlayerEntry <CityLoyaltyEntry>(from);

            if (entry == null)
            {
                return(false);
            }

            return((entry.Titles & title) != 0);
        }
示例#13
0
        public virtual void AddTitle(Mobile from, CityTitle title)
        {
            CityLoyaltyEntry entry = GetPlayerEntry <CityLoyaltyEntry>(from);

            if (entry == null)
            {
                return;
            }

            entry.AddTitle(title);
        }
示例#14
0
        public bool TryNominate(PlayerMobile pm)
        {
            CityLoyaltyEntry pentry = City.GetPlayerEntry <CityLoyaltyEntry>(pm);

            if (pm.Young)
            {
                pm.SendMessage("Young players cannot be nominated for the ballot!");
            }
            else if (!City.IsCitizen(pm) || pentry == null)
            {
                pm.SendLocalizedMessage(1153890); // You must be a citizen of this City to nominate yourself for the ballot!
            }
            else if (City.GetLoyaltyRating(pm) < LoyaltyRating.Adored)
            {
                pm.SendLocalizedMessage(1153891); // You must at least be adored within the City to nominate yourself for the ballot.
            }
            else
            {
                Account a = pm.Account as Account;
                for (int i = 0; i < a.Length; i++)
                {
                    Mobile m = a[i];

                    if (!(m is PlayerMobile))
                    {
                        continue;
                    }

                    BallotEntry ballot = Candidates.FirstOrDefault(entry => entry.Player == m);

                    if (ballot != null && m is PlayerMobile)
                    {
                        pm.SendLocalizedMessage(ballot.Endorsements.Count > 0 ? 1153917 : 1153889);  // A character from this account is currently endorsed for Candidacy and cannot be nominated.                                                                      // A character from this account has already been nominated to run for office.
                        return(false);                                                               // A character from this account has already been nominated to run for office.
                    }

                    ballot = Candidates.FirstOrDefault(entry => entry.Endorsements.Contains(m));

                    if (ballot != null && m is PlayerMobile)
                    {
                        pm.SendLocalizedMessage(1153892); // A character from this account has already endorsed a nominee!
                        return(false);
                    }
                }

                Candidates.Add(new BallotEntry(pm, pentry.Love, pentry.Hate));
                pm.PrivateOverheadMessage(Network.MessageType.Regular, 0x3B2, 1153905, pm.NetState); // *You etch your name into the stone*
                pm.SendLocalizedMessage(1154087);                                                    // You have 24 hours to get your nomination endorsed. If you do not get an endorsement within that period you will need to re-nominate yourself.

                return(true);
            }

            return(false);
        }
示例#15
0
        public bool HasMinRating(Mobile from, CityTitle title)
        {
            CityLoyaltyEntry entry = GetPlayerEntry <CityLoyaltyEntry>(from);

            if (entry == null)
            {
                return(false);
            }

            return(entry.LoyaltyRating >= GetMinimumRating(title));
        }
示例#16
0
        public override void AddGumpLayout()
        {
            int page = 0;

            AddPage(page);

            AddBackground(0, 0, 500, 400, 5054);
            AddHtml(0, 15, 400, 20, $"<center>City Info - {City.Definition.Name}</center>", 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, $"{(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);
                }
            }
        }
示例#17
0
        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);
        }
示例#18
0
        public override void OnResponse(RelayInfo info)
        {
            TextRelay        relay = info.GetTextEntry(1);
            CityLoyaltyEntry entry = City.GetPlayerEntry <CityLoyaltyEntry>(Citizen);

            if (entry == null)
            {
                return;
            }

            if (relay == null || string.IsNullOrEmpty(relay.Text))
            {
                entry.CustomTitle = null;
                Citizen.RemoveRewardTitle(1154017, true);

                if (User != Citizen)
                {
                    User.SendMessage("You have removed their title.");
                    Citizen.SendMessage("{0} has removed your city title.", User.Name);
                }
                else
                {
                    User.SendMessage("You have removed your title.");
                }
            }
            else
            {
                string text = Utility.FixHtml(relay.Text);

                if (BaseGuildGump.CheckProfanity(text) && text.Trim().Length > 3)
                {
                    if (entry.IsCitizen)
                    {
                        Citizen.AddRewardTitle(1154017); // ~1_TITLE~ of ~2_CITY~
                        entry.CustomTitle = text.Trim();

                        if (User != Citizen)
                        {
                            User.SendMessage("You have bestowed {0} the title: {1} of {2}.", Citizen.Name, text, City.Definition.Name);
                        }

                        Citizen.SendLocalizedMessage(1155605, $"{text}\t{City.Definition.Name}"); // Thou hath been bestowed the title ~1_TITLE~! - ~1_TITLE~ of ~2_CITY~
                    }
                }
                else
                {
                    User.SendLocalizedMessage(501179); // That title is disallowed.
                }
            }
        }
示例#19
0
        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)
            {
                if (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));
                    }
                }

                int message;

                if (pm.LastOnline + LoveAtrophyDuration > DateTime.UtcNow)
                {
                    message = 1152913; // The moons of Trammel and Felucca align to preserve your virtue status and city loyalty.
                }
                else
                {
                    message = 1152912; // The moons of Trammel and Felucca fail to preserve your virtue status and city loyalty.
                }

                Timer.DelayCall(TimeSpan.FromSeconds(.7), () =>
                {
                    pm.SendLocalizedMessage(message);
                });
            }
        }
示例#20
0
        public static bool HasCustomTitle(PlayerMobile pm, out string str)
        {
            CityLoyaltySystem city = GetCitizenship(pm);

            str = null;

            if (city != null)
            {
                CityLoyaltyEntry entry = city.GetPlayerEntry <CityLoyaltyEntry>(pm, true);

                if (entry != null)
                {
                    str = String.Format("{0}\t{1}", entry.CustomTitle, city.Definition.Name);
                }
            }

            return(str != null);
        }
示例#21
0
        public virtual LoyaltyRating GetLoyaltyRating(Mobile from, CityLoyaltyEntry entry)
        {
            if (entry != null)
            {
                int love = entry.Love;
                int hate = entry.Hate;
                int neut = entry.Neutrality;

                if (hate > 0 && hate > love && hate > neut)
                {
                    return(GetHateRating(hate));
                }
                else if (neut > 0 && neut > love && neut > hate)
                {
                    return(GetNeutralRating(neut));
                }
                else if (love > 0)
                {
                    return(GetLoveRating(love));
                }
            }

            return(LoyaltyRating.Unknown);
        }
示例#22
0
        public override void GetContextMenuEntries(Mobile from, List <ContextMenuEntry> list)
        {
            base.GetContextMenuEntries(from, list);

            if (!CityLoyaltySystem.Enabled || City == null)
            {
                return;
            }

            if (!City.IsCitizen(from))
            {
                if (City.Herald != null)
                {
                    City.Herald.SayTo(from, 1154061, City.Definition.Name); // Only citizens of ~1_CITY~ may use the City Stone!
                }
                else
                {
                    from.SendLocalizedMessage(1154061, City.Definition.Name); // Only citizens of ~1_CITY~ may use the City Stone!
                }
                return;
            }

            list.Add(new SimpleContextMenuEntry(from, 1154018, m => // Grant Citizen Title
            {
                if (City.IsGovernor(m))
                {
                    m.SendLocalizedMessage(1154027);     // Which Citizen do you wish to bestow a title?
                    m.BeginTarget(10, false, TargetFlags.None, (mob, targeted) =>
                    {
                        PlayerMobile pm = targeted as PlayerMobile;

                        if (pm != null)
                        {
                            if (City.IsCitizen(pm))
                            {
                                BaseGump.SendGump(new PlayerTitleGump(mob as PlayerMobile, pm, City));
                            }
                            else
                            {
                                mob.SendLocalizedMessage(1154029);         // You may only bestow a title on citizens of this city!
                            }
                        }
                        else
                        {
                            mob.SendLocalizedMessage(1154028);         // You can only bestow a title on a player!
                        }
                    });
                }
            }, enabled: City.IsGovernor(from)));

            list.Add(new SimpleContextMenuEntry(from, 1154031, m => // Open Trade Deal
            {
                if (City.IsGovernor(m))
                {
                    BaseGump.SendGump(new ChooseTradeDealGump(m as PlayerMobile, City));
                }
            }, enabled: City.IsGovernor(from)));

            list.Add(new SimpleContextMenuEntry(from, 1154277, m => // Open Inventory WTF is this?
            {
                if (m is PlayerMobile && City.IsGovernor(m))
                {
                    BaseGump.SendGump(new OpenInventoryGump((PlayerMobile)m, City));
                }
            }, enabled: City.IsGovernor(from)));

            list.Add(new SimpleContextMenuEntry(from, 1154278, m => // Place Ballot Box
            {
                if (City.IsGovernor(m))
                {
                    if (Boxes != null && Boxes.Count >= CityLoyaltySystem.MaxBallotBoxes)
                    {
                        m.SendMessage("You have reached the maximum amount of ballot boxes in your city.");
                        return;
                    }

                    m.SendMessage("Where would you like to place a ballot box?");
                    m.BeginTarget(3, true, TargetFlags.None, (mob, targeted) =>
                    {
                        if (targeted is IPoint3D)
                        {
                            IPoint3D p = targeted as IPoint3D;
                            Server.Spells.SpellHelper.GetSurfaceTop(ref p);
                            BallotBox box = new BallotBox();

                            if (CheckLocation(m, box, p))
                            {
                                box.Owner   = m;
                                box.Movable = false;

                                if (Boxes == null)
                                {
                                    Boxes = new List <BallotBox>();
                                }

                                Boxes.Add(box);
                                box.MoveToWorld(new Point3D(p), Map);

                                m.SendMessage("{0} of {1} ballot boxes placed.", Boxes.Count.ToString(), CityLoyaltySystem.MaxBallotBoxes.ToString());
                            }
                            else
                            {
                                box.Delete();
                            }
                        }
                    });
                }
            }, enabled: City.IsGovernor(from)));

            list.Add(new SimpleContextMenuEntry(from, 1154060, m => // Utilize Trade Deal
            {
                City.TryUtilizeTradeDeal(from);
            }, enabled: City.ActiveTradeDeal != TradeDeal.None));

            CityLoyaltyEntry entry = City.GetPlayerEntry <CityLoyaltyEntry>(from);

            list.Add(new SimpleContextMenuEntry(from, 1154019, m => // Remove City Title
            {
                if (entry != null && entry.CustomTitle != null)
                {
                    entry.CustomTitle = null;

                    if (m is PlayerMobile)
                    {
                        ((PlayerMobile)m).RemoveRewardTitle(1154017, true);
                    }

                    m.SendMessage("City Title removed.");
                }
            }, enabled: entry != null && entry.CustomTitle != null));

            list.Add(new SimpleContextMenuEntry(from, 1154068, m => // Accept Office
            {
                if (m is PlayerMobile && m == City.GovernorElect && City.Governor == null)
                {
                    BaseGump.SendGump(new AcceptOfficeGump(m as PlayerMobile, City));
                }
            }, enabled: City.GovernorElect == from && City.Governor == null && City.GetLoyaltyRating(from) >= LoyaltyRating.Unknown));
        }
示例#23
0
        public void DeclareCitizen(Mobile from)
        {
            CityLoyaltyEntry entry = GetPlayerEntry <CityLoyaltyEntry>(from, true);

            entry.DeclareCitizenship();
        }
示例#24
0
        public static void OnTick()
        {
            List <PlayerMobile> list = new List <PlayerMobile>(_CitizenWait.Keys.OfType <PlayerMobile>());

            foreach (PlayerMobile pm in list)
            {
                if (_CitizenWait[pm] < DateTime.UtcNow)
                {
                    RemoveWaitTime(pm);
                }
            }

            list.Clear();
            list.TrimExcess();

            Cities.ForEach(sys =>
            {
                if (DateTime.UtcNow > _NextAtrophy)
                {
                    sys.PlayerTable.ForEach(t =>
                    {
                        CityLoyaltyEntry entry = t as CityLoyaltyEntry;

                        if (entry != null)
                        {
                            PlayerMobile owner = entry.Player;

                            entry.Neutrality -= entry.Neutrality / 50;
                            entry.Hate       -= entry.Hate / 50;

                            if (owner != null && owner.LastOnline + TimeSpan.FromHours(40) < DateTime.UtcNow)
                            {
                                entry.Love -= entry.Love / 75;
                            }
                        }
                    });

                    _NextAtrophy = DateTime.UtcNow + TimeSpan.FromDays(1);
                }

                if (sys.NextTradeDealCheck != DateTime.MinValue && sys.NextTradeDealCheck < DateTime.UtcNow)
                {
                    sys.PayTradeDealCost();
                }

                foreach (CityLoyaltyEntry entry in sys.PlayerTable.OfType <CityLoyaltyEntry>())
                {
                    if (entry.TradeDealExpired)
                    {
                        entry.CheckTradeDeal();
                    }
                }

                if (sys.Election != null)
                {
                    sys.Election.OnTick();
                }
                else
                {
                    sys.Election = new CityElection(sys);
                }
            });

            CityTradeSystem.OnTick();
        }
示例#25
0
        public static void OnTick()
        {
            foreach (var sys in Cities)
            {
                List <Mobile> list = new List <Mobile>(sys.CitizenWait.Keys);

                foreach (var m in list)
                {
                    if (sys.CitizenWait[m] < DateTime.UtcNow)
                    {
                        sys.RemoveWaitTime(m);
                    }
                }

                ColUtility.Free(list);

                if (DateTime.UtcNow > _NextAtrophy)
                {
                    sys.PlayerTable.ForEach(t =>
                    {
                        CityLoyaltyEntry entry = t as CityLoyaltyEntry;

                        if (entry != null && entry.Player != null)
                        {
                            PlayerMobile owner = entry.Player;

                            entry.Neutrality -= entry.Neutrality / 50;
                            entry.Hate       -= entry.Hate / 50;

                            if (owner.LastOnline + LoveAtrophyDuration < DateTime.UtcNow)
                            {
                                entry.Love -= entry.Love / 75;
                            }
                        }
                    });

                    _NextAtrophy = DateTime.UtcNow + TimeSpan.FromDays(1);
                }

                if (sys.NextTradeDealCheck != DateTime.MinValue && sys.NextTradeDealCheck < DateTime.UtcNow)
                {
                    sys.PayTradeDealCost();
                }

                foreach (CityLoyaltyEntry entry in sys.PlayerTable.OfType <CityLoyaltyEntry>())
                {
                    if (entry.TradeDealExpired)
                    {
                        entry.CheckTradeDeal();
                    }
                }

                if (sys.Election != null)
                {
                    sys.Election.OnTick();
                }
                else
                {
                    sys.Election = new CityElection(sys);
                }
            }

            CityTradeSystem.OnTick();
        }
示例#26
0
        public virtual LoyaltyRating GetLoyaltyRating(Mobile from, CityLoyaltyEntry entry)
        {
            if (entry != null)
            {
                int love = entry.Love;
                int hate = entry.Hate;
                int neut = entry.Neutrality;

                if (hate > 0 && hate > love && hate > neut)
                {
                    return GetHateRating(hate);
                }
                else if (neut > 0 && neut > love && neut > hate)
                {
                    return GetNeutralRating(neut);
                }
                else if (love > 0)
                {
                    return GetLoveRating(love);
                }
            }

            return LoyaltyRating.Unknown;
        }