public Story PrintFormattedStory(StoryProgressionObject manager, string localizedStory, string summaryKey, object[] parameters, string[] extended, StoryLogging logging) { return(PrintInternalStory(manager, localizedStory, summaryKey, parameters, extended, PerformFormat.No, false, SummaryPerSim.Yes, logging)); }
protected Story PrintInternalStory(StoryProgressionObject manager, string storyKey, string summaryKey, object[] oldParameters, string[] extended, PerformFormat format, bool notify, SummaryPerSim summaryPerSim, StoryLogging logging) { bool matchesAlert = notify, foundSim = false, foundLot = false; Story.Element element1 = null; Story.Element element2 = null; CASAgeGenderFlags firstGender = CASAgeGenderFlags.None; CASAgeGenderFlags secondGender = CASAgeGenderFlags.None; List <object> newParameters = new List <object>(); if (!matchesAlert) { if (oldParameters.Length == 0) { matchesAlert = true; } else if (manager != null) { foreach (object obj in oldParameters) { SimDescription sim = null; if (obj is Sim) { sim = (obj as Sim).SimDescription; } else { sim = obj as SimDescription; } if (sim != null) { if (manager.MatchesAlertLevel(sim)) { matchesAlert = true; break; } } else { Lot lot = obj as Lot; if ((lot != null) && (lot.Household != null)) { if (manager.MatchesAlertLevel(lot.Household.AllSimDescriptions)) { matchesAlert = true; break; } } } } } } foreach (object obj in oldParameters) { SimDescription sim = null; if (obj is Sim) { sim = (obj as Sim).SimDescription; } else { sim = obj as SimDescription; } if (sim != null) { newParameters.Add(obj); if ((summaryPerSim == SummaryPerSim.Yes) || (!foundSim)) { AddSummary(manager, sim, summaryKey, extended, logging); } AddGenderNouns(sim, newParameters); foundSim = true; if (element1 == null) { firstGender = sim.Gender; element1 = new Story.Element(sim); } else if (element2 == null) { secondGender = sim.Gender; element2 = new Story.Element(sim); } } else { Lot lot = obj as Lot; if (lot != null) { string name = lot.Name.Trim(); if (string.IsNullOrEmpty(name)) { name = Localize("SomeHome"); } newParameters.Add(name); name = lot.Address.Trim(); if (string.IsNullOrEmpty(name)) { name = Localize("SomeAddress"); } newParameters.Add(name); foundLot = true; if (!string.IsNullOrEmpty(lot.Name)) { AddSummary(manager, lot.Name, summaryKey, null, matchesAlert, logging); } AddSummary(manager, lot.Address, summaryKey, extended, matchesAlert, logging); if (element1 == null) { element1 = new Story.Element(lot.ObjectId); } else if (element2 == null) { element2 = new Story.Element(lot.ObjectId); } } else { newParameters.Add(obj); string str = obj as string; if (str != null) { if ((!foundSim) && (foundLot)) { AddSummary(manager, str, summaryKey, extended, matchesAlert, logging); } } } } } if (((logging & StoryLogging.Notice) == StoryLogging.Notice) && ((!foundSim) || (matchesAlert))) { string text = storyKey; if (format == PerformFormat.Yes) { object[] parameters = newParameters.ToArray(); string uniqueKey = manager.UnlocalizedName + storyKey; List <AvailableStory> stories; if (!mValidStories.TryGetValue(uniqueKey, out stories)) { stories = new List <AvailableStory>(); mValidStories.Add(uniqueKey, stories); for (int i = 0; i <= 9; i++) { AvailableStory story = new AvailableStory(manager, storyKey + i.ToString(), parameters); if (!story.IsValid) { continue; } stories.Add(story); } } if (stories.Count > 0) { AvailableStory set = RandomUtil.GetRandomObjectFromList(stories); text = set.Localize(manager, firstGender, secondGender, parameters); IncStat("Story: " + uniqueKey); } else { text = manager.Localize(storyKey + "0", false, parameters); IncStat("Missing: " + text, Common.DebugLevel.High); } } if (!string.IsNullOrEmpty(text)) { return(NewStory(new Story(manager, text, element1, element2))); } } return(new Story(manager, null, null)); }
public Story PrintStory(StoryProgressionObject manager, string key, object[] parameters, string[] extended, bool forceNotify, StoryLogging logging) { return(PrintInternalStory(manager, key, key, parameters, extended, PerformFormat.Yes, forceNotify, SummaryPerSim.Yes, logging)); }
public Story PrintStory(StoryProgressionObject manager, string key, Household house, string[] extended, StoryLogging logging) { List <object> parameters = new List <object>(); SimDescription head = SimTypes.HeadOfFamily(house, false); if (head != null) { parameters.Add(head); if (house.LotHome != null) { string name = house.LotHome.Name.Trim(); if (string.IsNullOrEmpty(name)) { name = Localize("SomeHome"); } parameters.Add(name); name = house.LotHome.Address.Trim(); if (string.IsNullOrEmpty(name)) { name = Localize("SomeAddress"); } parameters.Add(name); } else { parameters.Add(null); parameters.Add(null); } foreach (SimDescription sim in house.AllSimDescriptions) { if (sim == head) { continue; } parameters.Add(sim); } } return(PrintInternalStory(manager, key, key, parameters.ToArray(), extended, PerformFormat.Yes, false, SummaryPerSim.No, logging)); }
protected void AddSummary(StoryProgressionObject spObject, string name, string msg, string[] extended, bool notify, StoryLogging logging) { if (string.IsNullOrEmpty(name)) { return; } Manager manager = null; if (spObject is SimPersonality) { manager = Personalities; } else { manager = spObject as Manager; } if (manager != null) { manager.IncStat("Summary: " + msg); } string translated = msg; if (spObject != null) { ulong key = ParserFunctions.ParseUlong(msg, 0); if (key != 0) { translated = Localization.LocalizeString(key); } else { translated = spObject.Localize(msg); } if (string.IsNullOrEmpty(translated)) { translated = "(D) " + spObject.UnlocalizedName + "." + msg; } } if ((notify) && ((logging & StoryLogging.Summary) == StoryLogging.Summary) && (GetValue <ShowSummaryOption, int>() > 0)) { mSummary.Add(translated + ": " + name); } if (((logging & StoryLogging.Log) == StoryLogging.Log) && ((notify) || (GetValue <FullStoryLogOption, bool>()))) { AddSummaryToLog(translated + ": " + name, extended); } }
public void AddSummary(StoryProgressionObject spObject, SimDescription sim, string msg, string[] extended, StoryLogging logging) { if (string.IsNullOrEmpty(msg)) { return; } string sType = null; bool notify = true; if (sim != null) { notify = MatchesAlertLevel(sim); if (notify) { if (!GetValue <AllowSummaryOption, bool>(sim)) { notify = false; } } if (DebuggingEnabled) { if (sim.LotHome != null) { sType = "(R) "; } else if (SimTypes.IsService(sim)) { sType = "(S) "; } else if (SimTypes.IsTourist(sim)) { sType = "(T) "; } else { sType = "(V) "; } } } AddSummary(spObject, sType + FullName(sim), msg, extended, notify, logging); }
public Story PrintFormattedSummary(Manager manager, string storyKey, string summaryKey, SimDescription sim, List <SimDescription> sims, string[] extended, StoryLogging logging) { List <object> parameters = new List <object>(); parameters.Add(sim); foreach (SimDescription other in sims) { if (sim == other) { continue; } parameters.Add(other); } string nameString = ManagerStory.CreateNameString(sims, sim).ToString(); List <object> objs = AddGenderNouns(sim); objs.Add(nameString); parameters.Add(nameString); return(PrintFormattedStory(manager, manager.Localize(storyKey + "Summary", false, objs.ToArray()), summaryKey, parameters.ToArray(), extended, logging)); }