Пример #1
0
        private void LoadSimpsonsCharactersSet()
        {
            SimpsonsCharacters = new CharactersSet("Simpsons");
            List <string> listSim = new List <string>();

            string[] longtextSim = System.IO.File.ReadAllLines("simpsons.txt");
            for (int i = 0; i < longtextSim.Length; i++)
            {
                listSim.Add(" " + longtextSim[i].Remove(longtextSim[i].IndexOf('\t')).ToLower());
            }
            SimpsonsCharacters.charactersName = listSim;
        }
Пример #2
0
        public void LoadCharactersSet(string setName)
        {
            SubstituteCharacters = new CharactersSet(setName.Substring(0, setName.Length - 5));

            List <string> listSim = new List <string>();

            string[] longtextSim = System.IO.File.ReadAllLines(setName);
            for (int i = 0; i < longtextSim.Length; i++)
            {
                listSim.Add(" " + longtextSim[i].Remove(longtextSim[i].IndexOf('\t')));
            }
            SubstituteCharacters.charactersName = listSim;
        }
Пример #3
0
        public void LoadPokemonsCharactersSet()
        {
            SubstituteCharacters = new CharactersSet("Pokemon");
            List <string> listPok = new List <string>();

            string[] longtextPok = System.IO.File.ReadAllLines("pokemon.txt");
            for (int i = 0; i < longtextPok.Length; i++)
            {
                longtextPok[i] = longtextPok[i].Remove(0, 12);
                listPok.Add(" " + longtextPok[i].Remove(longtextPok[i].IndexOf('\t')));
            }
            SubstituteCharacters.charactersName = listPok;
        }
Пример #4
0
        public void ChangeCharacters()
        {
            if (SubstituteCharacters == null)
            {
                SubstituteCharacters = SimpsonsCharacters;
            }
            Random rnd = new Random();

            foreach (string name in SimpsonsCharacters.charactersName)
            {
                if (episode.summary.Contains(name))
                {
                    if ((name == " simpsons" || name == " simpson family") && SubstituteCharacters.GroupName != null)
                    {
                        episode.summary = episode.summary.Replace(name, SubstituteCharacters.GroupName);
                    }
                    else
                    {
                        //random substitute
                        if (!charactersSubdtitutes.ContainsKey(name))
                        {
                            charactersSubdtitutes.Add(name, SubstituteCharacters.charactersName[rnd.Next(0, SubstituteCharacters.charactersName.Count - 1)]);
                        }
                        episode.summary = episode.summary.Replace(name, charactersSubdtitutes[name]);
                    }
                }
                if (episode.summary.Contains(name + "'s"))
                {
                    //random substitute
                    if (!charactersSubdtitutes.ContainsKey(name))
                    {
                        charactersSubdtitutes.Add(name, SubstituteCharacters.charactersName[rnd.Next(0, SubstituteCharacters.charactersName.Count - 1)]);
                    }
                    episode.summary = episode.summary.Replace(name + "'s", charactersSubdtitutes[name] + "'s");
                }
            }
        }