Example #1
0
        static private void GetProblemsFromSeed()
        {
            string seedPath = SeedFilePath();

            byte []      seedContents = System.IO.File.ReadAllBytes(seedPath);
            MemoryStream seedStream   = new MemoryStream(seedContents);

            if (seedContents.Length == 0)
            {
                ThinksyPlugin.ShowEmergencyWindow("The seed file is empty! (" + seedPath + ")");
                throw new Exception("The seed file is empty!");
            }
            //Message.Problem.ProblemGetResponse problemGet = Message.Problem.ProblemGetResponse.ParseFrom (seedContents);
            //Message.Problem.ProblemGetResponse problemGet = ProtoBuf.Serializer.Deserialize<Message.Problem.ProblemGetResponse> (seedStream);

            ThinksyProtosSerializer customSerializer = new ThinksyProtosSerializer();

            Message.Problem.ProblemGetResponse problemGet =
                customSerializer.Deserialize(seedStream, null, typeof(Message.Problem.ProblemGetResponse))
                as Message.Problem.ProblemGetResponse;


            for (int i = 0; i < problemGet.problems.Count; i++)
            {
                Message.Problem.ProblemData problem = problemGet.problems[i];
                ProblemKeeper.AddProblemsToProblemQueue(problem);
            }
        }
 static private void SetCurrentPlayer(Message.Player.Player newPlayer)
 {
     currentPlayer = newPlayer;
     ProblemKeeper.DrainProblems();
 }
 public static void Heartbeat()
 {
     Logger.BasicLog("thump thump");
     Senseix.SenseixSession.GetEncouragements();
     ProblemKeeper.PushAllProblems();
 }
 static public bool SubmitAnswer(Message.Problem.ProblemData Problem, Answer answer, bool correct)
 {
     return(ProblemKeeper.SubmitAnswer(Problem, answer, correct));
 }
 static public bool CheckAnswer(Message.Problem.ProblemData Problem, Answer answer)
 {
     return(ProblemKeeper.CheckAnswer(Problem, answer));
 }
 static public Senseix.Message.Problem.ProblemData PullProblem()
 {
     return(ProblemKeeper.GetProblem());
 }
Example #7
0
 static public void ReplaceQueue(Message.Problem.ProblemGetResponse reply)
 {
     ProblemKeeper.ReplaceSeed(reply);
     ProblemKeeper.DrainProblems();
     ProblemKeeper.GetProblemsFromSeed();
 }