public void TestRankCalculator() { const int experienceForOneLevel = 2758; var returnedRank = ExperienceCalculator.GetPlayerLevelFromExperienceTotal(0); Assert.AreEqual(returnedRank, PlayerLevel.TypoL1); returnedRank = ExperienceCalculator.GetPlayerLevelFromExperienceTotal(experienceForOneLevel - 1); Assert.AreEqual(returnedRank, PlayerLevel.TypoL1); returnedRank = ExperienceCalculator.GetPlayerLevelFromExperienceTotal(experienceForOneLevel); Assert.AreEqual(returnedRank, PlayerLevel.TypoL2); returnedRank = ExperienceCalculator.GetPlayerLevelFromExperienceTotal(experienceForOneLevel + 1); Assert.AreEqual(returnedRank, PlayerLevel.TypoL2); returnedRank = ExperienceCalculator.GetPlayerLevelFromExperienceTotal(3 * experienceForOneLevel - 1); Assert.AreEqual(returnedRank, PlayerLevel.TypoL2); returnedRank = ExperienceCalculator.GetPlayerLevelFromExperienceTotal(3 * experienceForOneLevel); Assert.AreEqual(returnedRank, PlayerLevel.TypoL3); returnedRank = ExperienceCalculator.GetPlayerLevelFromExperienceTotal(10000000); Assert.AreEqual(returnedRank, PlayerLevel.TheTruthL3); }
private static IJiraQuest PrepareJiraQuest() { IExperienceCalculator expCalculator = new ExperienceCalculator(); IJiraQuest quest = new JiraQuest(expCalculator); quest.SprintPoints = 8; quest.EstimatedCompletionTime = 7.5; quest.RealTime = 10; return(quest); }
public void Process(UnitHasDiedEvent eventData) { var receivingUnit = eventData.Killer; receivingUnit.Stats.AddExperience(eventData.Target.Stats.Experience()); var nextLevelThreshold = ExperienceCalculator.GetExperienceRequiredForLevel(receivingUnit.Class.Level + 1); if (receivingUnit.Stats.Experience() >= nextLevelThreshold) { receivingUnit.Class.Level++; receivingUnit.Stats.RemoveExperience(nextLevelThreshold); EventSystem.Publish(new UnitLeveledUpEvent(receivingUnit)); } }
private void CalculatePlayerExperience() { var localPlayer = _navigationArgs.GameData.PlayerDictionary[Settings.Alias]; var expEarned = ExperienceCalculator.GetGameExperienceEarned(localPlayer); Settings.Experience += expEarned; var postGameRank = ExperienceCalculator.GetPlayerLevelFromExperienceTotal(expEarned); if ((int)postGameRank != Settings.Level) { Settings.Level = (int)postGameRank; //ToDo: RE-enable; Currently this throws a SystemUnauthorizedAccess exception during dialog.ShowAsync(); //ShowLevelUpAnimation(postGameRank); } }