/// <summary>
        /// Evaluates all rules and applies them
        /// </summary>
        /// <param name="traits">character traits</param>
        public void EvaluateAndApplyAllRules(CharacterTraits traits)
        {
            var rules = GetAllEmotionalTraitRules();

            foreach (var rule in rules)
            {
                var quality = traits.GetType().GetProperty(rule.Quality);
                var emotion = traits.LongTermEmotions.GetType().GetProperty(rule.Emotion);

                if (quality == null || emotion == null)
                {
                    continue;
                }

                int randomValue         = RandomValueGenerator.GeneratePercentileIntegerValue();
                int qualityValue        = (int)quality.GetValue(traits);
                int currentEmotionValue = (int)emotion.GetValue(traits.LongTermEmotions);

                if (rule.IsComparedBelowQualityValue && qualityValue > randomValue ||
                    (!rule.IsComparedBelowQualityValue && qualityValue < randomValue))
                {
                    //If conditions are met, emotion is modified, but by at most 3.
                    emotion.SetValue(traits.LongTermEmotions, currentEmotionValue + RandomValueGenerator.GenerateIntWithMaxValue(3));
                }
            }
        }
示例#2
0
        private static string GetRandomEventName(Type eventEnumType)
        {
            int possibilities = Enum.GetNames(eventEnumType).Length;

            int index = RandomValueGenerator.GenerateIntWithMaxValue(possibilities);

            return(eventEnumType.GetEnumValues().GetValue(index - 1).ToString());
        }
        ///<inheritdoc/>
        protected override void SetPersonalValuesAccordingToArchetype(CharacterTraits traits)
        {
            int numberOfValues = Enum.GetValues(typeof(PersonalValues)).Length;

            while (traits.PersonalValues.Count < 3)
            {
                int valueIndex = RandomValueGenerator.GenerateIntWithMaxValue(numberOfValues);

                var personalValue = (PersonalValues)valueIndex;

                if (!traits.PersonalValues.Contains(personalValue))
                {
                    traits.PersonalValues.Add(personalValue);
                }
            }
        }
示例#4
0
        /// <inheritdoc />
        /// <summary>
        /// Returns a copy of the object with all the information copied inaccurately
        /// this represents the character having wrong information
        /// </summary>
        /// <returns>Item with the information</returns>
        public override MemoryItem GetInaccurateCopy()
        {
            GameTime.GameTime birthDate   = DateOfBirth;
            GameTime.GameTime deathDate   = DateOfDeath;
            Orientation       orientation = Orientation;
            //TODO : Randomize name

            int falsificationCase = RandomValueGenerator.GenerateIntWithMaxValue(4);

            switch (falsificationCase)
            {
            case 1:
                int variance = RandomValueGenerator.GenerateRealWithinValues(-30, 30);
                birthDate?.SetYear(birthDate.GetYear() + variance);
                break;

            case 2:
                int deathVariance = RandomValueGenerator.GenerateRealWithinValues(-30, 30);
                deathDate?.SetYear(deathDate.GetYear() + deathVariance);
                break;

            case 3:
                orientation = (Orientation)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(Orientation)).Length);
                break;

            case 4:
                variance = RandomValueGenerator.GenerateRealWithinValues(-30, 30);
                birthDate?.SetYear(birthDate.GetYear() + variance);
                orientation = (Orientation)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(Orientation)).Length);
                break;
            }

            Person copy = new Person(Name, Gender, Sex, orientation, ReferenceId)
            {
                DateOfBirth    = birthDate,
                DateOfDeath    = deathDate,
                Description    = Description,
                ItemType       = ItemType,
                _associations  = _associations,
                _linkedEvents  = _linkedEvents,
                _linkedPlaces  = _linkedPlaces,
                _occupations   = _occupations,
                _relationships = _relationships
            };

            return(copy);
        }
示例#5
0
        /// <summary>
        /// Provides a random event message
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="actionType"></param>
        /// <param name="intentType"></param>
        /// <returns></returns>
        private static string GetRandomMessage(string eventName, ActionType actionType, Intent intentType)
        {
            if (actionType == ActionType.NonVerbal || actionType == ActionType.Physical)
            {
                return(string.Empty);
            }

            switch (intentType)
            {
            case Intent.Friendly:
                return("My friend...");

            case Intent.Neutral:
                return("Well...");

            case Intent.Hostile:
                int index = RandomValueGenerator.GenerateIntWithMaxValue(5);

                if (eventName == "Threat")
                {
                    switch (index)
                    {
                    case 1:
                        return("I'm going to punch your face!");

                    case 2:
                        return("When I'm done with you, you'll be the same of your family!");

                    case 3:
                        return("I'm going to leave you!");

                    case 4:
                        return("I will ruin you!");

                    case 5:
                        return("God wil damn you!");
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(intentType), intentType, null);
            }

            return(string.Empty);
        }
示例#6
0
        /// <summary>
        /// Returns a copy of the object with all the information copied inaccurately
        /// this represents the character having wrong information
        /// </summary>
        /// <returns>Item with the information</returns>
        public override MemoryItem GetInaccurateCopy()
        {
            GameTime.GameTime creation    = Creation;
            GameTime.GameTime destruction = Destruction;
            PlaceType         placeType   = Type;

            //TODO : Randomize name

            int falsificationCase = RandomValueGenerator.GenerateIntWithMaxValue(4);

            switch (falsificationCase)
            {
            case 1:
                int variance = RandomValueGenerator.GenerateRealWithinValues(-30, 30);
                creation?.SetYear(creation.GetYear() + variance);
                break;

            case 2:
                int deathVariance = RandomValueGenerator.GenerateRealWithinValues(-30, 30);
                destruction?.SetYear(destruction.GetYear() + deathVariance);
                break;

            case 3:
                placeType = (PlaceType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(PlaceType)).Length);
                break;

            case 4:
                placeType = (PlaceType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(PlaceType)).Length);
                variance  = RandomValueGenerator.GenerateRealWithinValues(-30, 30);
                creation?.SetYear(creation.GetYear() + variance);
                break;
            }

            var copy = new Place(Name, ReferenceId, Coordinates, Description, Creation, Destruction)
            {
                Type                = placeType,
                ItemType            = ItemType,
                _linkedPlaces       = _linkedPlaces,
                _linkedEvents       = _linkedEvents,
                _linkedPersons      = _linkedPersons,
                _relatedOccupations = _relatedOccupations
            };

            return(copy);
        }
        /// <inheritdoc />
        public override MemoryItem GetInaccurateCopy()
        {
            GameTime.GameTime   started = Started;
            GameTime.GameTime   ended   = Ended;
            OccupationalTieType type    = Type;

            //TODO : Randomize name

            int falsificationCase = RandomValueGenerator.GenerateIntWithMaxValue(4);

            switch (falsificationCase)
            {
            case 1:
                int variance = RandomValueGenerator.GenerateRealWithinValues(-10, 10);
                started?.SetYear(started.GetYear() + variance);
                break;

            case 2:
                int deathVariance = RandomValueGenerator.GenerateRealWithinValues(-10, 10);
                ended?.SetYear(ended.GetYear() + deathVariance);
                break;

            case 3:
                type = (OccupationalTieType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(OccupationalTieType)).Length);
                break;

            case 4:
                type     = (OccupationalTieType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(OccupationalTieType)).Length);
                variance = RandomValueGenerator.GenerateRealWithinValues(-10, 10);
                started?.SetYear(started.GetYear() + variance);
                break;
            }

            var copy = new OccupationalTie(LinkedLocation, LinkedOccupation, type, ReferenceId)
            {
                ItemType           = ItemType,
                Description        = Description,
                Started            = started,
                Ended              = ended,
                ReverseDescription = ReverseDescription,
                Name = Name
            };

            return(copy);
        }
示例#8
0
        /// <summary>
        /// Returns a copy of the object with all the information copied inaccurately
        /// this represents the character having wrong information
        /// </summary>
        /// <returns>Item with the information</returns>
        public override MemoryItem GetInaccurateCopy()
        {
            GameTime.GameTime started = Started;
            GameTime.GameTime ended   = Ended;
            PastEventType     type    = Type;

            //TODO : Randomize name

            int falsificationCase = RandomValueGenerator.GenerateIntWithMaxValue(4);

            switch (falsificationCase)
            {
            case 1:
                int variance = RandomValueGenerator.GenerateRealWithinValues(-15, 15);
                started?.SetYear(started.GetYear() + variance);
                break;

            case 2:
                int deathVariance = RandomValueGenerator.GenerateRealWithinValues(-15, 15);
                ended?.SetYear(ended.GetYear() + deathVariance);
                break;

            case 3:
                type = (PastEventType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(PastEventType)).Length);
                break;

            case 4:
                type     = (PastEventType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(PastEventType)).Length);
                variance = RandomValueGenerator.GenerateRealWithinValues(-15, 15);
                started?.SetYear(started.GetYear() + variance);
                break;
            }

            var copy = new PastEvent(Name, ReferenceId, Description, started, ended)
            {
                ItemType           = ItemType,
                _linkedPlaces      = _linkedPlaces,
                _linkedEvents      = _linkedEvents,
                _linkedOccupations = _linkedOccupations,
                _linkedPersons     = _linkedPersons,
                Type = type
            };

            return(copy);
        }
示例#9
0
        private static string GetRandomSource()
        {
            switch (RandomValueGenerator.GenerateIntWithMaxValue(4))
            {
            case 1:
                return("An_Enemy");

            case 2:
                return("A_Stranger");

            case 3:
                return("Tested_Friend");

            case 4:
                return("Another_Stranger");
            }

            return("The_Unknown");
        }
示例#10
0
        /// <summary>
        /// Returns a copy of the object with all the information copied inaccurately
        /// this represents the character having wrong information
        /// </summary>
        /// <returns>Item with the information</returns>
        public override MemoryItem GetInaccurateCopy()
        {
            GameTime.GameTime started = Started;
            GameTime.GameTime ended   = Ended;
            OrganizationType  type    = Type;

            //TODO : Randomize name

            int falsificationCase = RandomValueGenerator.GenerateIntWithMaxValue(4);

            switch (falsificationCase)
            {
            case 1:
                int variance = RandomValueGenerator.GenerateRealWithinValues(-30, 30);
                started?.SetYear(started.GetYear() + variance);
                break;

            case 2:
                int deathVariance = RandomValueGenerator.GenerateRealWithinValues(-30, 30);
                ended?.SetYear(ended.GetYear() + deathVariance);
                break;

            case 3:
                type = (OrganizationType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(OrganizationType)).Length);
                break;

            case 4:
                type     = (OrganizationType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(OrganizationType)).Length);
                variance = RandomValueGenerator.GenerateRealWithinValues(-30, 30);
                started?.SetYear(started.GetYear() + variance);
                break;
            }

            Organization copy = new Organization(Name, type, ReferenceId, Description)
            {
                ItemType      = ItemType,
                Started       = started,
                Ended         = ended,
                _associations = _associations
            };

            return(copy);
        }
示例#11
0
        /// <inheritdoc />
        public override MemoryItem GetInaccurateCopy()
        {
            global::RNPC.Core.GameTime.GameTime started = Started;
            global::RNPC.Core.GameTime.GameTime ended   = Ended;
            AssociationType type = Type;

            //TODO : Randomize name

            int falsificationCase = RandomValueGenerator.GenerateIntWithMaxValue(4);

            switch (falsificationCase)
            {
            case 1:
                int variance = RandomValueGenerator.GenerateRealWithinValues(-15, 15);
                started?.SetYear(started.GetYear() + variance);
                break;

            case 2:
                int deathVariance = RandomValueGenerator.GenerateRealWithinValues(-15, 15);
                ended?.SetYear(ended.GetYear() + deathVariance);
                break;

            case 3:
                type = (AssociationType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(AssociationType)).Length);
                break;

            case 4:
                type     = (AssociationType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(AssociationType)).Length);
                variance = RandomValueGenerator.GenerateRealWithinValues(-15, 15);
                started?.SetYear(started.GetYear() + variance);
                break;
            }

            Association copy = new Association(AssociatedPerson, AssociatedOrganization, type, ReferenceId, started, ended)
            {
                ItemType           = ItemType,
                ReverseDescription = ReverseDescription
            };

            return(copy);
        }
        ///<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);
            }
        }
示例#13
0
        /// <summary>
        /// Adds 1 to 4 additional strong points
        /// </summary>
        /// <param name="traits"></param>
        protected void AddRandomStrongPoint(CharacterTraits traits)
        {
            int numberOfStrongPoints  = 4;
            int demographicPercentage = RandomValueGenerator.GeneratePercentileIntegerValue();

            if (demographicPercentage > int.Parse(TraitDistribution.StrongPointTier1) &&
                demographicPercentage <= int.Parse(TraitDistribution.StrongPointTier2))
            {
                numberOfStrongPoints = 5;
            }

            if (demographicPercentage > int.Parse(TraitDistribution.StrongPointTier2) &&
                demographicPercentage <= int.Parse(TraitDistribution.StrongPointTier3))
            {
                numberOfStrongPoints = 6;
            }
            if (demographicPercentage > int.Parse(TraitDistribution.StrongPointTier3))
            {
                numberOfStrongPoints = 7;
            }

            while (StrongPoints.Count < numberOfStrongPoints)
            {
                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);
            }
        }