Beispiel #1
0
        private bool GenerateSignificantOther(CharacterRelationshipOption relationship, int numAlready)
        {
            if (relationship.IsInPath("Spouse"))
            {
                if (!CheckForSpouse(relationship, numAlready)) return false;
            }
            else if (relationship.IsInPath("Ex-Spouse"))
            {
                if (!CheckForExSpouse(relationship, numAlready)) return false;
            }
            else if (relationship.IsInPath("Lover"))
            {
                if (!CheckForLover(relationship, numAlready)) return false;
            }
            else if (!CheckForRelationship(relationship, numAlready)) return false;

            CharacterNote newNote = new CharacterNote();
            AddChild(newNote);
            newNote.Relationship = relationship;
            
            if (!relationship.RequiresOrientationMatch || !newNote.SetSignificantOtherGender(this, relationship))
                newNote.ChooseGender();

            int? minimum, maximum;
            GetSignificantOtherAgeRange(newNote.EffectiveGender, out minimum, out maximum);
            if (!newNote.ChooseAge(false, minimum, maximum)) // False return means no valid age range exists for the relationship (min > max).
            {
                Ideas.Remove(newNote);
                return false;
            }

            newNote.SetInheritedRaces();
            newNote.AssignFamilySurname();
            newNote.AssignFamilyFirstName();

            if (RootSaveFile?.Template?.CharacterTemplate?.Traits != null)
                newNote.Traits.MergeWithOption(RootSaveFile.Template.CharacterTemplate.Traits, true);
            newNote.Traits.Choose();

            // There is a chance that a character of any orientation will be in a
            // heterosexual marriage (or ex-marriage), due to societal pressure.
            // Otherwise, the new character's orientation will be adjusted, if necessary, to
            // fit the relationship.
            if (relationship.RequiresOrientationMatch &&
                (!relationship.Path.Contains("Spouse") ||
                random.Next(101) > chanceOfForcedHeteroMarriage ||
                EffectiveGender?.Archetype != newNote.EffectiveGender?.Opposite))
                newNote.ReconcileOrientation(this, newNote.Relationship);

            return true;
        }
Beispiel #2
0
        private bool SetSignificantOtherGender(CharacterNote partner, CharacterRelationshipOption relationship)
        {
            // Ensure gender options are up to date.
            if (RootSaveFile?.Template?.CharacterTemplate?.Genders != null)
                Genders.MergeWithOption(RootSaveFile.Template.CharacterTemplate.Genders, false);

            // There is a chance that any character, regardless of actual orientation, will be in
            // a hetero marriage (or ex-marriage), due to the pressure of social conventions.
            if (relationship.Path.Contains("Spouse") && random.Next(101) <= chanceOfForcedHeteroMarriage)
            {
                CharacterGenderOption gender = Genders.FindOptionsByName(new List<NoteOption>(), partner.EffectiveGender?.Opposite).FirstOrDefault() as CharacterGenderOption;
                if (gender != null)
                {
                    gender.IsChecked = true;
                    return true;
                }
            }

            // Otherwise, select a gender that corresponds to the character's orientation.
            NoteOption orientationOption = partner.Traits.FindOption("Personality\\Orientation");
            CharacterOrientationOption partnerOrientation = orientationOption.LowestCheckedChild as CharacterOrientationOption;
            if (partnerOrientation != null)
            {
                // When selecting a lover, a character whose orientation includes multiple genders
                // has a high chance that their extra-marital relationship will be with someone of
                // a gender not represented in their marriage.
                if (relationship.IsInPath("Lover") && partnerOrientation.IncludesMultiple &&
                    random.Next(101) <= chanceOfAlternateGenderLoverForBisexual)
                {
                    IEnumerable<CharacterGenderOption> spouseGenders = partner.GetSpouses().Select(s => s.EffectiveGender);
                    List<CharacterGenderOption> candidateGenders =
                        Genders.ChildOptions.Cast<CharacterGenderOption>().Where(g => !spouseGenders.Any(s => s.Archetype == g.Archetype)).ToList();
                    if (candidateGenders.Count > 0)
                    {
                        // Use a dummy NoteOption so that the weighted choice algorithms may be leveraged.
                        NoteOption genderOptions = new NoteOption() { RootIdea = this, ChildOptions = new ObservableCollection<NoteOption>(candidateGenders), IsChoice = true };
                        genderOptions.Choose();
                        return true;
                    }
                }
                return SetOrientationMatchedGender(partner, partnerOrientation);
            }
            return false;
        }