/// <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); }
/// <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)); }
/// <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); }
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); //} } }
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); } } }
/// <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); }
public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord) { return(achievementProgressRecord.Counter >= this.ReputationAmount); }
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); }
public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord) { return(achievementProgressRecord.Counter >= NumberOfVisitsAtBarberShop); }
public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord) { return(achievementProgressRecord.Counter >= NumberOfBankSlots); }
public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord) { return(achievementProgressRecord.Counter >= (uint)SkillTierId); }
public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord) { return(achievementProgressRecord.Counter >= this.CompletedQuestCount); }
/// <summary> /// Removes criteria progress from the player. /// </summary> /// <param name="achievementProgressRecord"></param> public void RemoveProgress(AchievementProgressRecord achievementProgressRecord) { m_progressRecords.Remove(achievementProgressRecord.AchievementCriteriaId); }
/// <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); }
public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord) { return(achievementProgressRecord.Counter >= this.NumberOfDays); }
public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord) { return(achievementProgressRecord.Counter >= 1U); }
public override bool IsAchieved(AchievementProgressRecord achievementProgressRecord) { return(achievementProgressRecord.Counter >= this.countOfEmotes); }