Example #1
0
		public VoteGump( PlayerMobile from, Election election ) : base( 50, 50 )
		{
			m_From = from;
			m_Election = election;

			bool canVote = election.CanVote( from );

			AddPage( 0 );

			AddBackground( 0, 0, 420, 350, 5054 );
			AddBackground( 10, 10, 400, 330, 3000 );

			AddHtmlText( 20, 20, 380, 20, election.Faction.Definition.Header, false, false );

			if ( canVote )
				AddHtmlLocalized( 20, 60, 380, 20, 1011428, false, false ); // VOTE FOR LEADERSHIP
			else
				AddHtmlLocalized( 20, 60, 380, 20, 1038032, false, false ); // You have already voted in this election.

			for ( int i = 0; i < election.Candidates.Count; ++i )
			{
				Candidate cd = election.Candidates[i];

				if ( canVote )
					AddButton( 20, 100 + (i * 20), 4005, 4007, i + 1, GumpButtonType.Reply, 0 );

				AddLabel( 55, 100 + (i * 20), 0, cd.Mobile.Name );
				AddLabel( 300, 100 + (i * 20), 0, cd.Votes.ToString() );
			}

			AddButton( 20, 310, 4005, 4007, 0, GumpButtonType.Reply, 0 );
			AddHtmlLocalized( 55, 310, 100, 20, 1011012, false, false ); // CANCEL
		}
 public FactionState( Faction faction )
 {
     m_Faction = faction;
     m_Tithe = 50;
     m_Members = new List<PlayerState>();
     m_Election = new Election( faction );
     m_FactionItems = new List<FactionItem>();
     m_FactionTraps = new List<BaseFactionTrap>();
 }
 public FactionState( Faction faction )
 {
     m_Faction = faction;
     m_Tithe = 50;
     m_Members = new PlayerStateCollection();
     m_Election = new Election( faction );
     m_FactionItems = new FactionItemCollection();
     m_FactionTraps = new FactionTrapCollection();
 }
Example #4
0
        public void RemoveMember(Mobile mob)
        {
            PlayerState pl = PlayerState.Find(mob);

            if (pl == null || !Members.Contains(pl))
            {
                return;
            }

            Members.Remove(pl);

            if (mob is PlayerMobile)
            {
                ((PlayerMobile)mob).FactionPlayerState = null;
            }

            mob.InvalidateProperties();
            mob.Delta(MobileDelta.Noto);

            if (Election.IsCandidate(mob))
            {
                Election.RemoveCandidate(mob);
            }

            Election.RemoveVoter(mob);

            if (pl.Finance != null)
            {
                pl.Finance.Finance = null;
            }

            if (pl.Sheriff != null)
            {
                pl.Sheriff.Sheriff = null;
            }

            if (Commander == mob)
            {
                Commander = null;
            }

            if (mob is PlayerMobile)
            {
                ((PlayerMobile)mob).ValidateEquipment();
            }
        }
		public void RemoveMember( Mobile mob )
		{
			PlayerState pl = PlayerState.Find( mob );

			if ( pl == null || !Members.Contains( pl ) )
				return;

			if( mob.Backpack != null )
			{
				//Ordinarily, through normal faction removal, this will never find any sigils.
				//Only with a leave delay less than the ReturnPeriod or a Faction Kick/Ban, will this ever do anything
				Item[] sigils = mob.Backpack.FindItemsByType( typeof( Sigil ) );

				for ( int i = 0; i < sigils.Length; ++i )
					((Sigil)sigils[i]).ReturnHome();
			}

			Members.Remove( pl );

			if ( mob is PlayerMobile )
				((PlayerMobile)mob).FactionPlayerState = null;

			mob.InvalidateProperties();
			mob.Delta( MobileDelta.Noto );

			if ( Election.IsCandidate( mob ) )
				Election.RemoveCandidate( mob );

			Election.RemoveVoter( mob );

			if ( pl.Finance != null )
				pl.Finance.Finance = null;

			if ( pl.Sheriff != null )
				pl.Sheriff.Sheriff = null;

			if ( Commander == mob )
				Commander = null;

			if ( mob is PlayerMobile )
				((PlayerMobile)mob).ValidateEquipment();
		}
Example #6
0
        public VoteGump(PlayerMobile from, Election election)
            : base(50, 50)
        {
            m_From     = from;
            m_Election = election;

            bool canVote = election.CanVote(from);

            AddPage(0);

            AddBackground(0, 0, 420, 350, 5054);
            AddBackground(10, 10, 400, 330, 3000);

            AddHtmlText(20, 20, 380, 20, election.Faction.Definition.Header, false, false);

            if (canVote)
            {
                AddHtmlLocalized(20, 60, 380, 20, 1011428, false, false);                   // VOTE FOR LEADERSHIP
            }
            else
            {
                AddHtmlLocalized(20, 60, 380, 20, 1038032, false, false);                   // You have already voted in this election.
            }

            for (int i = 0; i < election.Candidates.Count; ++i)
            {
                Candidate cd = election.Candidates[i];

                if (canVote)
                {
                    AddButton(20, 100 + (i * 20), 4005, 4007, i + 1, GumpButtonType.Reply, 0);
                }

                AddLabel(55, 100 + (i * 20), 0, cd.Mobile.Name);
                AddLabel(300, 100 + (i * 20), 0, cd.Votes.ToString());
            }

            AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(55, 310, 100, 20, 1011012, false, false);               // CANCEL
        }
		public void RemovePlayerState( PlayerState pl )
		{
			if ( pl == null || !Members.Contains( pl ) )
				return;

			Members.Remove( pl );

			PlayerMobile pm = (PlayerMobile) pl.Mobile;
			if( pm == null )
				return;

			Mobile mob = pl.Mobile;
			if ( pm.FactionPlayerState == pl )
			{
				pm.FactionPlayerState = null;

				mob.InvalidateProperties();
				mob.Delta( MobileDelta.Noto );

				if ( Election.IsCandidate( mob ) )
					Election.RemoveCandidate( mob );

				if ( pl.Finance != null )
					pl.Finance.Finance = null;

				if ( pl.Sheriff != null )
					pl.Sheriff.Sheriff = null;

				Election.RemoveVoter( mob );

				if ( Commander == mob )
					Commander = null;

				pm.ValidateEquipment();
			}
		}
		public ElectionManagementGump( Election election, Candidate candidate, int page ) : base( 40, 40 )
		{
			m_Election = election;
			m_Candidate = candidate;
			m_Page = page;

			AddPage( 0 );

			if ( candidate != null )
			{
				AddBackground( 0, 0, 448, 354, 9270 );
				AddAlphaRegion( 10, 10, 428, 334 );

				AddHtml( 10, 10, 428, 20, Color( Center( "Candidate Management" ), LabelColor ), false, false );

				AddHtml(  45, 35, 100, 20, Color( "Player Name:", LabelColor ), false, false );
				AddHtml( 145, 35, 100, 20, Color( candidate.Mobile == null ? "null" : candidate.Mobile.Name, LabelColor ), false, false );

				AddHtml(  45, 55, 100, 20, Color( "Vote Count:", LabelColor ), false, false );
				AddHtml( 145, 55, 100, 20, Color( candidate.Votes.ToString(), LabelColor ), false, false );

				AddButton( 12, 73, 4005, 4007, 1, GumpButtonType.Reply, 0 );
				AddHtml(  45, 75, 100, 20, Color( "Drop Candidate", LabelColor ), false, false );

				AddImageTiled( 13, 99, 422, 242, 9264 );
				AddImageTiled( 14, 100, 420, 240, 9274 );
				AddAlphaRegion( 14, 100, 420, 240 );

				AddHtml( 14, 100, 420, 20, Color( Center( "Voters" ), LabelColor ), false, false );

				if ( page > 0 )
					AddButton( 397, 104, 0x15E3, 0x15E7, 2, GumpButtonType.Reply, 0 );
				else
					AddImage( 397, 104, 0x25EA );

				if ( (page + 1) * 10 < candidate.Voters.Count )
					AddButton( 414, 104, 0x15E1, 0x15E5, 3, GumpButtonType.Reply, 0 );
				else
					AddImage( 414, 104, 0x25E6 );


				AddHtml( 14, 120, 30, 20, Color( Center( "DEL" ), LabelColor ), false, false );
				AddHtml( 47, 120, 150, 20, Color( "Name", LabelColor ), false, false );
				AddHtml( 195, 120, 100, 20, Color( Center( "Address" ), LabelColor ), false, false );
				AddHtml( 295, 120, 80, 20, Color( Center( "Time" ), LabelColor ), false, false );
				AddHtml( 355, 120, 60, 20, Color( Center( "Legit" ), LabelColor ), false, false );

				int idx = 0;

				for ( int i = page*10; i >= 0 && i < candidate.Voters.Count && i < (page+1)*10; ++i, ++idx )
				{
					Voter voter = (Voter)candidate.Voters[i];

					AddButton( 13, 138 + (idx * 20), 4002, 4004, 4 + i, GumpButtonType.Reply, 0 );

					object[] fields = voter.AcquireFields();

					int x = 45;

					for ( int j = 0; j < fields.Length; ++j )
					{
						object obj = fields[j];

						if ( obj is Mobile )
						{
							AddHtml( x + 2, 140 + (idx * 20), 150, 20, Color( ((Mobile)obj).Name, LabelColor ), false, false );
							x += 150;
						}
						else if ( obj is System.Net.IPAddress )
						{
							AddHtml( x, 140 + (idx * 20), 100, 20, Color( Center( obj.ToString() ), LabelColor ), false, false );
							x += 100;
						}
						else if ( obj is DateTime )
						{
							AddHtml( x, 140 + (idx * 20), 80, 20, Color( Center( FormatTimeSpan( ((DateTime)obj) - election.LastStateTime ) ), LabelColor ), false, false );
							x += 80;
						}
						else if ( obj is int )
						{
							AddHtml( x, 140 + (idx * 20), 60, 20, Color( Center( (int)obj + "%" ), LabelColor ), false, false );
							x += 60;
						}
					}
				}
			}
			else
			{
				AddBackground( 0, 0, 288, 334, 9270 );
				AddAlphaRegion( 10, 10, 268, 314 );

				AddHtml( 10, 10, 268, 20, Color( Center( "Election Management" ), LabelColor ), false, false );

				AddHtml(  45, 35, 100, 20, Color( "Current State:", LabelColor ), false, false );
				AddHtml( 145, 35, 100, 20, Color( election.State.ToString(), LabelColor ), false, false );

				AddButton( 12, 53, 4005, 4007, 1, GumpButtonType.Reply, 0 );
				AddHtml(  45, 55, 100, 20, Color( "Transition Time:", LabelColor ), false, false );
				AddHtml( 145, 55, 100, 20, Color( FormatTimeSpan( election.NextStateTime ), LabelColor ), false, false );

				AddImageTiled( 13, 79, 262, 242, 9264 );
				AddImageTiled( 14, 80, 260, 240, 9274 );
				AddAlphaRegion( 14, 80, 260, 240 );

				AddHtml( 14, 80, 260, 20, Color( Center( "Candidates" ), LabelColor ), false, false );
				AddHtml( 14, 100, 30, 20, Color( Center( "-->" ), LabelColor ), false, false );
				AddHtml( 47, 100, 150, 20, Color( "Name", LabelColor ), false, false );
				AddHtml( 195, 100, 80, 20, Color( Center( "Votes" ), LabelColor ), false, false );

				for ( int i = 0; i < election.Candidates.Count; ++i )
				{
					Candidate cd = election.Candidates[i];
					Mobile mob = cd.Mobile;

					if ( mob == null )
						continue;

					AddButton( 13, 118 + (i * 20), 4005, 4007, 2 + i, GumpButtonType.Reply, 0 );
					AddHtml( 47, 120 + (i * 20), 150, 20, Color( mob.Name, LabelColor ), false, false );
					AddHtml( 195, 120 + (i * 20), 80, 20, Color( Center( cd.Votes.ToString() ), LabelColor ), false, false );
				}
			}
		}
Example #9
0
        public FactionState(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 5:
            {
                m_LastAtrophy = reader.ReadDateTime();
                goto case 4;
            }

            case 4:
            {
                int count = reader.ReadEncodedInt();

                for (int i = 0; i < count; ++i)
                {
                    DateTime time = reader.ReadDateTime();

                    if (i < m_LastBroadcasts.Length)
                    {
                        m_LastBroadcasts[i] = time;
                    }
                }

                goto case 3;
            }

            case 3:
            case 2:
            case 1:
            {
                m_Election = new Election(reader);

                goto case 0;
            }

            case 0:
            {
                m_Faction = Faction.ReadReference(reader);

                m_Commander = reader.ReadMobile();

                if (version < 5)
                {
                    m_LastAtrophy = DateTime.UtcNow;
                }

                if (version < 4)
                {
                    DateTime time = reader.ReadDateTime();

                    if (m_LastBroadcasts.Length > 0)
                    {
                        m_LastBroadcasts[0] = time;
                    }
                }

                m_Tithe  = reader.ReadEncodedInt();
                m_Silver = reader.ReadEncodedInt();

                int memberCount = reader.ReadEncodedInt();

                m_Members = new List <PlayerState>();

                for (int i = 0; i < memberCount; ++i)
                {
                    PlayerState pl = new PlayerState(reader, m_Faction, m_Members);

                    if (pl.Mobile != null)
                    {
                        m_Members.Add(pl);
                    }
                }

                m_Faction.State = this;

                m_Faction.ZeroRankOffset = m_Members.Count;
                m_Members.Sort();

                for (int i = m_Members.Count - 1; i >= 0; i--)
                {
                    PlayerState player = m_Members[i];

                    if (player.KillPoints <= 0)
                    {
                        m_Faction.ZeroRankOffset = i;
                    }
                    else
                    {
                        player.RankIndex = i;
                    }
                }

                m_FactionItems = new List <FactionItem>();

                if (version >= 2)
                {
                    int factionItemCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionItemCount; ++i)
                    {
                        FactionItem factionItem = new FactionItem(reader, m_Faction);

                        Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.CheckAttach));         // sandbox attachment
                    }
                }

                m_FactionTraps = new List <BaseFactionTrap>();

                if (version >= 3)
                {
                    int factionTrapCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionTrapCount; ++i)
                    {
                        BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;

                        if (trap != null && !trap.CheckDecay())
                        {
                            m_FactionTraps.Add(trap);
                        }
                    }
                }

                break;
            }
            }

            if (version < 1)
            {
                m_Election = new Election(m_Faction);
            }
        }
Example #10
0
        public ElectionGump(PlayerMobile from, Election election)
            : base(50, 50)
        {
            this.m_From = from;
            this.m_Election = election;

            this.AddPage(0);

            this.AddBackground(0, 0, 420, 180, 5054);
            this.AddBackground(10, 10, 400, 160, 3000);

            this.AddHtmlText(20, 20, 380, 20, election.Faction.Definition.Header, false, false);

            // NOTE: Gump not entirely OSI-accurate, intentionally so

            switch ( election.State )
            {
                case ElectionState.Pending:
                    {
                        TimeSpan toGo = (election.LastStateTime + Election.PendingPeriod) - DateTime.UtcNow;
                        int days = (int)(toGo.TotalDays + 0.5);

                        this.AddHtmlLocalized(20, 40, 380, 20, 1038034, false, false); // A new election campaign is pending

                        if (days > 0)
                        {
                            this.AddHtmlLocalized(20, 60, 280, 20, 1018062, false, false); // Days until next election :
                            this.AddLabel(300, 60, 0, days.ToString());
                        }
                        else
                        {
                            this.AddHtmlLocalized(20, 60, 280, 20, 1018059, false, false); // Election campaigning begins tonight.
                        }

                        break;
                    }
                case ElectionState.Campaign:
                    {
                        TimeSpan toGo = (election.LastStateTime + Election.CampaignPeriod) - DateTime.UtcNow;
                        int days = (int)(toGo.TotalDays + 0.5);

                        this.AddHtmlLocalized(20, 40, 380, 20, 1018058, false, false); // There is an election campaign in progress.

                        if (days > 0)
                        {
                            this.AddHtmlLocalized(20, 60, 280, 20, 1038033, false, false); // Days to go:
                            this.AddLabel(300, 60, 0, days.ToString());
                        }
                        else
                        {
                            this.AddHtmlLocalized(20, 60, 280, 20, 1018061, false, false); // Campaign in progress. Voting begins tonight.
                        }

                        if (this.m_Election.CanBeCandidate(this.m_From))
                        {
                            this.AddButton(20, 110, 4005, 4007, 2, GumpButtonType.Reply, 0);
                            this.AddHtmlLocalized(55, 110, 350, 20, 1011427, false, false); // CAMPAIGN FOR LEADERSHIP
                        }
                        else
                        {
                            PlayerState pl = PlayerState.Find(this.m_From);

                            if (pl == null || pl.Rank.Rank < Election.CandidateRank)
                                this.AddHtmlLocalized(20, 100, 380, 20, 1010118, false, false); // You must have a higher rank to run for office
                        }

                        break;
                    }
                case ElectionState.Election:
                    {
                        TimeSpan toGo = (election.LastStateTime + Election.VotingPeriod) - DateTime.UtcNow;
                        int days = (int)Math.Ceiling(toGo.TotalDays);

                        this.AddHtmlLocalized(20, 40, 380, 20, 1018060, false, false); // There is an election vote in progress.

                        this.AddHtmlLocalized(20, 60, 280, 20, 1038033, false, false);
                        this.AddLabel(300, 60, 0, days.ToString());

                        this.AddHtmlLocalized(55, 100, 380, 20, 1011428, false, false); // VOTE FOR LEADERSHIP
                        this.AddButton(20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0);

                        break;
                    }
            }

            this.AddButton(20, 140, 4005, 4007, 0, GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(55, 140, 350, 20, 1011012, false, false); // CANCEL
        }
Example #11
0
        public ElectionManagementGump(Election election, Candidate candidate, int page) : base(40, 40)
        {
            m_Election  = election;
            m_Candidate = candidate;
            m_Page      = page;

            AddPage(0);

            if (candidate != null)
            {
                AddBackground(0, 0, 448, 354, 9270);
                AddAlphaRegion(10, 10, 428, 334);

                AddHtml(10, 10, 428, 20, Color(Center("Candidate Management"), LabelColor), false, false);

                AddHtml(45, 35, 100, 20, Color("Player Name:", LabelColor), false, false);
                AddHtml(145, 35, 100, 20, Color(candidate.Mobile == null ? "null" : candidate.Mobile.Name, LabelColor), false, false);

                AddHtml(45, 55, 100, 20, Color("Vote Count:", LabelColor), false, false);
                AddHtml(145, 55, 100, 20, Color(candidate.Votes.ToString(), LabelColor), false, false);

                AddButton(12, 73, 4005, 4007, 1, GumpButtonType.Reply, 0);
                AddHtml(45, 75, 100, 20, Color("Drop Candidate", LabelColor), false, false);

                AddImageTiled(13, 99, 422, 242, 9264);
                AddImageTiled(14, 100, 420, 240, 9274);
                AddAlphaRegion(14, 100, 420, 240);

                AddHtml(14, 100, 420, 20, Color(Center("Voters"), LabelColor), false, false);

                if (page > 0)
                {
                    AddButton(397, 104, 0x15E3, 0x15E7, 2, GumpButtonType.Reply, 0);
                }
                else
                {
                    AddImage(397, 104, 0x25EA);
                }

                if ((page + 1) * 10 < candidate.Voters.Count)
                {
                    AddButton(414, 104, 0x15E1, 0x15E5, 3, GumpButtonType.Reply, 0);
                }
                else
                {
                    AddImage(414, 104, 0x25E6);
                }


                AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor), false, false);
                AddHtml(47, 120, 150, 20, Color("Name", LabelColor), false, false);
                AddHtml(195, 120, 100, 20, Color(Center("Address"), LabelColor), false, false);
                AddHtml(295, 120, 80, 20, Color(Center("Time"), LabelColor), false, false);
                AddHtml(355, 120, 60, 20, Color(Center("Legit"), LabelColor), false, false);

                int idx = 0;

                for (int i = page * 10; i >= 0 && i < candidate.Voters.Count && i < (page + 1) * 10; ++i, ++idx)
                {
                    Voter voter = (Voter)candidate.Voters[i];

                    AddButton(13, 138 + (idx * 20), 4002, 4004, 4 + i, GumpButtonType.Reply, 0);

                    object[] fields = voter.AcquireFields();

                    int x = 45;

                    for (int j = 0; j < fields.Length; ++j)
                    {
                        object obj = fields[j];

                        if (obj is Mobile)
                        {
                            AddHtml(x + 2, 140 + (idx * 20), 150, 20, Color(((Mobile)obj).Name, LabelColor), false, false);
                            x += 150;
                        }
                        else if (obj is System.Net.IPAddress)
                        {
                            AddHtml(x, 140 + (idx * 20), 100, 20, Color(Center(obj.ToString()), LabelColor), false, false);
                            x += 100;
                        }
                        else if (obj is DateTime)
                        {
                            AddHtml(x, 140 + (idx * 20), 80, 20, Color(Center(FormatTimeSpan(((DateTime)obj) - election.LastStateTime)), LabelColor), false, false);
                            x += 80;
                        }
                        else if (obj is int)
                        {
                            AddHtml(x, 140 + (idx * 20), 60, 20, Color(Center((int)obj + "%"), LabelColor), false, false);
                            x += 60;
                        }
                    }
                }
            }
            else
            {
                AddBackground(0, 0, 288, 334, 9270);
                AddAlphaRegion(10, 10, 268, 314);

                AddHtml(10, 10, 268, 20, Color(Center("Election Management"), LabelColor), false, false);

                AddHtml(45, 35, 100, 20, Color("Current State:", LabelColor), false, false);
                AddHtml(145, 35, 100, 20, Color(election.State.ToString(), LabelColor), false, false);

                AddButton(12, 53, 4005, 4007, 1, GumpButtonType.Reply, 0);
                AddHtml(45, 55, 100, 20, Color("Transition Time:", LabelColor), false, false);
                AddHtml(145, 55, 100, 20, Color(FormatTimeSpan(election.NextStateTime), LabelColor), false, false);

                AddImageTiled(13, 79, 262, 242, 9264);
                AddImageTiled(14, 80, 260, 240, 9274);
                AddAlphaRegion(14, 80, 260, 240);

                AddHtml(14, 80, 260, 20, Color(Center("Candidates"), LabelColor), false, false);
                AddHtml(14, 100, 30, 20, Color(Center("-->"), LabelColor), false, false);
                AddHtml(47, 100, 150, 20, Color("Name", LabelColor), false, false);
                AddHtml(195, 100, 80, 20, Color(Center("Votes"), LabelColor), false, false);

                for (int i = 0; i < election.Candidates.Count; ++i)
                {
                    Candidate cd  = election.Candidates[i];
                    Mobile    mob = cd.Mobile;

                    if (mob == null)
                    {
                        continue;
                    }

                    AddButton(13, 118 + (i * 20), 4005, 4007, 2 + i, GumpButtonType.Reply, 0);
                    AddHtml(47, 120 + (i * 20), 150, 20, Color(mob.Name, LabelColor), false, false);
                    AddHtml(195, 120 + (i * 20), 80, 20, Color(Center(cd.Votes.ToString()), LabelColor), false, false);
                }
            }
        }
Example #12
0
 public ElectionManagementGump(Election election) : this(election, null, 0)
 {
 }
        public FactionState( GenericReader reader )
        {
            int version = reader.ReadEncodedInt();

            switch ( version )
            {
                case 4:
                {
                    int count = reader.ReadEncodedInt();

                    for ( int i = 0; i < count; ++i )
                    {
                        DateTime time = reader.ReadDateTime();

                        if ( i < m_LastBroadcasts.Length )
                            m_LastBroadcasts[i] = time;
                    }

                    goto case 3;
                }
                case 3:
                case 2:
                case 1:
                {
                    m_Election = new Election( reader );

                    goto case 0;
                }
                case 0:
                {
                    m_Faction = Faction.ReadReference( reader );

                    m_Commander = reader.ReadMobile();

                    if ( version < 4 )
                    {
                        DateTime time = reader.ReadDateTime();

                        if ( m_LastBroadcasts.Length > 0 )
                            m_LastBroadcasts[0] = time;
                    }

                    m_Tithe = reader.ReadEncodedInt();
                    m_Silver = reader.ReadEncodedInt();

                    int memberCount = reader.ReadEncodedInt();

                    m_Members = new PlayerStateCollection();

                    for ( int i = 0; i < memberCount; ++i )
                    {
                        PlayerState pl = new PlayerState( reader, m_Faction, m_Members );

                        if ( pl.Mobile != null )
                            m_Members.Add( pl );
                    }

                    m_Faction.State = this;
                    m_Faction.UpdateRanks();

                    m_FactionItems = new FactionItemCollection();

                    if ( version >= 2 )
                    {
                        int factionItemCount = reader.ReadEncodedInt();

                        for ( int i = 0; i < factionItemCount; ++i )
                        {
                            FactionItem factionItem = new FactionItem( reader, m_Faction );

                            if ( !factionItem.HasExpired )
                                factionItem.Attach();
                            else
                                Timer.DelayCall( TimeSpan.Zero, new TimerCallback( factionItem.Detach ) ); // sandbox detachment
                        }
                    }

                    m_FactionTraps = new FactionTrapCollection();

                    if ( version >= 3 )
                    {
                        int factionTrapCount = reader.ReadEncodedInt();

                        for ( int i = 0; i < factionTrapCount; ++i )
                        {
                            BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;

                            if ( trap != null && !trap.CheckDecay() )
                                m_FactionTraps.Add( trap );
                        }
                    }

                    break;
                }
            }

            if ( version < 1 )
                m_Election = new Election( m_Faction );
        }
Example #14
0
		public ElectionManagementGump( Election election ) : this( election, null, 0 )
		{
		}
Example #15
0
        public FactionState(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 4:
            {
                int count = reader.ReadEncodedInt();

                for (int i = 0; i < count; ++i)
                {
                    DateTime time = reader.ReadDateTime();

                    if (i < m_LastBroadcasts.Length)
                    {
                        m_LastBroadcasts[i] = time;
                    }
                }

                goto case 3;
            }

            case 3:
            case 2:
            case 1:
            {
                m_Election = new Election(reader);

                goto case 0;
            }

            case 0:
            {
                m_Faction = Faction.ReadReference(reader);

                m_Commander = reader.ReadMobile();

                if (version < 4)
                {
                    DateTime time = reader.ReadDateTime();

                    if (m_LastBroadcasts.Length > 0)
                    {
                        m_LastBroadcasts[0] = time;
                    }
                }

                m_Tithe  = reader.ReadEncodedInt();
                m_Silver = reader.ReadEncodedInt();

                int memberCount = reader.ReadEncodedInt();

                m_Members = new PlayerStateCollection();

                for (int i = 0; i < memberCount; ++i)
                {
                    PlayerState pl = new PlayerState(reader, m_Faction, m_Members);

                    if (pl.Mobile != null)
                    {
                        m_Members.Add(pl);
                    }
                }

                m_Faction.State = this;
                m_Faction.UpdateRanks();

                m_FactionItems = new FactionItemCollection();

                if (version >= 2)
                {
                    int factionItemCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionItemCount; ++i)
                    {
                        FactionItem factionItem = new FactionItem(reader, m_Faction);

                        if (!factionItem.HasExpired)
                        {
                            factionItem.Attach();
                        }
                        else
                        {
                            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.Detach));                                         // sandbox detachment
                        }
                    }
                }

                m_FactionTraps = new FactionTrapCollection();

                if (version >= 3)
                {
                    int factionTrapCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionTrapCount; ++i)
                    {
                        BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;

                        if (trap != null && !trap.CheckDecay())
                        {
                            m_FactionTraps.Add(trap);
                        }
                    }
                }

                break;
            }
            }

            if (version < 1)
            {
                m_Election = new Election(m_Faction);
            }
        }
Example #16
0
		public FactionState( GenericReader reader )
		{
			int version = reader.ReadEncodedInt();

			switch ( version )
			{
                case 5:
                    {
                        m_LastAtrophy = reader.ReadDateTime();
                        goto case 4;
                    }
				case 4:
				{
					int count = reader.ReadEncodedInt();

					for ( int i = 0; i < count; ++i )
					{
						DateTime time = reader.ReadDateTime();

						if ( i < m_LastBroadcasts.Length )
							m_LastBroadcasts[i] = time;
					}

					goto case 3;
				}
				case 3:
				case 2:
				case 1:
				{
					m_Election = new Election( reader );

					goto case 0;
				}
				case 0:
				{
					m_Faction = Faction.ReadReference( reader );

					m_Commander = reader.ReadMobile();

                    if (version < 5)
                        m_LastAtrophy = DateTime.Now;

					if ( version < 4 )
					{
						DateTime time = reader.ReadDateTime();

						if ( m_LastBroadcasts.Length > 0 )
							m_LastBroadcasts[0] = time;
					}

					m_Tithe = reader.ReadEncodedInt();
					m_Silver = reader.ReadEncodedInt();

					int memberCount = reader.ReadEncodedInt();

					m_Members = new List<PlayerState>();

					for ( int i = 0; i < memberCount; ++i )
					{
						PlayerState pl = new PlayerState( reader, m_Faction, m_Members );

						if ( pl.Mobile != null )
							m_Members.Add( pl );
					}

					m_Faction.State = this;

                    m_Faction.ZeroRankOffset = m_Members.Count;
                    m_Members.Sort();

                    for (int i = m_Members.Count - 1; i >= 0; i--)
                    {
                        PlayerState player = m_Members[i];

                        if (player.KillPoints <= 0)
                            m_Faction.ZeroRankOffset = i;
                        else
                            player.RankIndex = i;
                    }


					m_FactionItems = new List<FactionItem>();

					if ( version >= 2 )
					{
						int factionItemCount = reader.ReadEncodedInt();

						for ( int i = 0; i < factionItemCount; ++i )
						{
							FactionItem factionItem = new FactionItem( reader, m_Faction );

                            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.CheckAttach)); // sandbox attachment
						}
					}

					m_FactionTraps = new List<BaseFactionTrap>();

					if ( version >= 3 )
					{
						int factionTrapCount = reader.ReadEncodedInt();

						for ( int i = 0; i < factionTrapCount; ++i )
						{
							BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;

							if ( trap != null && !trap.CheckDecay() )
								m_FactionTraps.Add( trap );
						}
					}

					break;
				}
			}

			if ( version < 1 )
				m_Election = new Election( m_Faction );
		}
Example #17
0
        public FactionState(IGenericReader reader)
        {
            var version = reader.ReadEncodedInt();

            switch (version)
            {
            case 5:
            {
                LastAtrophy = reader.ReadDateTime();
                goto case 4;
            }

            case 4:
            {
                var count = reader.ReadEncodedInt();

                for (var i = 0; i < count; ++i)
                {
                    var time = reader.ReadDateTime();

                    if (i < m_LastBroadcasts.Length)
                    {
                        m_LastBroadcasts[i] = time;
                    }
                }

                goto case 3;
            }

            case 3:
            case 2:
            case 1:
            {
                Election = new Election(reader);

                goto case 0;
            }

            case 0:
            {
                m_Faction = Faction.ReadReference(reader);

                m_Commander = reader.ReadEntity <Mobile>();

                if (version < 5)
                {
                    LastAtrophy = Core.Now;
                }

                if (version < 4)
                {
                    var time = reader.ReadDateTime();

                    if (m_LastBroadcasts.Length > 0)
                    {
                        m_LastBroadcasts[0] = time;
                    }
                }

                Tithe  = reader.ReadEncodedInt();
                Silver = reader.ReadEncodedInt();

                var memberCount = reader.ReadEncodedInt();

                Members = new List <PlayerState>();

                for (var i = 0; i < memberCount; ++i)
                {
                    var pl = new PlayerState(reader, m_Faction, Members);

                    if (pl.Mobile != null)
                    {
                        Members.Add(pl);
                    }
                }

                m_Faction.State = this;

                m_Faction.ZeroRankOffset = Members.Count;
                Members.Sort();

                for (var i = Members.Count - 1; i >= 0; i--)
                {
                    var player = Members[i];

                    if (player.KillPoints <= 0)
                    {
                        m_Faction.ZeroRankOffset = i;
                    }
                    else
                    {
                        player.RankIndex = i;
                    }
                }

                FactionItems = new List <FactionItem>();

                if (version >= 2)
                {
                    var factionItemCount = reader.ReadEncodedInt();

                    for (var i = 0; i < factionItemCount; ++i)
                    {
                        var factionItem = new FactionItem(reader, m_Faction);

                        Timer.StartTimer(factionItem.CheckAttach);         // sandbox attachment
                    }
                }

                Traps = new List <BaseFactionTrap>();

                if (version >= 3)
                {
                    var factionTrapCount = reader.ReadEncodedInt();

                    for (var i = 0; i < factionTrapCount; ++i)
                    {
                        if (reader.ReadEntity <Item>() is BaseFactionTrap trap && !trap.CheckDecay())
                        {
                            Traps.Add(trap);
                        }
                    }
                }

                break;
            }
            }

            if (version < 1)
            {
                Election = new Election(m_Faction);
            }
        }
Example #18
0
        public ElectionGump(PlayerMobile from, Election election) : base(50, 50)
        {
            m_From     = from;
            m_Election = election;

            AddPage(0);

            AddBackground(0, 0, 420, 180, 5054);
            AddBackground(10, 10, 400, 160, 3000);

            AddHtmlText(20, 20, 380, 20, election.Faction.Definition.Header, false, false);

            // NOTE: Gump not entirely OSI-accurate, intentionally so

            switch (election.State)
            {
            case ElectionState.Pending:
            {
                TimeSpan toGo = election.LastStateTime + Election.PendingPeriod - DateTime.UtcNow;
                int      days = (int)(toGo.TotalDays + 0.5);

                AddHtmlLocalized(20, 40, 380, 20, 1038034); // A new election campaign is pending

                if (days > 0)
                {
                    AddHtmlLocalized(20, 60, 280, 20, 1018062); // Days until next election :
                    AddLabel(300, 60, 0, days.ToString());
                }
                else
                {
                    AddHtmlLocalized(20, 60, 280, 20, 1018059); // Election campaigning begins tonight.
                }

                break;
            }

            case ElectionState.Campaign:
            {
                TimeSpan toGo = election.LastStateTime + Election.CampaignPeriod - DateTime.UtcNow;
                int      days = (int)(toGo.TotalDays + 0.5);

                AddHtmlLocalized(20, 40, 380, 20, 1018058); // There is an election campaign in progress.

                if (days > 0)
                {
                    AddHtmlLocalized(20, 60, 280, 20, 1038033); // Days to go:
                    AddLabel(300, 60, 0, days.ToString());
                }
                else
                {
                    AddHtmlLocalized(20, 60, 280, 20, 1018061); // Campaign in progress. Voting begins tonight.
                }

                if (m_Election.CanBeCandidate(m_From))
                {
                    AddButton(20, 110, 4005, 4007, 2);
                    AddHtmlLocalized(55, 110, 350, 20, 1011427); // CAMPAIGN FOR LEADERSHIP
                }
                else
                {
                    PlayerState pl = PlayerState.Find(m_From);

                    if (pl == null || pl.Rank.Rank < Election.CandidateRank)
                    {
                        AddHtmlLocalized(20, 100, 380, 20, 1010118); // You must have a higher rank to run for office
                    }
                }

                break;
            }

            case ElectionState.Election:
            {
                TimeSpan toGo = election.LastStateTime + Election.VotingPeriod - DateTime.UtcNow;
                int      days = (int)Math.Ceiling(toGo.TotalDays);

                AddHtmlLocalized(20, 40, 380, 20, 1018060); // There is an election vote in progress.

                AddHtmlLocalized(20, 60, 280, 20, 1038033);
                AddLabel(300, 60, 0, days.ToString());

                AddHtmlLocalized(55, 100, 380, 20, 1011428); // VOTE FOR LEADERSHIP
                AddButton(20, 100, 4005, 4007, 1);

                break;
            }
            }

            AddButton(20, 140, 4005, 4007, 0);
            AddHtmlLocalized(55, 140, 350, 20, 1011012); // CANCEL
        }
Example #19
0
        public FactionState(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 6:
            case 5:
            {
                m_LastAtrophy = reader.ReadDateTime();
                goto case 4;
            }

            case 4:
            {
                int count = reader.ReadEncodedInt();

                for (int i = 0; i < count; ++i)
                {
                    DateTime time = reader.ReadDateTime();

                    if (i < m_LastBroadcasts.Length)
                    {
                        m_LastBroadcasts[i] = time;
                    }
                }

                goto case 3;
            }

            case 3:
            case 2:
            case 1:
            {
                Election ele = new Election(reader);

                if (Settings.Enabled)
                {
                    m_Election = ele;
                }
                else
                {
                    m_Election = new Election(m_Faction);
                }

                goto case 0;
            }

            case 0:
            {
                m_Faction = Faction.ReadReference(reader);

                if (m_Election.Faction == null)
                {
                    m_Election.Faction = m_Faction;
                }

                m_Commander = reader.ReadMobile();

                if (version < 5)
                {
                    m_LastAtrophy = DateTime.UtcNow;
                }

                if (version < 4)
                {
                    DateTime time = reader.ReadDateTime();

                    if (m_LastBroadcasts.Length > 0)
                    {
                        m_LastBroadcasts[0] = time;
                    }
                }

                m_Tithe  = reader.ReadEncodedInt();
                m_Silver = reader.ReadEncodedInt();

                int memberCount = reader.ReadEncodedInt();

                m_Members = new List <PlayerState>();

                for (int i = 0; i < memberCount; ++i)
                {
                    PlayerState pl = new PlayerState(reader, m_Faction, m_Members);

                    if (pl.Mobile != null)
                    {
                        if (Settings.Enabled)
                        {
                            m_Members.Add(pl);
                        }
                        else
                        {
                            Settings.AddDisabledNotice(pl.Mobile);
                        }
                    }
                }

                m_Faction.State = this;

                m_Faction.ZeroRankOffset = m_Members.Count;
                m_Members.Sort();

                for (int i = m_Members.Count - 1; i >= 0; i--)
                {
                    PlayerState player = m_Members[i];

                    if (player.KillPoints <= 0)
                    {
                        m_Faction.ZeroRankOffset = i;
                    }
                    else
                    {
                        player.RankIndex = i;
                    }
                }

                m_FactionItems = new List <FactionItem>();

                if (version >= 2)
                {
                    int factionItemCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionItemCount; ++i)
                    {
                        FactionItem factionItem = new FactionItem(reader, m_Faction);

                        if (Settings.Enabled)
                        {
                            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.CheckAttach));         // sandbox attachment
                        }
                    }
                }

                m_FactionTraps = new List <BaseFactionTrap>();

                if (version >= 3)
                {
                    int factionTrapCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionTrapCount; ++i)
                    {
                        BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;

                        if (trap != null && !trap.CheckDecay())
                        {
                            if (Settings.Enabled)
                            {
                                m_FactionTraps.Add(trap);
                            }
                            else
                            {
                                trap.Delete();
                            }
                        }
                    }
                }

                break;
            }
            }

            if (version < 6 && Settings.Enabled && Core.ML)
            {
                FactionCollectionBox box = new FactionCollectionBox(m_Faction);
                WeakEntityCollection.Add("factions", box);
                box.MoveToWorld(m_Faction.Definition.Stronghold.CollectionBox, Faction.Facet);
            }

            if (version < 1)
            {
                m_Election = new Election(m_Faction);
            }
        }