コード例 #1
0
        public static SocietyJobPlayerProgress GetSocietiesJobPlayerProgress(PlayerMobile player, SocietyJob job)
        {
            SocietyJobPlayerProgress jobPlayerProgress = null;

            if (player == null)
            {
                return(jobPlayerProgress);
            }
            if (job == null)
            {
                return(jobPlayerProgress);
            }

            CheckCreateSocietiesPlayerSettings(player);

            foreach (SocietyJobPlayerProgress jobPlayerProgressEntry in player.m_SocietiesPlayerSettings.m_JobProgress)
            {
                if (jobPlayerProgressEntry == null)
                {
                    continue;
                }
                if (jobPlayerProgressEntry.m_Job == job)
                {
                    return(jobPlayerProgressEntry);
                }
            }

            return(jobPlayerProgress);
        }
コード例 #2
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);
        }
コード例 #3
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            CreateSocietyData();

            //Version 0
            if (version >= 0)
            {
                m_Player = reader.ReadMobile() as PlayerMobile;

                int jobProgressCount = reader.ReadInt();
                for (int a = 0; a < jobProgressCount; a++)
                {
                    SocietyJob           job         = reader.ReadItem() as SocietyJob;
                    SocietiesJobContract jobContract = reader.ReadItem() as SocietiesJobContract;
                    double primaryProgress           = reader.ReadDouble();
                    double secondaryProgress         = reader.ReadDouble();

                    if (job == null)
                    {
                        continue;
                    }
                    if (job.Deleted)
                    {
                        continue;
                    }

                    SocietyJobPlayerProgress jobProgress = new SocietyJobPlayerProgress(job);
                    jobProgress.m_JobContract    = jobContract;
                    jobProgress.m_ProgressAmount = primaryProgress;
                    jobProgress.m_TurnedInAmount = secondaryProgress;

                    m_JobProgress.Add(jobProgress);
                }

                int recordedSocietyGroupDataCount = reader.ReadInt();
                for (int a = 0; a < recordedSocietyGroupDataCount; a++)
                {
                    SocietiesGroupType societyGroupType = (SocietiesGroupType)reader.ReadInt();

                    int pointsAvailable = reader.ReadInt();
                    int monthlyPoints   = reader.ReadInt();
                    int lifetimePoints  = reader.ReadInt();
                    int pointsSpent     = reader.ReadInt();

                    foreach (SocietyGroupPlayerData societyGroupPlayerData in m_SocietyPlayerData)
                    {
                        if (societyGroupPlayerData.m_SocietyGroupType == societyGroupType)
                        {
                            societyGroupPlayerData.m_PointsAvailable = pointsAvailable;
                            societyGroupPlayerData.m_MontlyPoints    = monthlyPoints;
                            societyGroupPlayerData.m_LifetimePoints  = lifetimePoints;
                            societyGroupPlayerData.m_PointsSpent     = pointsSpent;

                            break;
                        }
                    }
                }
            }

            //-----

            if (m_Player != null)
            {
                m_Player.m_SocietiesPlayerSettings = this;
            }

            else
            {
                Delete();
            }
        }
コード例 #4
0
        public static void CheckForExpiredSocietyJobs()
        {
            List <SocietyJob> m_ExpiredJobs = new List <SocietyJob>();
            Queue             m_Queue       = new Queue();

            foreach (SocietyJob societyJob in m_SocietyJobs)
            {
                if (societyJob.m_Expiration <= DateTime.UtcNow)
                {
                    m_ExpiredJobs.Add(societyJob);
                    m_Queue.Enqueue(societyJob);
                }
            }

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

                PlayerMobile player = mobile as PlayerMobile;

                CheckCreateSocietiesPlayerSettings(player);

                int expiredJobCount = 0;

                foreach (SocietyJob societyJob in m_ExpiredJobs)
                {
                    for (int a = 0; a < player.m_SocietiesPlayerSettings.m_JobProgress.Count; a++)
                    {
                        SocietyJobPlayerProgress jobPlayerProgress = player.m_SocietiesPlayerSettings.m_JobProgress[a];

                        if (jobPlayerProgress == null)
                        {
                            continue;
                        }

                        if (jobPlayerProgress.m_Job == societyJob)
                        {
                            if (jobPlayerProgress.m_JobContract != null)
                            {
                                jobPlayerProgress.m_JobContract.JobStatus = SocietiesJobContract.JobStatusType.Expired;
                            }

                            player.m_SocietiesPlayerSettings.m_JobProgress.RemoveAt(a);

                            expiredJobCount++;

                            break;
                        }
                    }
                }

                if (expiredJobCount > 0)
                {
                    player.SendMessage("One or more of your society job contracts have expired.");
                }
            }

            while (m_Queue.Count > 0)
            {
                SocietyJob societyJob = (SocietyJob)m_Queue.Dequeue();
                societyJob.Delete();
            }
        }
コード例 #5
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;
                }
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
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);
        }