using System; using System.Collections.Generic; using System.Text; using DarkWynter.Game.Globals; using System.ComponentModel; using System.Data; using System.Drawing; using System.Windows.Forms; using System.Xml; using DarkWynter.Engine.Globals; using DarkWynter.Engine.Utilities; using Microsoft.Xna.Framework; using DarkWynter.Game.GameObjects; using DarkWynter.Engine.GameObjects; using DarkWynter.Engine.ObjectLib; namespace DarkWynter.App.ChallengeSet { public class Challenge1 : ChallengeAbstract { string stringCheck = "string"; string numberCheck = "42"; public Challenge1(XmlNode problemNode) : base(problemNode) { this.id = 1; foreach (XmlNode instrNode in problemNode) { challengeDialogue.Add(instrNode.Attributes["text"].Value); } } public override string GetScaffolding() { challengeSource = @" using System; using System.Collections.Generic; using System.Text; class UserCode { public static void myFunction() { ThoughtList myThoughts = new ThoughtList(); //declaration of your list of thoughts for (int x = 0; x < myThoughts.Count; x ++) { myThoughts[x].setDestination.toExit(); myThoughts.setDestination(Exit); } } } "; return challengeSource; } public override bool ValidateStudentCode(string studentCode, string studentOutput) { // If base fails, return if (!base.ValidateStudentCode(studentCode, studentOutput)) { return false; } //return true; // Clean up the output first because forms are dumb shits // studentOutput = studentOutput.Replace('\r', ' '); // studentOutput = studentOutput.Replace('\n', ' '); // studentOutput = studentOutput.Trim(); // Check Input if (studentCode.Contains(stringCheck)) // did they use a string? { // Check Output if (!(studentOutput == numberCheck)) // did they change their name from 42 to something else? { // set the student name for the game Statics_Engine.PlayerSettings.studentName = studentOutput.Split(new Char[] {'\r','\n'})[0]; Statics_Engine.PlayerSettings.studentMessage = studentOutput.Split(new Char[] { '\r', '\n' })[2]; Statics_Game.GameSettings.triesNumber++; Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Success Message] Student input and output correct [End Success Message]"); App.CompilerControl.customErrorMessage = null; base.setExpPoints(); return true; } else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] Student did not change the name from 42 to something else. [End Error Message]"); App.CompilerControl.customErrorMessage = "Change the number 42 to your name. Try again."; Statics_Game.GameSettings.triesNumber++; return false; } else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] Student did not use a string for the name [End Error Message]"); App.CompilerControl.customErrorMessage = "You have to use a string, not an int. Try again."; Statics_Game.GameSettings.triesNumber++; return false; } public override bool RunVizualization() { //Statics_Game.GameSettings.myThoughts; Statics_Game.GameSettings.isProblemFinished = true; //Statics_Game.GameSettings.isProblemFinished = true; //DarkWynter.Engine.Globals.XML.levelInfoIndex = 1; //DarkWynter.Engine.Globals.Statics_Engine.GameSettings.LoadScreenLoaded = true; return true; } } }