예제 #1
0
        /// <summary>
        /// Returns the corresponding ProgressRecord. Creates a new one if the player doesn't have progress record.
        /// </summary>
        /// <param name="achievementCriteriaId"></param>
        /// <returns></returns>
        internal AchievementProgressRecord GetOrCreateProgressRecord(uint achievementCriteriaId)
        {
            AchievementProgressRecord achievementProgressRecord;

            if (!m_progressRecords.TryGetValue(achievementCriteriaId, out achievementProgressRecord))
            {
                achievementProgressRecord = AchievementProgressRecord.CreateAchievementProgressRecord(Owner, achievementCriteriaId, 0);
                AddProgressRecord(achievementProgressRecord);
            }
            return(achievementProgressRecord);
        }
예제 #2
0
        /// <summary>Checks if the given criteria is completable</summary>
        /// <param name="achievementCriteriaEntry"></param>
        /// <returns></returns>
        public bool IsCriteriaCompletable(AchievementCriteriaEntry achievementCriteriaEntry)
        {
            if (achievementCriteriaEntry.AchievementEntry.Flags.HasFlag((Enum)AchievementFlags.Counter))
            {
                return(false);
            }
            AchievementProgressRecord criteriaProgress =
                this.m_owner.Achievements.GetAchievementCriteriaProgress(achievementCriteriaEntry
                                                                         .AchievementCriteriaId);

            if (criteriaProgress == null)
            {
                return(false);
            }
            return(achievementCriteriaEntry.IsAchieved(criteriaProgress));
        }
예제 #3
0
        /// <summary>Sets the progress with a given Criteria entry.</summary>
        /// <param name="entry"></param>
        /// <param name="newValue"></param>
        /// <param name="progressType"></param>
        internal void SetCriteriaProgress(AchievementCriteriaEntry entry, uint newValue,
                                          ProgressType progressType = ProgressType.ProgressSet)
        {
            if (newValue == 0U)
            {
                return;
            }
            AchievementProgressRecord progressRecord = this.GetOrCreateProgressRecord(entry.AchievementCriteriaId);
            uint num;

            switch (progressType)
            {
            case ProgressType.ProgressAccumulate:
                num = newValue + progressRecord.Counter;
                break;

            case ProgressType.ProgressHighest:
                num = progressRecord.Counter < newValue ? newValue : progressRecord.Counter;
                break;

            default:
                num = newValue;
                break;
            }

            if ((int)num == (int)progressRecord.Counter)
            {
                return;
            }
            progressRecord.Counter = num;
            if (entry.TimeLimit > 0U)
            {
                DateTime now = DateTime.Now;
                if (progressRecord.StartOrUpdateTime.AddSeconds((double)entry.TimeLimit) < now)
                {
                    progressRecord.Counter = 1U;
                }
                progressRecord.StartOrUpdateTime = now;
            }

            AchievementHandler.SendAchievmentStatus(progressRecord, this.Owner);
            if (!this.IsAchievementCompletable(entry.AchievementEntry))
            {
                return;
            }
            this.EarnAchievement(entry.AchievementEntry);
        }
예제 #4
0
        public void Load()
        {
            foreach (var mCompletedAchievement in AchievementRecord.Load((int)Owner.EntityId.Low))
            {
                var achievement = AchievementMgr.GetAchievementEntry(mCompletedAchievement.AchievementEntryId);
                if (achievement != null)
                {
                    if (m_completedAchievements.ContainsKey(achievement.ID))
                    {
                        log.Warn("Character {0} had Achievement {1} more than once.", m_owner, achievement.ID);
                    }
                    else
                    {
                        AddAchievement(mCompletedAchievement);
                    }
                }
                else
                {
                    log.Warn("Character {0} has invalid Achievement: {1}", m_owner, mCompletedAchievement.AchievementEntryId);
                }
            }

            foreach (var achievementProgress in AchievementProgressRecord.Load((int)Owner.EntityId.Low))
            {
                // how to check if there's no criteria
                //if (achievement != null)
                {
                    if (m_progressRecords.ContainsKey(achievementProgress.AchievementCriteriaId))
                    {
                        log.Warn("Character {0} had progress for Achievement Criteria {1} more than once.", m_owner, achievementProgress.AchievementCriteriaId);
                    }
                    else
                    {
                        AddProgressRecord(achievementProgress);
                    }
                }
                //else
                //{
                //    log.Warn("Character {0} has invalid Achievement: {1}", m_owner, achivementProgress.AchievementCriteriaId);
                //}
            }
        }
예제 #5
0
        public void Load()
        {
            foreach (AchievementRecord achievementRecord in AchievementRecord.Load((int)this.Owner.EntityId.Low))
            {
                AchievementEntry achievementEntry =
                    AchievementMgr.GetAchievementEntry(achievementRecord.AchievementEntryId);
                if (achievementEntry != null)
                {
                    if (this.m_completedAchievements.ContainsKey(achievementEntry.ID))
                    {
                        AchievementCollection.log.Warn("Character {0} had Achievement {1} more than once.",
                                                       (object)this.m_owner, (object)achievementEntry.ID);
                    }
                    else
                    {
                        this.AddAchievement(achievementRecord);
                    }
                }
                else
                {
                    AchievementCollection.log.Warn("Character {0} has invalid Achievement: {1}", (object)this.m_owner,
                                                   (object)achievementRecord.AchievementEntryId);
                }
            }

            foreach (AchievementProgressRecord achievementProgressRecord in AchievementProgressRecord.Load(
                         (int)this.Owner.EntityId.Low))
            {
                if (this.m_progressRecords.ContainsKey(achievementProgressRecord.AchievementCriteriaId))
                {
                    AchievementCollection.log.Warn(
                        "Character {0} had progress for Achievement Criteria {1} more than once.",
                        (object)this.m_owner, (object)achievementProgressRecord.AchievementCriteriaId);
                }
                else
                {
                    this.AddProgressRecord(achievementProgressRecord);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Checks if the given criteria is completable
        /// </summary>
        /// <param name="achievementCriteriaEntry"></param>
        /// <returns></returns>
        public bool IsCriteriaCompletable(AchievementCriteriaEntry achievementCriteriaEntry)
        {
            AchievementEntry achievementEntry = achievementCriteriaEntry.AchievementEntry;

            // Counter achievement were never meant to be completed.
            if (achievementEntry.Flags.HasFlag(AchievementFlags.Counter))
            {
                return(false);
            }

            //TODO: Add support for realm first.

            // We never completed the criteria befoer.
            AchievementProgressRecord achievementProgressRecord =
                m_owner.Achievements.GetAchievementCriteriaProgress(achievementCriteriaEntry.AchievementCriteriaId);

            if (achievementProgressRecord == null)
            {
                return(false);
            }
            return(achievementCriteriaEntry.IsAchieved(achievementProgressRecord));
        }
 public virtual bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return(false);
 }
예제 #8
0
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return(achievementProgressRecord.Counter >= this.ReputationAmount);
 }
예제 #9
0
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return(achievementProgressRecord.Counter >= this.SkillValue);
 }
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return(achievementProgressRecord.Counter >= this.NumberOfExaltedReputations);
 }
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return((SkillTierId)achievementProgressRecord.Counter >= this.SkillTierId);
 }
예제 #12
0
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return(achievementProgressRecord.Counter >= NumberOfVisitsAtBarberShop);
 }
예제 #13
0
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return(achievementProgressRecord.Counter >= NumberOfBankSlots);
 }
예제 #14
0
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return(achievementProgressRecord.Counter >= (uint)SkillTierId);
 }
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return(achievementProgressRecord.Counter >= this.CompletedQuestCount);
 }
예제 #16
0
 /// <summary>
 /// Removes criteria progress from the player.
 /// </summary>
 /// <param name="achievementProgressRecord"></param>
 public void RemoveProgress(AchievementProgressRecord achievementProgressRecord)
 {
     m_progressRecords.Remove(achievementProgressRecord.AchievementCriteriaId);
 }
예제 #17
0
 /// <summary>
 /// Adds a new progress record to the list.
 /// </summary>
 /// <param name="achievementProgressRecord"></param>
 void AddProgressRecord(AchievementProgressRecord achievementProgressRecord)
 {
     m_progressRecords.Add(achievementProgressRecord.AchievementCriteriaId, achievementProgressRecord);
 }
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return achievementProgressRecord.Counter >= this.Height;
 }
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return((long)achievementProgressRecord.Counter >= (long)this.CreatureCount);
 }
예제 #20
0
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return(achievementProgressRecord.Counter >= this.NumberOfDays);
 }
예제 #21
0
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return(achievementProgressRecord.Counter >= 1U);
 }
 public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord)
 {
     return(achievementProgressRecord.Counter >= this.countOfEmotes);
 }