public void EvaluateAndApplyAllRules_RandomlyGeneratedCharacter_ValuesNormalizedAfterCall() { //Arrange QualityRuleEvaluator evaluator = new QualityRuleEvaluator(); CharacterTraits traits = new CharacterTraits("Lara Croft", Sex.Female) { Adaptiveness = 90, Changing = 45, Inventiveness = 20, Imagination = 66, WeakPoints = new List <string> { "Inventiveness" }, StrongPoints = new List <string> { "Adaptiveness" } }; var currentQualityValues = traits.GetPersonalQualitiesValues(); //Act evaluator.EvaluateAndApplyAllRules(traits); var newValues = traits.GetPersonalQualitiesValues(); int differenceCount = currentQualityValues.Count(qualityValue => qualityValue.Value != newValues[qualityValue.Key]); //Assert Assert.IsTrue(differenceCount > 0); }
public void Initialize_NewCharacterTraits_ValuesInitializedAndAdjusted() { CharacterTraits traits = new CharacterTraits("Ronald McDonald", Sex.Male, Orientation.Straight, Gender.Male); new RandomInitializationMethod().Initialize(ref traits, new QualityRuleEvaluator(), new EmotionRuleEvaluator()); Assert.IsFalse(traits.GetPersonalQualitiesValues().Any(x => x.Value == 0)); Assert.IsTrue(traits.PersonalValues.Count == 3); Assert.IsFalse(traits.GetEmotionalStateValues().Any(x => x.Value > 12)); }
public void GetPersonalQualitiesValues_NormalCharacterCreation_29QualitiesExpected() { //Arrange CharacterTraits traits = new CharacterTraits("Fred Flintstone", Sex.Male); //Act var list = traits.GetPersonalQualitiesValues(); //Assert Assert.AreEqual(list.Count, CharacterTraits.GetPersonalQualitiesCount()); }
public void New_WithValidArguments_ClassInstantiated() { //ACT CharacterTraits traits = new CharacterTraits("Sterling Archer", Sex.Male, Orientation.Bisexual); var emotions = traits.GetEmotionalStateValues(); var qualities = traits.GetPersonalQualitiesValues(); traits.SetQualityAttributeByName("Adaptiveness", 99); traits.ResetEmotions(); Assert.AreEqual(qualities.Count, CharacterTraits.GetPersonalQualitiesCount()); Assert.AreEqual(emotions.Count, CharacterTraits.GetEmotionalStatesCount()); Assert.AreEqual(traits.Sex, Sex.Male); Assert.AreEqual(traits.Orientation, Orientation.Bisexual); Assert.AreNotEqual(traits.InternalId, String.Empty); }
///<inheritdoc/> protected override void AdjustQualitiesAccordingToArchetype(CharacterTraits traits) { while (StrongPoints.Count < 4) { int randomTraitIndex = RandomValueGenerator.GenerateIntWithMaxValue(CharacterTraits.GetPersonalQualitiesCount() - 1); var property = traits.GetQualityPropertyByIndex(randomTraitIndex); if (property == null || StrongPoints.Contains(property.Name) || WeakPoints.Contains(property.Name)) { continue; } property.SetValue(traits, RandomValueGenerator.GenerateStrongAttributeValue()); StrongPoints.Add(property.Name); } var weakPoints = traits.GetPersonalQualitiesValues().Where(quality => quality.Value <= 20).ToList(); WeakPoints.AddRange(weakPoints.Select(x => x.Key).Take(2)); while (WeakPoints.Count < 2) { int randomTraitIndex = RandomValueGenerator.GenerateIntWithMaxValue(CharacterTraits.GetPersonalQualitiesCount() - 1); var property = traits.GetQualityPropertyByIndex(randomTraitIndex); if (property == null || StrongPoints.Contains(property.Name) || WeakPoints.Contains(property.Name)) { continue; } property.SetValue(traits, RandomValueGenerator.GenerateWeakAttributeValue()); WeakPoints.Add(property.Name); } }
private int CalculateNbOfStrongPoints(CharacterTraits traits) { return(traits.GetPersonalQualitiesValues().Count(q => q.Value >= Constants.MinStrongPoint)); }
private int CalculateNbOfWeakPoints(CharacterTraits traits) { return(traits.GetPersonalQualitiesValues().Count(q => q.Value <= Constants.MaxWeakPoint)); }