Beispiel #1
0
        private bool CheckForRelationship(CharacterRelationshipOption relationship, int numAlready)
        {
            if (numAlready >= relationship.Max) return false;

            if (AgeYears < relationship?.MinAge) return false;
            if (AgeYears > relationship?.MaxAge) return false;

            if (HasAnyRelationships(relationship.IncompatibleRelationships) ||
                !HasAllRelationships(relationship.RequiredRelationships))
                return false;

            bool force = false;
            int weight;
            if (numAlready > 1 && relationship.SecondWeight.HasValue)
                weight = relationship.SecondWeight.Value;
            else if (numAlready > 2 && relationship.ThirdWeight.HasValue)
                weight = relationship.ThirdWeight.Value;
            else weight = relationship.GetEffectiveWeight(out force);
            bool chosen = random.Next(1, 101) <= (weight * Math.Pow(multipleRelationshipMultiplier, numAlready));
            return force || chosen;
        }
Beispiel #2
0
        private bool CheckForLover(CharacterRelationshipOption relationship, int numAlready)
        {
            if (numAlready >= relationship.Max) return false;
            
            if (AgeYears < relationship?.MinAge) return false;
            if (AgeYears > relationship?.MaxAge) return false;

            if (HasAnyRelationships(relationship.IncompatibleRelationships) ||
                !HasAllRelationships(relationship.RequiredRelationships))
                return false;
            
            bool force = false;
            int weight;
            if (numAlready > 1 && relationship.SecondWeight.HasValue)
                weight = relationship.SecondWeight.Value;
            else if (numAlready > 2 && relationship.ThirdWeight.HasValue)
                weight = relationship.ThirdWeight.Value;
            else weight = relationship.GetEffectiveWeight(out force);

            NoteOption orientationOption = Traits.FindOption("Personality\\Orientation");
            CharacterOrientationOption orientation = orientationOption.LowestCheckedChild as CharacterOrientationOption;
            if (orientation != null)
            {
                // An orientation which includes any gender is somewhat more likely than usual to have a lover
                // (of a different gender than their spouse).
                if (orientation?.IncludesAny == true) weight = (int)Math.Round(weight * bisexualLoverChanceMultiplier);
                else
                {
                    List<CharacterNote> spouses = GetSpouses();
                    bool orientationSatisfied = false;
                    CharacterGenderOption gender = EffectiveGender;
                    foreach (CharacterNote spouse in spouses)
                    {
                        CharacterGenderOption partnerGender = spouse.EffectiveGender;
                        if (gender == null || partnerGender == null) continue;
                        
                        if (orientation.IncludesSame && gender.Archetype == partnerGender.Name)
                        {
                            orientationSatisfied = true;
                            break;
                        }
                        if (orientation.IncludesSimilar && gender.Archetype == partnerGender.Archetype)
                        {
                            orientationSatisfied = true;
                            break;
                        }
                        if (orientation.IncludesOpposite && gender.Opposite != null && gender.Opposite == partnerGender.Name)
                        {
                            orientationSatisfied = true;
                            break;
                        }
                        if (orientation.IncludesSimilarToOpposite && gender.Opposite != null && gender.Opposite == partnerGender.Archetype)
                        {
                            orientationSatisfied = true;
                            break;
                        }
                    }
                    // There is an even higher chance that a character who is married to someone
                    // of a gender that does not match their preference will take a lover (of a preferred gender).
                    if (!orientationSatisfied) weight = (int)Math.Round(weight * homosexualLoverChanceMultiplier);
                }
            }

            bool chosen = random.Next(1, 101) <= weight * Math.Pow(multipleRelationshipMultiplier, numAlready);
            return force || chosen;
        }
Beispiel #3
0
        private bool ShouldHaveChildren(CharacterRelationshipOption relationship, bool woman, bool married, bool divorced)
        {
            bool force;
            int weight = relationship.GetEffectiveWeight(out force);
            if (force) return true;

            // Certain situations will override the usual weight.
            if (married)
            {
                if (random.Next(1, 101) > chanceToHaveKidsWhenMarried) return false;
            }

            else if (divorced && woman) // 50% chance of being a single divorced mom.
            {
                if (random.Next(1, 101) > chanceToHaveKids_SingleDivorcedMom) return false;
            }

            else if (AgeYears >= 30 && AgeYears <= 60)
            {
                if (woman) // 10% chance of being a single mom (not divorced) between ages 30 and 60.
                {
                    if (random.Next(1, 101) > chanceToHaveKids_SingleUndivorcedMom_30to60)
                        return false;
                }
                else if (divorced) // 10% chance of being a single divorced dad between ages 30 and 60.
                {
                    if (random.Next(1, 101) > chanceToHaveKids_SingleDivorcedDad_30to60)
                        return false;
                }
            }

            // In other situations, the usual weight is used.
            else if (random.Next(101) > weight) return false;

            return true;
        }