Exemplo n.º 1
0
        public static void Restart()
        {
            if (!UiEnabled)
            {
                return;
            }
            if (Settings.GetSettings().MachineLessonIndex < 0)
            {
                Settings.GetSettings().MachineLessonIndex = 0;
            }
            else if (Settings.GetSettings().MachineLessonIndex >= machineLessons.Count)
            {
                Settings.GetSettings().MachineLessonIndex = machineLessons.Count - 1;
            }

            currentLesson = machineLessons[Settings.GetSettings().MachineLessonIndex];

            Go();
        }
Exemplo n.º 2
0
        static void Go()
        {
            if (!UiEnabled)
            {
                return;
            }
            var lessons = machineLessons.Where(l => l.Level == Settings.GetSettings().MachineLessonIndex).ToList();

            if (lessons.Count > 0)
            {
                reachedMaxLen = false;

                currentLesson    = lessons.ChooseRandomly();
                executingActions = GetActionMapping(currentLesson.Text);
                Execute(executingActions);
            }
            else
            {
                reachedMaxLen = true;
                MakeLessonFromArticle();
            }
        }
        public static void Seed()
        {
            Debugger.Break();
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string folder = "dataImport";
            //  FactData factD = serializer.Deserialize<FactData>(File.ReadAllText(Path.Combine(folder, "fact.json")));
            //  foreach (var data in factD.Facts)
            //  {
            //      Article art = new Article
            //      {
            //          Name = data.Name,
            //          Text = data.Fact,
            //      };
            //     Database.Insert(art);
            //  }


            //  JokeData joke = serializer.Deserialize<JokeData>(File.ReadAllText(Path.Combine(folder, "joke.json")));
            //  foreach (var data in joke.Jokes)
            //  {
            //      Article art = new Article
            //      {
            //          Name = data.Name,
            //          Text = data.Joke,
            //      };
            //      Database.Insert(art);
            //  }

            // QouteData qoute = serializer.Deserialize<QouteData>(File.ReadAllText(Path.Combine(folder, "qoute.json")));
            //  foreach (var fact in qoute.Qoutes)
            //  {
            //      Article art = new Article
            //      {
            //          Name = fact.Name,
            //          Text = fact.Qoute,
            //      };
            //      Database.Insert(art);
            //  }

            //DefaultLessonData Dlesson = serializer.Deserialize<DefaultLessonData>(File.ReadAllText(Path.Combine(folder, "defaultLesson.json")));

            //  foreach (var lesson in Dlesson.DefaultLessons)
            //  {
            //      DefaultLesson ls = new DefaultLesson()
            //      {
            //          Name = lesson.Name,
            //          Text = new string(lesson.Lesson.Take(100).ToArray())
            //      };
            //      Database.Insert(ls);
            //  }



            MachineLessonData machineLesson = serializer.Deserialize <MachineLessonData>(File.ReadAllText(Path.Combine(folder, "lessonScript.json")));

            foreach (var v in machineLesson.Lessons)
            {
                MachineLesson lesson = new MachineLesson()
                {
                    Text  = v.Script,
                    Level = v.Level,
                };
                Database.Insert(lesson);
            }
        }