Example #1
0
        public string GetJobDescriptionProgressText(PlayerMobile player)
        {
            string description = "";

            Societies.CheckCreateSocietiesPlayerSettings(player);

            SocietyJobPlayerProgress jobPlayerProgress = Societies.GetSocietiesJobPlayerProgress(player, this);

            double primaryNumber   = 0;
            double secondaryNumber = 0;

            if (jobPlayerProgress != null)
            {
                primaryNumber   = jobPlayerProgress.m_ProgressAmount;
                secondaryNumber = jobPlayerProgress.m_TurnedInAmount;
            }

            switch (m_JobType)
            {
            case JobType.CraftItem: description = primaryNumber.ToString() + " / " + m_TargetNumber.ToString() + " " + m_PrimaryTypeName + " Crafted"; break;

            case JobType.KillCreature: description = primaryNumber.ToString() + " / " + m_TargetNumber.ToString() + " " + m_PrimaryTypeName + " Killed"; break;

            case JobType.RetrieveFish: description = primaryNumber.ToString() + " / " + m_TargetNumber.ToString() + " " + m_PrimaryTypeName + " Caught"; break;

            case JobType.SinkShip: description = primaryNumber.ToString() + " / " + m_TargetNumber.ToString() + " " + m_PrimaryTypeName + " Sunk"; break;

            case JobType.StealItem: description = primaryNumber.ToString() + " / " + m_TargetNumber.ToString() + " " + m_PrimaryTypeName + " Stolen"; break;

            case JobType.TameCreature: description = primaryNumber.ToString() + " / " + m_TargetNumber.ToString() + " " + m_PrimaryTypeName + " Tamed"; break;
            }

            return(description);
        }
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int)0); //Version

            Societies.Serialize(writer);
        }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            Movable = false;

            Societies.PersistanceItem = this;
            Societies.Deserialize(reader);
        }
        public static List <KeyValuePair <PlayerMobile, int> > GetSocietyGroupLifetimeRanks(SocietiesGroupType societyGroupType)
        {
            Dictionary <PlayerMobile, int> dictPlayers = new Dictionary <PlayerMobile, int>();

            foreach (Mobile mobile in World.Mobiles.Values)
            {
                if (mobile == null)
                {
                    continue;
                }
                if (mobile.Deleted)
                {
                    continue;
                }
                if (!mobile.Player)
                {
                    continue;
                }

                PlayerMobile pm_Target = mobile as PlayerMobile;

                Societies.CheckCreateSocietiesPlayerSettings(pm_Target);
                SocietyGroupPlayerData societyGroupPlayerData = pm_Target.m_SocietiesPlayerSettings.GetSocietyGroupPlayerData(societyGroupType);

                if (societyGroupPlayerData == null)
                {
                    continue;
                }

                if (societyGroupPlayerData.m_MontlyPoints > 0)
                {
                    dictPlayers.Add(pm_Target, societyGroupPlayerData.m_LifetimePoints);
                }
            }

            List <KeyValuePair <PlayerMobile, int> > m_Results = new List <KeyValuePair <PlayerMobile, int> >();

            foreach (KeyValuePair <PlayerMobile, int> pair in dictPlayers.OrderByDescending(key => key.Value))
            {
                PlayerMobile pm_Target = pair.Key;
                int          points    = pair.Value;

                m_Results.Add(pair);
            }

            return(m_Results);
        }
Example #5
0
        public string GetJobRewardText()
        {
            string description = "";

            string societiesGroupName = Societies.GetSocietyGroupName(m_SocietiesGroupType);

            if (m_PointValue == 1)
            {
                return("" + m_PointValue.ToString() + " Society Point Awarded");
            }

            else
            {
                return("" + m_PointValue.ToString() + " Society Points Awarded");
            }

            return(description);
        }
Example #6
0
        public void PlayerAccept(PlayerMobile player)
        {
            if (player == null)
            {
                return;
            }
            if (player.Backpack == null)
            {
                return;
            }

            if (AccountHasCompleted(player))
            {
                player.SendMessage("A character on this account has already completed this job.");
                return;
            }

            SocietyJobPlayerProgress playerJobProgress = Societies.GetSocietiesJobPlayerProgress(player, this);

            if (playerJobProgress == null)
            {
                if (player.Backpack.TotalItems >= player.Backpack.MaxItems)
                {
                    player.SendMessage("You have too many items in your backpack to accept a new job contract.");
                    return;
                }

                else
                {
                    playerJobProgress = new SocietyJobPlayerProgress(this);
                    player.m_SocietiesPlayerSettings.m_JobProgress.Add(playerJobProgress);

                    player.SendMessage("You accept the job offer. A contract has been placed in your backpack.");

                    SocietiesJobContract jobContract = new SocietiesJobContract(this);
                    playerJobProgress.m_JobContract = jobContract;
                    jobContract.m_Player            = player;

                    player.SendSound(0x249);

                    player.Backpack.DropItem(jobContract);
                }
            }

            else
            {
                List <SocietiesJobContract> m_ContractsHeld = player.Backpack.FindItemsByType <SocietiesJobContract>();

                bool foundMatch = false;

                foreach (SocietiesJobContract contract in m_ContractsHeld)
                {
                    if (contract.m_Job == this)
                    {
                        foundMatch = true;
                        break;
                    }
                }

                if (foundMatch)
                {
                    player.SendMessage("You already have a contract for this job in your backpack.");
                    return;
                }

                if (player.Backpack.TotalItems >= player.Backpack.MaxItems)
                {
                    player.SendMessage("You have too many items in your backpack to receive a replacement contract for this job.");
                    return;
                }

                else
                {
                    //Delete Any Old Instances of this Contract Created by Player
                    Queue m_Queue = new Queue();

                    foreach (Item item in World.Items.Values)
                    {
                        if (item is SocietiesJobContract)
                        {
                            SocietiesJobContract oldContract = item as SocietiesJobContract;

                            if (oldContract == null)
                            {
                                continue;
                            }

                            if (oldContract.m_Job == this && oldContract.m_Player == player)
                            {
                                m_Queue.Enqueue(oldContract);
                            }
                        }
                    }

                    while (m_Queue.Count > 0)
                    {
                        Item item = (Item)m_Queue.Dequeue();

                        item.Delete();
                    }

                    SocietiesJobContract jobContract = new SocietiesJobContract(this);

                    jobContract.m_Player            = player;
                    playerJobProgress.m_JobContract = jobContract;

                    player.Backpack.DropItem(jobContract);

                    player.SendSound(0x249);

                    player.SendMessage("You have previouly accepted this job offer, and receive a replacement contract for the job.");
                    return;
                }
            }
        }
Example #7
0
        public void Complete(PlayerMobile player)
        {
            SocietyJobPlayerProgress jobProgress = Societies.GetSocietiesJobPlayerProgress(player, this);

            if (jobProgress == null)
            {
                return;
            }

            if (!m_PlayersCompleted.Contains(player))
            {
                m_PlayersCompleted.Add(player);
            }

            SocietyGroupPlayerData societyGroupPlayerData = player.m_SocietiesPlayerSettings.GetSocietyGroupPlayerData(m_SocietiesGroupType);

            if (societyGroupPlayerData != null)
            {
                societyGroupPlayerData.m_PointsAvailable += m_PointValue;
                societyGroupPlayerData.m_MontlyPoints    += m_PointValue;
                societyGroupPlayerData.m_LifetimePoints  += m_PointValue;

                player.SendMessage(Societies.GetSocietyGroupTextHue(m_SocietiesGroupType), "You have been awarded " + m_PointValue.ToString() + " with the " + Societies.GetSocietyGroupName(m_SocietiesGroupType) + " for completion of a job contract.");
            }

            if (jobProgress.m_JobContract != null)
            {
                jobProgress.m_JobContract.JobStatus = SocietiesJobContract.JobStatusType.Completed;
            }

            player.m_SocietiesPlayerSettings.m_JobProgress.Remove(jobProgress);

            Account account = player.Account as Account;

            foreach (Mobile mobile in account.accountMobiles)
            {
                PlayerMobile pm_Target = mobile as PlayerMobile;

                if (pm_Target == null)
                {
                    continue;
                }
                if (pm_Target == player)
                {
                    continue;
                }

                Societies.CheckCreateSocietiesPlayerSettings(pm_Target);

                SocietyJobPlayerProgress otherPlayerJobProgress = Societies.GetSocietiesJobPlayerProgress(player, this);

                if (otherPlayerJobProgress == null)
                {
                    continue;
                }

                if (otherPlayerJobProgress.m_JobContract != null)
                {
                    otherPlayerJobProgress.m_JobContract.JobStatus = SocietiesJobContract.JobStatusType.Completed;
                }

                player.m_SocietiesPlayerSettings.m_JobProgress.Remove(otherPlayerJobProgress);
            }
        }
Example #8
0
        public bool TurnIn(PlayerMobile player, Mobile vendor)
        {
            bool completed = false;

            if (player == null)
            {
                return(false);
            }
            if (player.Backpack == null)
            {
                return(false);
            }

            SocietyJobPlayerProgress jobProgress = Societies.GetSocietiesJobPlayerProgress(player, this);

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

            if (m_TurnInRequirementAmount >= 1)
            {
                bool turnInItem     = false;
                bool turnInCreature = false;

                double remainingNeeded = m_TurnInRequirementAmount - jobProgress.m_TurnedInAmount;
                int    amountTurnedIn  = 0;

                Queue m_Queue = new Queue();

                if (m_JobType == JobType.CraftItem || m_JobType == JobType.RetrieveFish || m_JobType == JobType.StealItem)
                {
                    turnInItem = true;

                    Item[] m_MatchingItems = player.Backpack.FindItemsByType(m_PrimaryType);

                    foreach (Item item in m_MatchingItems)
                    {
                        if (item == null)
                        {
                            continue;
                        }
                        if (m_CraftResourceRequired != CraftResource.None && item.Resource != m_CraftResourceRequired)
                        {
                            continue;
                        }
                        if (m_PrimaryJobModifier == JobModifierType.ExceptionalQuality && item.Quality != Quality.Exceptional)
                        {
                            continue;
                        }
                        if (m_SecondaryJobModifier == JobModifierType.ExceptionalQuality && item.Quality != Quality.Exceptional)
                        {
                            continue;
                        }

                        jobProgress.m_TurnedInAmount++;
                        amountTurnedIn++;
                        remainingNeeded--;

                        m_Queue.Enqueue(item);

                        if (remainingNeeded <= 0)
                        {
                            break;
                        }
                    }

                    while (m_Queue.Count > 0)
                    {
                        Item mobile = (Item)m_Queue.Dequeue();
                        mobile.Delete();
                    }
                }

                else if (m_JobType == JobType.TameCreature)
                {
                    turnInCreature = true;

                    for (int a = 0; a < player.AllFollowers.Count; a++)
                    {
                        Mobile follower = player.AllFollowers[a];

                        if (follower.GetType() != m_PrimaryType)
                        {
                            continue;
                        }
                        if (follower == null)
                        {
                            continue;
                        }
                        if (!follower.Alive || follower.IsDeadBondedFollower)
                        {
                            continue;
                        }
                        if (Utility.GetDistance(follower.Location, vendor.Location) >= 12)
                        {
                            continue;
                        }

                        jobProgress.m_TurnedInAmount++;
                        amountTurnedIn++;
                        remainingNeeded--;

                        m_Queue.Enqueue(follower);

                        if (remainingNeeded <= 0)
                        {
                            break;
                        }
                    }

                    while (m_Queue.Count > 0)
                    {
                        Mobile mobile = (Mobile)m_Queue.Dequeue();
                        mobile.Delete();
                    }
                }

                if (amountTurnedIn == 0)
                {
                    if (turnInCreature)
                    {
                        player.SendMessage("You do not have any of the required creatures nearby needed to complete that job.");
                    }

                    else if (turnInItem)
                    {
                        player.SendMessage("You do not have any of the required items neccessary to complete that job in your backpack.");
                    }

                    return(false);
                }

                else if (amountTurnedIn > 0 && remainingNeeded > 0)
                {
                    if (turnInCreature)
                    {
                        player.SendMessage("You turn in some of the creatures neccessary for this job but still require more to complete it fully.");
                    }

                    else if (turnInItem)
                    {
                        player.SendMessage("You turn in some of the items neccessary for this job but still require more to complete it fully.");
                    }

                    return(false);
                }

                else
                {
                    return(true);
                }
            }

            else if (jobProgress.m_ProgressAmount >= m_TargetNumber)
            {
                return(true);
            }

            return(completed);
        }