示例#1
0
        public override void Load(SerializationReader Reader)
        {
            this.village = HistoricEntity.Load(Reader, XRLCore.Core.Game.sultanHistory).GetCurrentSnapshot();
            this.amount  = Reader.ReadSingle();
            this.faction = Factions.get(Reader.ReadString());

            int countTales = Reader.ReadInt32();

            this.historytales = new List <JournalVillageNote>();
            List <JournalVillageNote> allnotes = JournalAPI.GetNotesForVillage(village.entity.id);

            for (int i = 0; i < countTales; i++)
            {
                string             thissecretid = Reader.ReadString();
                JournalVillageNote note         = allnotes.FirstOrDefault(c => c.secretid == thissecretid);
                if (note != null)
                {
                    this.historytales.Add(note);
                }
            }
            int counttales = Reader.ReadInt32();

            this.tales = new List <string>();
            for (int i = 0; i < counttales; i++)
            {
                this.tales.Add(Reader.ReadString());
            }
        }
示例#2
0
        public override string GetStory(acegiak_RomanceChatNode node, HistoricEntitySnapshot entity)
        {
            if (Stat.Rnd2.NextDouble() < 0.5f)
            {
                var    vars     = new Dictionary <string, string>();
                string storyTag = ((amount > 0) ?
                                   "<spice.eros.opinion.patriot.like.story.!random>" :
                                   "<spice.eros.opinion.patriot.dislike.story.!random>");
                while (this.tales.Count < 5)
                {
                    vars["*sacredThing*"]  = randomGood();
                    vars["*profaneThing*"] = randomBad();
                    this.tales.Add(//"  &K"+storyTag.Substring(1,storyTag.Count()-2)+"&y\n"+
                        acegiak_RomanceText.ExpandString(
                            storyTag, entity, vars));
                }
                return(tales[Stat.Rnd2.Next(tales.Count)]);
            }

            JournalVillageNote e = historytales[Stat.Rnd2.Next(historytales.Count)];

            node.OnLeaveNode = delegate {
                e.Reveal();
            };

            return("<Did you know|I've heard that|There is a tale that says> " + e.GetDisplayText() + (amount > 0?" <Isn't that interesting?|It's so fascinating!|At least, that's what I heard.>":" <Isn't that terrible?|Isn't that horrible?|At least, that's what I heard.>"));
        }
        public override string GetStory(acegiak_RomanceChatNode node, HistoricEntitySnapshot entity)
        {
            if (Stat.Rnd2.NextDouble() > 0.25)
            {
                var vars = new Dictionary <string, string>();
                vars["*sultan*"] = this.faveSultan.GetCurrentSnapshot().GetProperty("name", "a sultan");
                string storyTag = ((amount > 0) ?
                                   "<spice.eros.opinion.sultan.like.story.!random>" :
                                   "<spice.eros.opinion.sultan.dislike.story.!random>");
                while (this.mytales.Count < 5)
                {
                    vars["*sultanLong*"] = vars["*sultan*"] + ", "
                                           + this.faveSultan.GetCurrentSnapshot().GetRandomElementFromListProperty("cognomen", "the ancient sultan", Stat.Rnd2);
                    this.mytales.Add(//"  &K"+storyTag.Substring(1,storyTag.Count()-2)+"&y\n"+
                        acegiak_RomanceText.ExpandString(
                            storyTag, entity, vars));
                }
                return(mytales[Stat.Rnd2.Next(tales.Count)]);
            }

            HistoricEvent e = tales[Stat.Rnd2.Next(tales.Count)];

            node.OnLeaveNode = delegate {
                SultanShrine.RevealBasedOnHistoricalEvent(e);
            };

            return("<Did you know|I've heard that|There is a tale that says> " + e.GetEventProperty("gospel") + (amount > 0?" <Isn't that interesting?|It's so fascinating!|At least, that's what I heard.>":" <Isn't that terrible?|Isn't that horrible?|At least, that's what I heard.>"));
        }
示例#4
0
        public static string ExpandString(string input, HistoricEntitySnapshot entity, History history, Dictionary <string, string> vars = null)
        {
            if (!initialized)
            {
                Init();
            }

            string output = HistoricStringExpander.ExpandString(input, entity, history, vars);

            LogQuery(input, output);

            return(output);
        }
示例#5
0
 public void ExpandText(
     HistoricEntitySnapshot entity,
     Dictionary <string, string> vars = null)
 {
     Text = FilterRandom(Text);
     Text = Text
            //acegiak_RomanceText.ExpandString(
            //Text, entity, vars)
            + "&k"; // Black out village text, mrah
     foreach (ConversationChoice choice in Choices)
     {
         choice.Text = FilterRandom(choice.Text);
         //choice.Text = acegiak_RomanceText.ExpandString(
         //    choice.Text, entity, vars);
     }
 }
示例#6
0
        public override string GetStory(acegiak_RomanceChatNode node, HistoricEntitySnapshot entity)
        {
            var    vars     = new Dictionary <string, string>();
            string storyTag = ((amount > 0) ?
                               "<spice.eros.opinion.food.like.story.!random>" :
                               "<spice.eros.opinion.food.dislike.story.!random>");

            while (this.tales.Count < 5)
            {
                SetSampleObject(vars, exampleObject());
                this.tales.Add(//"  &K"+storyTag.Substring(1,storyTag.Count()-2)+"&y\n"+
                    acegiak_RomanceText.ExpandString(
                        storyTag, entity, vars));
            }
            return(tales[Stat.Rnd2.Next(tales.Count)]);
        }
示例#7
0
        public acegiak_PatriotPreference(acegiak_Romancable romancable)
        {
            Romancable = romancable;


            List <HistoricEntity> villages = HistoryAPI.GetVillages();
            // .Name.Contains("villagers")
            int high = 0;

            foreach (KeyValuePair <string, int> item in  romancable.ParentObject.pBrain.FactionMembership)
            {
                if (item.Key.Contains("villagers"))
                {
                    if (item.Value > high && villages.Select(v => v.GetCurrentSnapshot()).Where(v => item.Key.Contains(v.Name)).Count() > 0)
                    {
                        village = villages.Select(v => v.GetCurrentSnapshot()).Where(v => item.Key.Contains(v.Name)).FirstOrDefault();
                        high    = item.Value;
                        faction = Factions.get(item.Key);
                    }
                }
            }



            amount = (float)((Stat.Rnd2.NextDouble() * 1.5) - 0.5);



            if (village == null || faction == null)
            {
                throw new Exception("Not a villager.");
            }
            //IPart.AddPlayerMessage("They "+(amount>0?"like":"dislike")+" "+this.interestedFaction);
            List <JournalVillageNote> notesForVillage = JournalAPI.GetNotesForVillage(village.entity.id);

            while (this.historytales.Count < 2)
            {
                this.historytales.Add(notesForVillage[Stat.Rnd2.Next(0, notesForVillage.Count)]);
            }
        }
示例#8
0
 public static string ExpandString(string input, HistoricEntitySnapshot entity, Dictionary <string, string> vars = null)
 {
     return(ExpandString(input, entity, null, vars));
 }
示例#9
0
        private HistoricEntitySnapshot GetSelfEntity()
        {
            if (selfEntity != null)
            {
                return(selfEntity);
            }

            havePreference();

            var myBody = ParentObject.GetPart <Body>().GetBody();

            //PronounSet pronouns = ParentObject.GetPronounSet();

            //selfHistory = new HistoricEntity();
            selfEntity = new HistoricEntitySnapshot(null);
            selfEntity.setProperty("name", ParentObject.The + ParentObject.DisplayNameOnlyDirect);

            // Should not use these pronoun forms
            selfEntity.setProperty("subjectPronoun", ParentObject.it);
            selfEntity.setProperty("objectPronoun", ParentObject.them);
            selfEntity.setProperty("possessivePronoun", ParentObject.its);
            selfEntity.setProperty("substantivePossessivePronoun", ParentObject.theirs);

            // Populate entity with storyoptions
            foreach (string option in StoryOptionTags)
            {
                var values = new List <string>();
                foreach (var preference in preferences)
                {
                    // Three items from each preference?
                    for (int i = 0; i < 3; ++i)
                    {
                        string value = preference.getstoryoption(option);
                        if (value != null && value.Count() != 0)
                        {
                            values.Add(value);
                        }
                    }
                }
                if (values.Count() == 0)
                {
                    // Backup
                    string vague = null;
                    for (int i = 0; i < 5; ++i)
                    {
                        vague = acegiak_RomanceText.ExpandString(
                            "<spice.eros.opinion.storyOption." + option + ".!random>",
                            selfEntity, null, null);
                        if (vague != null && vague.Count() > 0)
                        {
                            break;
                        }
                    }

                    if (vague == null || vague.Count() == 0)
                    {
                        vague = "(&R" + option + "&y)";
                    }
                    else if (vague[0] == '<')
                    {
                        vague = "(&R" + vague.Substring(1, vague.Count() - 2) + "&y)";
                    }
                    values.Add(vague);
                }
                selfEntity.listProperties.Add(option, values);
            }

            return(selfEntity);
        }
示例#10
0
 public QA_Node_Helper(string qa_path, HistoricEntitySnapshot entity, Dictionary <string, string> vars)
 {
     qa_base     = "<spice.eros.opinion." + qa_path + ".";
     this.entity = entity;
     this.vars   = vars;
 }
示例#11
0
 public abstract string GetStory(acegiak_RomanceChatNode node, HistoricEntitySnapshot entity);
示例#12
0
        public acegiak_RomanceChatNode Build_QA_Node(
            acegiak_RomanceChatNode node,
            string qa_path,
            string gen_type,
            Dictionary <string, string> vars,
            HistoricEntitySnapshot entity = null)
        {
            var qa_text = new QA_Node_Helper(qa_path, entity, vars);

            string code = qa_text.Get(gen_type);

            acegiak_RomanceText.Log("Q&A Script: " + code);

            string[] parts = code.Split('|');
            if (parts.Count() < 1)
            {
                acegiak_RomanceText.Log("ERROR: Q&A blank: " + code);
            }

            string bodytext;

            if (parts[0] == "Q")
            {
                if (parts.Count() < 3)
                {
                    acegiak_RomanceText.Log("ERROR: Q&A too few params in quiz: " + code);
                }

                // Generated question.
                bodytext = qa_text.Get(parts[1]);

                for (int i = 2; i < parts.Count(); ++i)
                {
                    qa_text.MakeChoiceFromCode(node, parts[i]);
                }
            }
            else if (parts[0] == "S")
            {
                if (parts.Count() != 5)
                {
                    acegiak_RomanceText.Log("ERROR: Q&A need 5 params in show-and-tell: " + code);
                }

                // 1: Generated question.
                bodytext = qa_text.Get(parts[1]);

                // 2: Item types to include and exclude
                var item_filter = new acegiak_ItemFilter(parts[2]);

                // 3: Paths for show prompt and reactions
                string   choice_show;
                string[] react_text  = new string[3];
                int[]    react_value = new int   [3];
                {
                    string[] subparts = parts[3].Split(',');

                    if (subparts.Count() != 7)
                    {
                        acegiak_RomanceText.Log("ERROR: Q&A need 7 params in show section: " + parts[3]);
                    }

                    choice_show = subparts[0];

                    for (int i = 0; i < 3; ++i)
                    {
                        react_text [i] = qa_text.Get(choice_show + "." + subparts[1 + 2 * i]);
                        react_value[i] = 0;
                        if (!int.TryParse(subparts[2 + 2 * i], out react_value[i]))
                        {
                            acegiak_RomanceText.Log("ERROR: Q&A non-integer choice value: " + code);
                        }
                    }
                }

                // 3b: Generate list of showable items.
                List <GameObject> showables = XRLCore.Core.Game.Player.Body.GetPart <Inventory>().GetObjects();
                foreach (BodyPart item in XRLCore.Core.Game.Player.Body.GetPart <Body>().GetEquippedParts())
                {
                    if (item.Equipped != null)
                    {
                        showables.Add(item.Equipped);
                    }
                }

                // Filter and sort the items into buckets assessed quality.
                var itemsGood = new List <GameObject>();
                var itemsNeut = new List <GameObject>();
                var itemsBad  = new List <GameObject>();
                foreach (GameObject item in showables)
                {
                    if (!item_filter.Passes(item))
                    {
                        continue;
                    }

                    var amount = Romancable.assessGift(item, XRLCore.Core.Game.Player.Body).amount;
                    int kind   = 1;
                    if (amount > 0f)
                    {
                        itemsGood.Add(item);
                    }
                    else if (amount < 0f)
                    {
                        itemsBad.Add(item);
                    }
                    else
                    {
                        itemsNeut.Add(item);
                    }
                }

                // Make a set of up to 5 random choices (with value noted)
                //   Include at least one good and one bad option if possible.
                var options = new Dictionary <GameObject, int>();
                if (itemsGood.Count() != 0)
                {
                    int index = (Stat.Rnd2.Next() % itemsGood.Count());
                    options.Add(itemsGood.RemoveRandomElement(Stat.Rnd2), 0);
                    itemsGood.RemoveAt(index);
                }
                if (itemsBad.Count() != 0)
                {
                    int index = (Stat.Rnd2.Next() % itemsBad.Count());
                    options.Add(itemsBad.RemoveRandomElement(Stat.Rnd2), 2);
                    itemsBad.RemoveAt(index);
                }
                while (options.Count() < 5)
                {
                    int
                        good   = itemsGood.Count(),
                        notbad = itemsNeut.Count() + good,
                        total  = itemsBad.Count() + notbad;
                    if (total == 0)
                    {
                        break;
                    }

                    int index = (Stat.Rnd2.Next() % total);
                    if (index < good)
                    {
                        options.Add(itemsGood[index], 0);        itemsGood.RemoveAt(index);
                    }
                    else if (index < notbad)
                    {
                        options.Add(itemsNeut[index - good], 1);   itemsNeut.RemoveAt(index - good);
                    }
                    else
                    {
                        options.Add(itemsBad [index - notbad], 2); itemsBad.RemoveAt(index - notbad);
                    }
                }

                // Now place choices in random order.
                int optionNumber = 1;
                while (options.Count() > 0)
                {
                    int index  = (Stat.Rnd2.Next() % options.Count());
                    var option = options.ElementAt(index);
                    options.Remove(option.Key);

                    SetSampleObject(vars, option.Key, "item", true, 'g', 'y');

                    node.AddChoice(choice_show + optionNumber.ToString(),
                                   qa_text.Get(choice_show + ".a"),
                                   react_text [option.Value],
                                   react_value[option.Value]);
                }

                // 4: Generate neutral response
                qa_text.MakeChoiceFromCode(node, parts[4]);
            }
            else
            {
                bodytext = "&RI have failed to think of an interesting question!&y";
                node.AddChoice("ok", "How unfortunate.", "A terrible shame indeed!", 0);
            }

            // Insert story
            if (Romancable != null)
            {
                node.Text = node.Text + "\n\n" + Romancable.GetStory(node);
            }
            node.Text = node.Text + "\n\n" + bodytext;

            return(node);
        }