Beispiel #1
0
 /// <summary>
 /// Assigns or removes usable slots from the city pool to the beneficiary
 /// </summary>
 /// <param name="pm">The pm.</param>
 /// <param name="amount">The amount.</param>
 public void ModifyGuardSlots(PlayerMobile pm, int amount)
 {
     KinCityData.BeneficiaryData bd = GetBeneficiary(pm);
     if (bd == null || amount == 0)
     {
         return;
     }
     if (amount > 0)
     {
         //Simply add to unassigned slots
         bd.UnassignedGuardSlots += amount;
         m_UnassignedGuardSlots  -= amount;
     }
     else
     {
         amount = Math.Abs(amount);
         //We can only remove slots if there are some to remove
         if (bd.UnassignedGuardSlots >= amount)
         {
             bd.UnassignedGuardSlots -= amount;
             m_UnassignedGuardSlots  += amount;
         }
     }
 }
Beispiel #2
0
        private static void EventSink_Speech(SpeechEventArgs e)
        {
            Mobile from = e.Mobile;

            int[] keywords = e.Keywords;

            for (int i = 0; i < keywords.Length; ++i)
            {
                switch (keywords[i])
                {
                case 0x00EC:                         // *showscore*
                {
                    if (KinSystemSettings.PointsEnabled && from is PlayerMobile && from.Alive)
                    {
                        PlayerMobile pm = from as PlayerMobile;
                        from.PublicOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, true, string.Format("Unassisted: {0:0.00}", pm.KinSoloPoints));
                        from.PublicOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, true, string.Format("Assisted: {0:0.00}", pm.KinTeamPoints));

                        from.SendMessage("Unassisted: {0:0.00}", pm.KinSoloPoints);
                        from.SendMessage("Assisted: {0:0.00}", pm.KinTeamPoints);
                        from.SendMessage("Power: {0:0.00}", pm.KinPowerPoints);
                    }
                    break;
                }
                }
            }

            if (e.Mobile != null && e.Mobile is PlayerMobile && e.Mobile.Alive)
            {
                if (e.Speech.ToLower().IndexOf("i wish to place a guard post") > -1)
                {
                    //wooo sanity!
                    PlayerMobile pm = e.Mobile as PlayerMobile;
                    if (pm == null || pm.IOBRealAlignment == IOBAlignment.None)
                    {
                        return;
                    }

                    //Check player is in a faction region
                    if (!(pm.Region is KinCityRegion))
                    {
                        pm.SendMessage("You are not within a faction city where you are a beneficiary.");
                        return;
                    }

                    //Check they are a beneficiary
                    KinCityData cityData = KinCityManager.GetCityData(((KinCityRegion)pm.Region).KinFactionCity);
                    if (cityData == null)
                    {
                        return;
                    }
                    KinCityData.BeneficiaryData bd = cityData.GetBeneficiary(pm);
                    if (bd == null)
                    {
                        pm.SendMessage("You are not within a faction city where you are a beneficiary.");
                        return;
                    }

                    if (cityData.GuardOption == KinCityData.GuardOptions.LordBritish || cityData.GuardOption == KinCityData.GuardOptions.None)
                    {
                        pm.SendMessage("You may not place a guard post with your city's current guard policy");
                        return;
                    }


                    IPooledEnumerable eable = pm.GetItemsInRange(5);
                    if (eable != null)
                    {
                        try
                        {
                            foreach (Item i in eable)
                            {
                                if (i != null && i is KinGuardPost && !i.Deleted)
                                {
                                    pm.SendMessage("You may not place a guard post this close to another guard post");
                                    return;
                                }
                            }
                        }
                        finally
                        {
                            eable.Free();
                            eable = null;
                        }
                    }

                    eable = pm.GetItemsInRange(3);
                    if (eable != null)
                    {
                        try
                        {
                            foreach (Item i in eable)
                            {
                                if (i != null && i is BaseDoor && !i.Deleted)
                                {
                                    pm.SendMessage("You may not place a guard post this close to a door");
                                    return;
                                }
                            }
                        }
                        finally
                        {
                            eable.Free();
                            eable = null;
                        }
                    }

                    //Check they have enough spare guard slots
                    if (bd.UnassignedGuardSlots < 1)
                    {
                        pm.SendMessage("You do not have enough free guard slots to create a guard post");
                        return;
                    }

                    //Test the 8 squares around the target tile to make sure there is nothing blocking there.
                    for (int x = -1; x < 2; x++)
                    {
                        for (int y = -1; y < 2; y++)
                        {
                            if (x == 0 && y == 0)
                            {
                                continue;                                               //ignore the tile where they are standing
                            }
                            Point3D location = pm.Location;
                            location.X += x;
                            location.Y += y;
                            if (!pm.Map.CanSpawnMobile(location))
                            {
                                pm.SendMessage("You must have at least one free space in every direction around you.");
                                return;
                            }
                        }
                    }


                    //Place & register guard post
                    KinGuardPost kgp = new KinGuardPost(0x429, pm, KinFactionGuardTypes.FactionHenchman, ((KinCityRegion)pm.Region).KinFactionCity);
                    if (bd.RegisterGuardPost(kgp))
                    {
                        pm.SendMessage("Successfully created guard post.");
                        kgp.MoveToWorld(pm.Location, pm.Map);
                        kgp.Visible = true;
                    }
                    else
                    {
                        kgp.Delete();
                    }
                }
                else if (e.Speech.ToLower().IndexOf("i wish to fund my guard post") > -1)
                {
                    //wooo sanity!
                    PlayerMobile pm = e.Mobile as PlayerMobile;
                    if (pm == null || pm.IOBRealAlignment == IOBAlignment.None)
                    {
                        return;
                    }

                    pm.SendMessage("Select the guard post you would like to fund");
                    pm.Target = new KinGuardPostFundTarget();
                }
                else if (e.Speech.ToLower().IndexOf("i renounce my kin status") > -1)
                {
                    ((PlayerMobile)e.Mobile).ResetIOBRankTime();
                    e.Mobile.SendMessage("You have reduced your rank.");
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Increases the vote count for a given mobile
        /// </summary>
        /// <param name="city"></param>
        /// <param name="voteFor"></param>
        /// <param name="voteFrom"></param>
        /// <returns></returns>
        public bool CastVote(PlayerMobile voteFor, PlayerMobile voteFrom)
        {
            //woo sanity
            if (voteFor == null || voteFrom == null)
            {
                return(false);
            }

            //Check this city is in its voting stage
            if (!IsVotingStage)
            {
                return(false);
            }

            //Mobile can't vote for itself
            if (voteFrom == voteFor)
            {
                voteFrom.SendMessage("You may not vote for yourself.");
                return(false);
            }

            //double check the mobile can still vote
            if (!CanVote(voteFrom))
            {
                voteFrom.SendMessage("You may vote only once.");
                return(false);
            }

            //lastly make sure the mobile to be voted for is eligible
            if (!IsBeneficiary(voteFor))
            {
                //This should be impossible
                voteFrom.SendMessage("That person is not a candidate for town control.");
                return(false);
            }

            //Increment vote count
            KinCityData.BeneficiaryData v = GetBeneficiary(voteFor);
            if (v == null)
            {
                //Should be impossible
                voteFrom.SendMessage("That person could not be indentified as a beneificary");
            }
            else
            {
                v.Votes++;
            }

            v = GetBeneficiary(voteFrom);
            if (v == null)
            {
                //Should be impossible
                voteFrom.SendMessage("You could not be found in the list of valid beneficiaries.");
            }
            else
            {
                v.HasVoted = true;
            }

            voteFrom.SendMessage("Your vote has been counted successfully.");

            //plasma: if everyone has voted, let the stage end early
            bool end = true;

            foreach (BeneficiaryData bd in m_BeneficiaryDataList)
            {
                if (!bd.HasVoted)
                {
                    end = false;
                    break;
                }
            }

            if (end)
            {
                ProcessVotes();
            }

            return(true);
        }