コード例 #1
0
        /// <summary>
        /// Processes the vote count, designates the city leader and switches off the voting stage
        /// </summary>
        /// <param name="data"></param>
        public void ProcessVotes()
        {
            List <PlayerMobile> winners = new List <PlayerMobile>();
            PlayerMobile        winner  = null;

            //calculate who wins the vote for this city!
            //grab city data
            if (BeneficiaryDataList.Count == 0)
            {
                //TODO:  might want to log this case?
                //Turn town over to the golem controllers
                KinCityManager.TransferOwnership(this.City, IOBAlignment.None, null);
                return;
            }
            //Call sort
            BeneficiaryDataList.Sort(new KinCityData.BeneficiaryDataComparer(KinCityData.BeneficiaryDataComparer.SortFields.Votes, true));

            //Find highest vote
            int winningVote = BeneficiaryDataList[0].Votes;

            //Get the winner(s)
            foreach (KinCityData.BeneficiaryData v in BeneficiaryDataList)
            {
                if (v.Votes == winningVote)
                {
                    winners.Add(v.Pm);
                }
            }

            if (winners.Count == 0)
            {
                //This should be impossible
                // turn city over to golem controllers
                KinCityManager.TransferOwnership(this.City, IOBAlignment.None, null);
            }
            else
            {
                //Pick a random mobile from the winners list to be leader
                winner = winners[Utility.Random(0, winners.Count - 1)];
            }

            //more sanity
            if (winner == null)
            {
                //TODO:  something here heh.  should be massively impossible
            }

            //Establish winner as the leader of this city and declare voting over
            IsVotingStage = false;
            CityLeader    = winner;

            foreach (BeneficiaryData bd in BeneficiaryDataList)
            {
                bd.Pm.SendMessage("The voting stage for the City of {0} has ended.  {1} has been selected as the City Leader.", m_City.ToString(), winner.Name);
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the beneficiary.
        /// </summary>
        /// <param name="pmName">Name of the pm.</param>
        /// <returns></returns>
        public BeneficiaryData GetBeneficiary(string pmName)
        {
            BeneficiaryData data = null;

            try
            {
                data = BeneficiaryDataList.Find(delegate(BeneficiaryData bd) { return(bd.Pm.Name == pmName); });
            }
            catch
            {
            }
            return(data);
        }
コード例 #3
0
        /// <summary>
        /// Gets the beneficiary.
        /// </summary>
        /// <param name="pm">The pm.</param>
        /// <returns></returns>
        public BeneficiaryData GetBeneficiary(PlayerMobile pm)
        {
            if (pm == null)
            {
                return(null);
            }
            BeneficiaryData data = null;

            try
            {
                data = BeneficiaryDataList.Find(delegate(BeneficiaryData bd) { return(bd.Pm == pm); });
            }
            catch
            {
            }
            return(data);
        }