private void BeforeSerialization() { Backgrounds = Backgrounds.GetCheckedChildrenClone(); Resolutions = Resolutions.GetCheckedChildrenClone(); Traits = Traits.GetCheckedChildrenClone(); Settings = Settings.GetCheckedChildrenClone(); Themes = Themes.GetCheckedChildrenClone(); Genres = Genres.GetCheckedChildrenClone(); }
private void GenreCheckCommand(object sender, ExecutedRoutedEventArgs e) { CheckBox checkBox = e.OriginalSource as CheckBox; NoteOption genre = e.Parameter as NoteOption; genre.InternalCheckUpdate = true; genre.IsChecked = checkBox.IsChecked ?? false; genre.InternalCheckUpdate = false; ((MainViewModel)DataContext).ApplyGenreFilter(); }
private void AddRandomCommand(object sender, ExecutedRoutedEventArgs e) { TreeView treeView = (TreeView)e.Parameter; NoteOption noteOption = (NoteOption)treeView.SelectedItem; if (noteOption != null) { noteOption.Choose(true); } }
private void comboBox_PlotSubtype_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { NoteOption newSubtype = e.AddedItems[0] as NoteOption; if (newSubtype != null) { newSubtype.IsChecked = true; } } }
public object Clone() { NoteOption clone = (NoteOption)MemberwiseClone(); clone.ChildOptions = new ObservableCollection <NoteOption>(); foreach (var child in ChildOptions) { clone.AddChild((NoteOption)child.Clone()); } return(clone); }
private void button_AddCustomBackground_Click(object sender, RoutedEventArgs e) { string response = PromptDialog.Prompt("Enter your custom value:", "Custom Value", false); if (!string.IsNullOrWhiteSpace(response)) { NoteOption custom = new NoteOption(response); ((StoryNote)DataContext).Backgrounds.AddChild(custom); custom.IsChecked = true; } }
private void CanAddRandomCommand(object sender, CanExecuteRoutedEventArgs e) { TreeView treeView = (TreeView)e.Parameter; NoteOption noteOption = (NoteOption)treeView.SelectedItem; if (noteOption == null) { e.CanExecute = false; } else { e.CanExecute = noteOption.IsMultiSelect || !noteOption.IsChoice; } }
private void CanCommandNoteOption(object sender, CanExecuteRoutedEventArgs e) { TreeView treeView = (TreeView)e.Parameter; NoteOption noteOption = (NoteOption)treeView.SelectedItem; if (noteOption == null) { e.CanExecute = false; } else { e.CanExecute = true; } }
private void AddCustomChildCommand(object sender, ExecutedRoutedEventArgs e) { TreeView treeView = (TreeView)e.Parameter; NoteOption noteOption = (NoteOption)treeView.SelectedItem; if (noteOption != null) { string response = PromptDialog.Prompt("Enter your custom value:", "Custom Value", false); if (!string.IsNullOrWhiteSpace(response)) { NoteOption custom = new NoteOption(response); noteOption.AddChild(custom); custom.IsChecked = true; } } }
private void SaveCustomToTemplateCommand(object sender, ExecutedRoutedEventArgs e) { TreeView treeView = (TreeView)e.Parameter; NoteOption noteOption = (NoteOption)treeView.SelectedItem; NoteOption templateOption = noteOption.RootIdea?.RootSaveFile?.Template?.CharacterTemplate?.Traits; if (treeView == null || noteOption == null || templateOption == null) { return; } templateOption.MergeWithOption(noteOption.RootOption, false); templateOption.DeselectAllChildren(); noteOption.RootIdea.RootSaveFile.Template.Save(); noteOption.RefreshTemplate(); }
public NoteOption GetCheckedChildrenClone() { NoteOption clone = (NoteOption)Clone(); ObservableCollection <NoteOption> newChildren = new ObservableCollection <NoteOption>(); foreach (var child in ChildOptions) { if (child.IsChecked) { newChildren.Add(child.GetCheckedChildrenClone()); } } clone.ChildOptions = newChildren; return(clone); }
private void CanSaveCustomToTemplate(object sender, CanExecuteRoutedEventArgs e) { TreeView treeView = (TreeView)e.Parameter; NoteOption noteOption = (NoteOption)treeView.SelectedItem; NoteOption templateOption = noteOption?.RootIdea?.RootSaveFile?.Template?.CharacterTemplate?.Traits; if (treeView == null || noteOption == null || templateOption == null) { e.CanExecute = false; } else if (templateOption.FindOption(noteOption.Path) == null) { e.CanExecute = true; } else { e.CanExecute = false; } }
public NoteOption FindChildOption(string path) { string firstNode = GetFirstPathNode(path); NoteOption child = ChildOptions.FirstOrDefault(c => c.Name == firstNode); if (child == null) { return(null); } else if (child.Path.EndsWith(path)) { return(child); } else { return(child.FindChildOption(GetChildPathNode(path))); } }
/// <inheritdoc/> public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values.Length < 2) { return(Brushes.LightPink); // problem } NoteOption option = values[0] as NoteOption; NoteOption templateOption = values[1] as NoteOption; if (option == null || templateOption == null) { return(Brushes.LightPink); // problem } else if (templateOption.FindOption(option.Path) == null) { return(Brushes.SteelBlue); // not in template } else { return(Brushes.Transparent); // in template } }
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; }
private void ReconcileOrientation(CharacterNote partner, CharacterRelationshipOption relationship) { NoteOption orientationOptions = Traits.FindOption("Personality\\Orientation"); if (orientationOptions == null) return; // No adjustment necessary/possible without any orientation traits. CharacterOrientationOption orientation = orientationOptions.LowestCheckedChild as CharacterOrientationOption; if (orientation == null || orientation.IncludesAny == true) return; // No adjustment necessary; any gender is accepted. CharacterGenderOption gender = EffectiveGender; CharacterGenderOption partnerGender = partner.EffectiveGender; if (gender == null || partnerGender == null) return; // No adjustment possible without gender information. List<NoteOption> candidateOrientations = new List<NoteOption>(); if (gender.Opposite == partnerGender.Archetype && !orientation.IncludesOpposite && !orientation.IncludesSimilarToOpposite) candidateOrientations.AddRange(orientationOptions.ChildOptions.Cast<CharacterOrientationOption>().Where(o => o.IncludesOpposite || o.IncludesSimilarToOpposite || o.IncludesAny)); else if (gender.Archetype == partnerGender.Archetype && !orientation.IncludesSame && !orientation.IncludesSimilar) candidateOrientations.AddRange(orientationOptions.ChildOptions.Cast<CharacterOrientationOption>().Where(o => o.IncludesSame || o.IncludesSimilar || o.IncludesAny)); else if (gender.Opposite == partnerGender.Name && !orientation.IncludesOpposite) candidateOrientations.AddRange(orientationOptions.ChildOptions.Cast<CharacterOrientationOption>().Where(o => o.IncludesOpposite || o.IncludesAny)); else if (gender.Archetype == partnerGender.Name && !orientation.IncludesSame) candidateOrientations.AddRange(orientationOptions.ChildOptions.Cast<CharacterOrientationOption>().Where(o => o.IncludesSame || o.IncludesAny)); if (candidateOrientations.Count > 0) { // Use a dummy NoteOption so that the weighted choice algorithms may be leveraged. NoteOption options = new NoteOption() { RootIdea = this, ChildOptions = new ObservableCollection<NoteOption>(candidateOrientations), IsChoice = true }; orientationOptions.DeselectAllChildren(); options.Choose(); } }
private static void AddDefaultSettings(IdeaTreeTemplate defaultTemplate) { NoteOption setting = new NoteOption("Present") { IsChoice = true, IsMultiSelect = true, Weight = 20 }; NoteOption location = new NoteOption("Home") { IsChoice = true, IsMultiSelect = true, Weight = 75 }; location.AddChild(new NoteOption("City") { Weight = 50 }); location.AddChild(new NoteOption("Remote") { Weight = 5 }); location.AddChild(new NoteOption("Rural") { Weight = 5 }); location.AddChild(new NoteOption("Suburban") { Weight = 50 }); setting.AddChild(location); location = new NoteOption("Lodging") { IsChoice = true, IsMultiSelect = true, Weight = 25 }; location.AddChild(new NoteOption("Bed and Breakfast") { Weight = 5 }); location.AddChild(new NoteOption("Cabin") { Weight = 5 }); location.AddChild(new NoteOption("Country Club") { Weight = 5 }); location.AddChild(new NoteOption("Cruise") { Weight = 5 }); location.AddChild(new NoteOption("Hotel") { Weight = 10 }); location.AddChild(new NoteOption("Houseguest") { Weight = 5 }); location.AddChild(new NoteOption("Resort") { Weight = 5 }); location.AddChild(new NoteOption("Ski Lodge") { Weight = 5 }); setting.AddChild(location); location = new NoteOption("Medical") { IsChoice = true, IsMultiSelect = true, Weight = 10 }; location.AddChild(new NoteOption("Doctor's Office") { Weight = 3 }); location.AddChild(new NoteOption("Hospital") { Weight = 3 }); location.AddChild(new NoteOption("Research Facility")); setting.AddChild(location); location = new NoteOption("Nature") { IsChoice = true, IsMultiSelect = true, Weight = 25 }; location.AddChild(new NoteOption("Beach") { Weight = 15 }); location.AddChild(new NoteOption("Forest") { Weight = 10 }); location.AddChild(new NoteOption("Desert")); location.AddChild(new NoteOption("Lake") { Weight = 10 }); location.AddChild(new NoteOption("Mountain") { Weight = 10 }); location.AddChild(new NoteOption("Park") { Weight = 15 }); location.AddChild(new NoteOption("River") { Weight = 10 }); location.AddChild(new NoteOption("Sea") { Weight = 10 }); setting.AddChild(location); location = new NoteOption("Recreational") { IsChoice = true, IsMultiSelect = true, Weight = 25 }; location.AddChild(new NoteOption("Bar") { Weight = 18 }); location.AddChild(new NoteOption("Movie Theater") { Weight = 18 }); location.AddChild(new NoteOption("Nightclub") { Weight = 18 }); location.AddChild(new NoteOption("Opera") { Weight = 4 }); location.AddChild(new NoteOption("Restaurant") { Weight = 18 }); location.AddChild(new NoteOption("Spa") { Weight = 6 }); location.AddChild(new NoteOption("Symphony") { Weight = 4 }); location.AddChild(new NoteOption("Theater") { Weight = 4 }); setting.AddChild(location); location = new NoteOption("School") { IsChoice = true, IsMultiSelect = true, Weight = 25 }; location.AddChild(new NoteOption("College") { Weight = 3 }); location.AddChild(new NoteOption("High School") { Weight = 3 }); location.AddChild(new NoteOption("Technical/Specialized School")); setting.AddChild(location); setting.AddChild(new NoteOption("Work") { Weight = 50 }); // Only major countries (with >5 million citizens) are included in the default template, // for simplicity's sake. location = new NoteOption("Abroad") { IsChoice = true, IsManualMultiSelect = true, Weight = 5 }; NoteOption subLocation = new NoteOption("Africa") { IsChoice = true, IsManualMultiSelect = true }; NoteOption subSubLocation = new NoteOption("Central Africa") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Angola")); subSubLocation.AddChild(new NoteOption("Cameroon")); subSubLocation.AddChild(new NoteOption("Chad")); subSubLocation.AddChild(new NoteOption("Democratic Republic of the Congo")); subLocation.AddChild(subSubLocation); subSubLocation = new NoteOption("East Africa") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Burundi")); subSubLocation.AddChild(new NoteOption("Eritrea")); subSubLocation.AddChild(new NoteOption("Ethiopia")); subSubLocation.AddChild(new NoteOption("Kenya")); subSubLocation.AddChild(new NoteOption("Madagascar")); subSubLocation.AddChild(new NoteOption("Malawi")); subSubLocation.AddChild(new NoteOption("Mozambique")); subSubLocation.AddChild(new NoteOption("Rwanda")); subSubLocation.AddChild(new NoteOption("Somalia")); subSubLocation.AddChild(new NoteOption("South Sudan")); subSubLocation.AddChild(new NoteOption("Uganda")); subSubLocation.AddChild(new NoteOption("Tanzania")); subSubLocation.AddChild(new NoteOption("Zambia")); subSubLocation.AddChild(new NoteOption("Zimbabwe")); subLocation.AddChild(subSubLocation); subSubLocation = new NoteOption("North Africa") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Algeria")); subSubLocation.AddChild(new NoteOption("Egypt")); subSubLocation.AddChild(new NoteOption("Libya")); subSubLocation.AddChild(new NoteOption("Morocco")); subSubLocation.AddChild(new NoteOption("Sudan")); subSubLocation.AddChild(new NoteOption("Tunisia")); subLocation.AddChild(subSubLocation); subLocation.AddChild(new NoteOption("South Africa")); subSubLocation = new NoteOption("West Africa") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Benin")); subSubLocation.AddChild(new NoteOption("Burkina Faso")); subSubLocation.AddChild(new NoteOption("Côte d'Ivoire")); subSubLocation.AddChild(new NoteOption("Ghana")); subSubLocation.AddChild(new NoteOption("Guinea")); subSubLocation.AddChild(new NoteOption("Mali")); subSubLocation.AddChild(new NoteOption("Niger")); subSubLocation.AddChild(new NoteOption("Nigeria")); subSubLocation.AddChild(new NoteOption("Senegal")); subSubLocation.AddChild(new NoteOption("Sierra Leone")); subSubLocation.AddChild(new NoteOption("Togo")); subLocation.AddChild(subSubLocation); location.AddChild(subLocation); subLocation = new NoteOption("America") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation = new NoteOption("Caribbean") { IsChoice = true, IsManualMultiSelect = true, AllowsNone = true }; subSubLocation.AddChild(new NoteOption("Cuba")); subSubLocation.AddChild(new NoteOption("Dominican Republic")); subSubLocation.AddChild(new NoteOption("Haiti")); subLocation.AddChild(subSubLocation); subSubLocation = new NoteOption("Central America") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("El Salvador")); subSubLocation.AddChild(new NoteOption("Guatemala")); subSubLocation.AddChild(new NoteOption("Honduras")); subSubLocation.AddChild(new NoteOption("Nicaragua")); subLocation.AddChild(subSubLocation); subSubLocation = new NoteOption("North America") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Canada")); subSubLocation.AddChild(new NoteOption("Mexico")); // The default template assumes a "home" location in the U.S., and therefore does not consider it "abroad." // When localizing the template for other locations, this weight should be re-set to 1, and the weight of // the local "home" region set to 0 instead. subSubLocation.AddChild(new NoteOption("United States") { Weight = 0 }); subLocation.AddChild(subSubLocation); subSubLocation = new NoteOption("South America") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Argentina")); subSubLocation.AddChild(new NoteOption("Bolivia")); subSubLocation.AddChild(new NoteOption("Brazil")); subSubLocation.AddChild(new NoteOption("Chile")); subSubLocation.AddChild(new NoteOption("Colombia")); subSubLocation.AddChild(new NoteOption("Ecuador")); subSubLocation.AddChild(new NoteOption("Paraguay")); subSubLocation.AddChild(new NoteOption("Peru")); subSubLocation.AddChild(new NoteOption("Venezuela")); subLocation.AddChild(subSubLocation); location.AddChild(subLocation); subLocation = new NoteOption("Asia") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation = new NoteOption("Central Asia") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Afghanistan")); subSubLocation.AddChild(new NoteOption("Kazakhstan")); subSubLocation.AddChild(new NoteOption("Kyrgyzstan")); subSubLocation.AddChild(new NoteOption("Tajikistan")); subSubLocation.AddChild(new NoteOption("Turkmenistan")); subSubLocation.AddChild(new NoteOption("Uzbekistan")); subLocation.AddChild(subSubLocation); subSubLocation = new NoteOption("East Asia") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("China")); subSubLocation.AddChild(new NoteOption("Japan")); subSubLocation.AddChild(new NoteOption("Korea")); subLocation.AddChild(subSubLocation); subSubLocation = new NoteOption("Southeast Asia") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Cambodia")); subSubLocation.AddChild(new NoteOption("Indonesia")); subSubLocation.AddChild(new NoteOption("Malaysia")); subSubLocation.AddChild(new NoteOption("The Philipines")); subSubLocation.AddChild(new NoteOption("Thailand")); subSubLocation.AddChild(new NoteOption("Vietnam")); subLocation.AddChild(subSubLocation); subSubLocation = new NoteOption("South Asia") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Bangladesh")); subSubLocation.AddChild(new NoteOption("India")); subSubLocation.AddChild(new NoteOption("Nepal")); subSubLocation.AddChild(new NoteOption("Pakistan")); subLocation.AddChild(subSubLocation); location.AddChild(subLocation); subLocation = new NoteOption("Europe") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation = new NoteOption("Eastern Europe") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Belarus")); subSubLocation.AddChild(new NoteOption("Bulgaria")); subSubLocation.AddChild(new NoteOption("Czech Republic")); subSubLocation.AddChild(new NoteOption("Hungary")); subSubLocation.AddChild(new NoteOption("Poland")); subSubLocation.AddChild(new NoteOption("Romania")); subSubLocation.AddChild(new NoteOption("Russia")); subSubLocation.AddChild(new NoteOption("Slovakia")); subSubLocation.AddChild(new NoteOption("Ukraine")); subLocation.AddChild(subSubLocation); subSubLocation = new NoteOption("Northern Europe") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Denmark")); subSubLocation.AddChild(new NoteOption("England")); subSubLocation.AddChild(new NoteOption("Finland")); subSubLocation.AddChild(new NoteOption("Ireland")); subSubLocation.AddChild(new NoteOption("Norway")); subSubLocation.AddChild(new NoteOption("Scotland")); subSubLocation.AddChild(new NoteOption("Sweden")); subLocation.AddChild(subSubLocation); subSubLocation = new NoteOption("Southern Europe") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Greece")); subSubLocation.AddChild(new NoteOption("Italy")); subSubLocation.AddChild(new NoteOption("Portugal")); subSubLocation.AddChild(new NoteOption("Serbia")); subSubLocation.AddChild(new NoteOption("Spain")); subLocation.AddChild(subSubLocation); subSubLocation = new NoteOption("Western Europe") { IsChoice = true, IsManualMultiSelect = true }; subSubLocation.AddChild(new NoteOption("Austria")); subSubLocation.AddChild(new NoteOption("Belgium")); subSubLocation.AddChild(new NoteOption("France")); subSubLocation.AddChild(new NoteOption("Germany")); subSubLocation.AddChild(new NoteOption("Netherlands")); subSubLocation.AddChild(new NoteOption("Switzerland")); subLocation.AddChild(subSubLocation); location.AddChild(subLocation); subLocation = new NoteOption("Middle East") { IsChoice = true, IsManualMultiSelect = true }; subLocation.AddChild(new NoteOption("Azerbaijan")); subLocation.AddChild(new NoteOption("Iran")); subLocation.AddChild(new NoteOption("Iraq")); subLocation.AddChild(new NoteOption("Israel")); subLocation.AddChild(new NoteOption("Jordan")); subLocation.AddChild(new NoteOption("Lebanon")); subLocation.AddChild(new NoteOption("Palestine")); subLocation.AddChild(new NoteOption("Saudi Arabia")); subLocation.AddChild(new NoteOption("Syria")); subLocation.AddChild(new NoteOption("Turkey")); subLocation.AddChild(new NoteOption("United Arab Emirates")); subLocation.AddChild(new NoteOption("Yemen")); location.AddChild(subLocation); subLocation = new NoteOption("Oceania") { IsChoice = true, IsManualMultiSelect = true }; subLocation.AddChild(new NoteOption("Australia")); subSubLocation = new NoteOption("Melanesia") { IsChoice = true, IsManualMultiSelect = true, AllowsNone = true }; subSubLocation.AddChild(new NoteOption("Papua New Guinea")); subLocation.AddChild(subSubLocation); subLocation.AddChild(new NoteOption("Micronesia")); subLocation.AddChild(new NoteOption("New Zealand")); location.AddChild(subLocation); setting.AddChild(location); defaultTemplate.StoryTemplate.Settings.AddChild(setting); setting = new NoteOption("Ancient") { IsChoice = true, IsMultiSelect = true }; setting.AddChild(new NoteOption("Hyborian")); setting.AddChild(new NoteOption("Celtic")); setting.AddChild(new NoteOption("Egyptian")); setting.AddChild(new NoteOption("Greco-Roman")); setting.AddChild(new NoteOption("Scandinavian")); setting.AddChild(new NoteOption("Stone Age")); defaultTemplate.StoryTemplate.Settings.AddChild(setting); setting = new NoteOption("Medieval") { IsChoice = true, IsMultiSelect = true }; setting.AddChild(new NoteOption("Arabia")); setting.AddChild(new NoteOption("Asia")); setting.AddChild(new NoteOption("Europe")); defaultTemplate.StoryTemplate.Settings.AddChild(setting); setting = new NoteOption("Renaissance") { IsChoice = true, IsMultiSelect = true }; setting.AddChild(new NoteOption("High Seas")); setting.AddChild(new NoteOption("New World")); setting.AddChild(new NoteOption("Noble Court")); defaultTemplate.StoryTemplate.Settings.AddChild(setting); setting = new NoteOption("Victorian") { IsChoice = true, IsMultiSelect = true }; setting.AddChild(new NoteOption("City")); setting.AddChild(new NoteOption("Colony")); setting.AddChild(new NoteOption("Country Manor")); setting.AddChild(new NoteOption("Courtly Society")); setting.AddChild(new NoteOption("Wild West")); defaultTemplate.StoryTemplate.Settings.AddChild(setting); setting = new NoteOption("Future") { IsChoice = true, IsMultiSelect = true }; setting.AddChild(new NoteOption("Alien Planet")); setting.AddChild(new NoteOption("Dystopian Society")); setting.AddChild(new NoteOption("Spaceship")); setting.AddChild(new NoteOption("Space Station")); setting.AddChild(new NoteOption("Utopian Society")); defaultTemplate.StoryTemplate.Settings.AddChild(setting); }
public void AddChild(NoteOption child) { if (child == this) throw new Exception("Cannot add a NoteOption as its own child."); child.Parent = this; ChildOptions.Add(child); }
private bool ChooseAge(NoteOption ageOptions, bool manual = false, int? minimum = 0, int? maximum = null) { ageOptions.Choose(); CharacterAgeOption age = (CharacterAgeOption)ageOptions.ChildOptions.FirstOrDefault(a => a.IsChecked); if (age == null) return false; if (!manual && age.OmitFromFamilyTree) return false; int min = minimum ?? int.MinValue; int max = maximum ?? int.MaxValue; min = Math.Max(min, age.MinAge ?? min); max = Math.Min(max, age.MaxAge ?? max); if (min > max) return false; int years = random.Next(min, max + 1); if (years < 0 || years > maxAge) return false; AgeYears = years; if (AgeYears == 0) AgeMonths = (byte)random.Next(1, 12); else AgeMonths = 0; return true; }
public void AddElement(NoteOption child) { child.Parent = this; ElementOptions.Add(child); }
private void button_AddCustomTheme_Click(object sender, RoutedEventArgs e) { string response = PromptDialog.Prompt("Enter your custom value:", "Custom Value", false); if (!string.IsNullOrWhiteSpace(response)) { NoteOption custom = new NoteOption(response) { IsChecked = true }; ((StoryNote)DataContext).Themes.AddChild(custom); } }
public bool ChooseAge(bool manual = false, int? secondaryMin = null, int? secondaryMax = null, bool relationshipRestrictions = false) { if (RootSaveFile?.Template?.CharacterTemplate?.Ages == null) return false; int min = int.MinValue; int max = int.MaxValue; if (relationshipRestrictions) { if (Relationship?.MinAge.HasValue == true) min = Relationship.MinAge.Value; if (Relationship?.MinAgeOffset.HasValue == true) min = Math.Max(min, ((CharacterNote)Parent).AgeYears + Relationship.MinAgeOffset.Value); if (Relationship?.MaxAge.HasValue == true) max = Relationship.MaxAge.Value; if (Relationship?.MaxAgeOffset.HasValue == true) max = Math.Min(max, ((CharacterNote)Parent).AgeYears + Relationship.MaxAgeOffset.Value); if (Relationship?.IsInPath("Child") == true) { CharacterRelationshipOption childRelationship = RootSaveFile.Template.CharacterTemplate.Relationships.FindOption("Child") as CharacterRelationshipOption; ((CharacterNote)Parent).CalculateChildAgeRange(childRelationship, out min, out max); } else if (Relationship?.IsInPath("Sibling") == true) CalculateSiblingAgeRange(out min, out max); else if (Relationship?.IsInPath("Significant Other") == true) { int? minimum, maximum; ((CharacterNote)Parent).GetSignificantOtherAgeRange(EffectiveGender, out minimum, out maximum); if (minimum.HasValue) min = minimum.Value; if (maximum.HasValue) max = maximum.Value; } } if (secondaryMin.HasValue) min = Math.Max(min, secondaryMin.Value); if (secondaryMax.HasValue) max = Math.Min(max, secondaryMax.Value); List<CharacterAgeOption> ages = RootSaveFile.Template.CharacterTemplate.Ages.ChildOptions.Cast<CharacterAgeOption>().Where(a => a.MinAge <= max && a.MaxAge >= min).ToList(); if (ages.Count == 0) return false; // Use a dummy NoteOption so that the weighted choice algorithms may be leveraged. NoteOption ageOptions = new NoteOption() { RootIdea = this, ChildOptions = new ObservableCollection<NoteOption>(ages), IsChoice = true }; return ChooseAge(ageOptions, manual, min, max); }
public void ChooseGender() { // Ensure gender options are up to date. if (RootSaveFile?.Template?.CharacterTemplate?.Genders != null) Genders.MergeWithOption(RootSaveFile.Template.CharacterTemplate.Genders, false); if (Relationship == null) { Genders.Choose(); return; } List<CharacterGenderOption> genders = new List<CharacterGenderOption>(); foreach (var gender in Relationship.Genders) { List<CharacterGenderOption> matches = Genders.GetArchetypeClone(gender).ChildOptions.Cast<CharacterGenderOption>().ToList(); if (matches.Count > 0) genders = genders.Concat(matches).ToList(); } // If the relationship doesn't specify gender, select from among all of them. if (genders.Count == 0) genders = new List<CharacterGenderOption>(Genders.ChildOptions.Where(c => c is CharacterGenderOption).Cast<CharacterGenderOption>()); // Use a dummy NoteOption so that the weighted choice algorithms may be leveraged. NoteOption genderOptions = new NoteOption() { RootIdea = this, ChildOptions = new ObservableCollection<NoteOption>(genders), IsChoice = true }; genderOptions.Choose(); Genders.FindOption(genderOptions.LowestCheckedChild.Path).IsChecked = true; }
private bool SetOrientationMatchedGender(CharacterNote partner, CharacterOrientationOption partnerOrientation) { CharacterGenderOption partnerGender = partner.EffectiveGender; if (partnerGender == null) return false; List<CharacterGenderOption> candidateGenders = new List<CharacterGenderOption>(); if (partnerOrientation.IncludesSame) candidateGenders.AddRange(Genders.FindOptionsByName(new List<NoteOption>(), partnerGender.Archetype).Cast<CharacterGenderOption>()); if (partnerOrientation.IncludesSimilar) candidateGenders.AddRange(Genders.ChildOptions.Cast<CharacterGenderOption>().Where(g => g.Archetype == partnerGender.Archetype)); if (partnerOrientation.IncludesOpposite && partnerGender.Opposite != null) candidateGenders.AddRange(Genders.FindOptionsByName(new List<NoteOption>(), partnerGender.Opposite).Cast<CharacterGenderOption>()); if (partnerOrientation.IncludesSimilarToOpposite && partnerGender.Opposite != null) candidateGenders.AddRange(Genders.ChildOptions.Cast<CharacterGenderOption>().Where(g => g.Archetype == partnerGender.Opposite)); if (candidateGenders.Count == 0) return false; // 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; }
private void SetRelationshipMatchingGender(CharacterNote partner, CharacterRelationshipOption relationship) { // If the relationship is orientation-specific, pick an appropriate gender. bool choseGender = false; if (relationship.RequiresOrientationMatch) { NoteOption orientationOptions = partner.Traits.FindOption("Personality\\Orientation"); CharacterOrientationOption partnerOrientation = orientationOptions.LowestCheckedChild as CharacterOrientationOption; choseGender = SetOrientationMatchedGender(partner, partnerOrientation); // A choice must only be forced if the partner has an orientation, and it is gender-specific. if (partnerOrientation != null && !partnerOrientation.IncludesAny) { // Ensure gender options are up to date. if (RootSaveFile?.Template?.CharacterTemplate?.Genders != null) Genders.MergeWithOption(RootSaveFile.Template.CharacterTemplate.Genders, false); List<CharacterGenderOption> genders = new List<CharacterGenderOption>(); if (partnerOrientation.IncludesSimilarToOpposite) genders.AddRange(Genders.GetArchetypeClone(partner.EffectiveGender.Opposite).ChildOptions.Cast<CharacterGenderOption>()); else if (partnerOrientation.IncludesOpposite) genders.AddRange(Genders.FindOptionsByName(new List<NoteOption>(), partner.EffectiveGender.Opposite).Cast<CharacterGenderOption>()); if (partnerOrientation.IncludesSimilar) genders.AddRange(Genders.GetArchetypeClone(partner.EffectiveGender.Archetype).ChildOptions.Cast<CharacterGenderOption>()); else if (partnerOrientation.IncludesSame) genders.AddRange(Genders.FindOptionsByName(new List<NoteOption>(), partner.EffectiveGender.Archetype).Cast<CharacterGenderOption>()); if (genders.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>(genders), IsChoice = true }; genderOptions.Choose(); Genders.FindOption(genderOptions.LowestCheckedChild.Path).IsChecked = true; choseGender = true; } } } // Otherwise, choose one at random. if (!choseGender) ChooseGender(); foreach (CharacterRelationshipOption childRelationship in relationship.ChildOptions) { if (childRelationship.Genders.Any(g => g == EffectiveGender.Archetype)) { Relationship = childRelationship; return; } } return; }
private static void AddDefaultStoryTraits(IdeaTreeTemplate defaultTemplate) { NoteOption trait = new NoteOption("Tone") { IsChoice = true }; trait.AddChild(new NoteOption("Comedic")); trait.AddChild(new NoteOption("Light-hearted")); trait.AddChild(new NoteOption("Dramatic")); trait.AddChild(new NoteOption("Dark")); defaultTemplate.StoryTemplate.Traits.AddChild(trait); trait = new NoteOption("Cast Size") { IsChoice = true }; trait.AddChild(new NoteOption("Solitary Protagonist")); NoteOption subTrait = new NoteOption("Duo") { IsChoice = true }; subTrait.AddChild(new NoteOption("Partners")); subTrait.AddChild(new NoteOption("Rivals")); trait.AddChild(subTrait); trait.AddChild(new NoteOption("Small Cast")); trait.AddChild(new NoteOption("Medium Cast")); subTrait = new NoteOption("Large Cast") { IsChoice = true }; subTrait.AddChild(new NoteOption("Protagonist with supporting cast")); subTrait.AddChild(new NoteOption("Ensemble")); trait.AddChild(subTrait); defaultTemplate.StoryTemplate.Traits.AddChild(trait); }
protected virtual bool DoesModifierApply(NoteOptionModifier modifier) { NoteOption option = FindOption(modifier.TargetPath); return(option?.IsChecked == true); }
private static void AddDefaultGenres(IdeaTreeTemplate defaultTemplate) { NoteOption genre = new NoteOption("Adventure") { Weight = 20, IsChoice = true, IsManualMultiSelect = true }; genre.AddChild(new NoteOption("Epic")); genre.AddChild(new NoteOption("Lost World")); genre.AddChild(new NoteOption("Nautical")); genre.AddChild(new NoteOption("Picaresque")); genre.AddChild(new NoteOption("Robinsonade")); genre.AddChild(new NoteOption("Western")); defaultTemplate.StoryTemplate.Genres.AddChild(genre); genre = new NoteOption("Crime") { Weight = 20, IsChoice = true, IsManualMultiSelect = true }; genre.AddChild(new NoteOption("Caper")); genre.AddChild(new NoteOption("Detective Story")); genre.AddChild(new NoteOption("Espionage Thriller")); genre.AddChild(new NoteOption("Legal Thriller")); genre.AddChild(new NoteOption("Murder Mystery")); defaultTemplate.StoryTemplate.Genres.AddChild(genre); genre = new NoteOption("Fantasy") { Weight = 20, IsChoice = true, IsManualMultiSelect = true }; genre.AddChild(new NoteOption("Alternate Reality")); genre.AddChild(new NoteOption("Contemporary Fantasy")); genre.AddChild(new NoteOption("Dark Fantasy")); genre.AddChild(new NoteOption("Dying Earth")); genre.AddChild(new NoteOption("Epic / High Fantasy")); genre.AddChild(new NoteOption("Fairy Tale")); genre.AddChild(new NoteOption("Fantasy Romance")); genre.AddChild(new NoteOption("Historical Fantasy")); genre.AddChild(new NoteOption("Low Fantasy")); genre.AddChild(new NoteOption("Mythic")); NoteOption subGenre = new NoteOption("Science Fantasy") { IsChoice = true, IsManualMultiSelect = true, AllowsNone = true }; NoteOption subSubGenre = new NoteOption("Planetary Romance") { IsChoice = true, IsManualMultiSelect = true, AllowsNone = true }; subSubGenre.AddChild(new NoteOption("Sword and Planet")); subGenre.AddChild(subSubGenre); genre.AddChild(subGenre); genre.AddChild(new NoteOption("Superhero")); genre.AddChild(new NoteOption("Sword and Sorcery")); genre.AddChild(new NoteOption("Urban Fantasy")); defaultTemplate.StoryTemplate.Genres.AddChild(genre); genre = new NoteOption("Horror") { Weight = 20, IsChoice = true, IsManualMultiSelect = true }; genre.AddChild(new NoteOption("Body Horror")); genre.AddChild(new NoteOption("Gothic")); genre.AddChild(new NoteOption("Occult Detective")); genre.AddChild(new NoteOption("Psychological Thriller")); subGenre = new NoteOption("Supernatural / Paranormal") { IsChoice = true, IsManualMultiSelect = true }; subGenre.AddChild(new NoteOption("Ghost Story")); subGenre.AddChild(new NoteOption("Lovecraftian")); subGenre.AddChild(new NoteOption("Paranormal Romance")); subSubGenre = new NoteOption("Monster Story") { IsChoice = true, IsManualMultiSelect = true, AllowsNone = true }; subSubGenre.AddChild(new NoteOption("Mummy Story")); subSubGenre.AddChild(new NoteOption("Vampire Story")); subSubGenre.AddChild(new NoteOption("Werewolf Story")); subGenre.AddChild(subSubGenre); genre.AddChild(subGenre); defaultTemplate.StoryTemplate.Genres.AddChild(genre); genre = new NoteOption("Realistic") { Weight = 20, IsChoice = true, IsManualMultiSelect = true }; genre.AddChild(new NoteOption("Bildungsroman")); genre.AddChild(new NoteOption("Biography")); genre.AddChild(new NoteOption("Contemporary Romance")); subGenre = new NoteOption("Historical Fiction") { IsChoice = true, IsManualMultiSelect = true, AllowsNone = true }; subGenre.AddChild(new NoteOption("Alternative History")); subGenre.AddChild(new NoteOption("Historical Romance")); subGenre = new NoteOption("Political Fiction") { IsChoice = true, IsManualMultiSelect = true }; subGenre.AddChild(new NoteOption("Political Thriller")); subGenre.AddChild(new NoteOption("Political Satire")); genre.AddChild(subGenre); genre.AddChild(new NoteOption("Urban Fiction")); defaultTemplate.StoryTemplate.Genres.AddChild(genre); genre = new NoteOption("Science Fiction") { Weight = 20, IsChoice = true, IsManualMultiSelect = true }; genre.AddChild(new NoteOption("Alien Invasion")); genre.AddChild(new NoteOption("Post-Apocalyptic")); genre.AddChild(new NoteOption("Cyberpunk")); genre.AddChild(new NoteOption("Dystopian")); genre.AddChild(new NoteOption("Space Opera")); genre.AddChild(new NoteOption("Steampunk")); defaultTemplate.StoryTemplate.Genres.AddChild(genre); }
public void MergeWithOption(NoteOption other, bool overwrite, bool mergeChecked = false) { if (overwrite) { // Merge properties. Weight = other.Weight; IsChoice = other.IsChoice; IsMultiSelect = other.IsMultiSelect; IsManualMultiSelect = other.IsManualMultiSelect; AllowsNone = other.AllowsNone; NoneWeight = other.NoneWeight; } // Do not un-check, only check to match. if (mergeChecked && other.IsChecked) IsChecked = true; // Combine matching children. foreach (var matchingChild in ChildOptions.Where(c => other.ChildOptions.Any(o => c.Name == o.Name))) { matchingChild.MergeWithOption(other.ChildOptions.First(o => o.Name == matchingChild.Name), overwrite, mergeChecked); } foreach (var newChild in other.ChildOptions.Where(o => !ChildOptions.Any(c => c.Name == o.Name))) AddChild((NoteOption)newChild.Clone()); }