示例#1
0
        public void RemoveCandidate(Mobile mob)
        {
            Candidate cd = FindCandidate(mob);

            if (cd == null)
            {
                return;
            }

            m_Candidates.Remove(cd);
            mob.SendLocalizedMessage(1038031);

            if (m_State == ElectionState.Election)
            {
                if (m_Candidates.Count == 1)
                {
                    m_Faction.Broadcast(1038031); // There are no longer any valid candidates in the Faction Commander election.

                    Candidate winner = m_Candidates[0];

                    Mobile      winMob = winner.Mobile;
                    PlayerState pl     = PlayerState.Find(winMob);

                    if (pl == null || pl.Faction != m_Faction || winMob == m_Faction.Commander)
                    {
                        m_Faction.Broadcast(1038026); // Faction leadership has not changed.
                    }
                    else
                    {
                        m_Faction.Broadcast(1038028); // The faction has a new commander.
                        m_Faction.Commander = winMob;
                    }

                    m_Candidates.Clear();
                    State = ElectionState.Pending;
                }
                else if (m_Candidates.Count == 0) // well, I guess this'll never happen
                {
                    m_Faction.Broadcast(1038031); // There are no longer any valid candidates in the Faction Commander election.

                    m_Candidates.Clear();
                    State = ElectionState.Pending;
                }
            }
        }