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; namespace DarkWynter.Game.ChallengeSet { public class Challenge0 : ChallengeAbstract { string stringCheck = "string"; string numberCheck = "42"; public Challenge0(XmlNode problemNode) : base(problemNode) { this.id = 0; foreach (XmlNode instrNode in problemNode) { challengeDialogue.Add(instrNode.Attributes["text"].Value); } } public override string GetScaffolding() { challengeSource = @"using System; class Test { public static void MyFunction() { int number = 42; Console.WriteLine(number); } }"; return challengeSource; } public override bool ValidateStudentCode(string studentCode, string studentOutput) { // If base fails, return if (!base.ValidateStudentCode(studentCode, studentOutput)) { return false; } // 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? { Statics_Engine.PlayerSettings.studentName = studentOutput; Statics_Game.GameSettings.triesNumber++; Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Success Message] Student input and output correct [End Success Message]"); GameForm.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]"); GameForm.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]"); GameForm.customErrorMessage = "You have to use a string, not an int. Try again."; Statics_Game.GameSettings.triesNumber++; return false; } public override bool RunVizualization() { float amount = 5.0f; int radius = 3; // To get from island 1 to island 2, // start at 18, 0, 42 // end up at 18, 0, 81 // Set start and endpoints of line Vector3 StartPosition = new Vector3(18, 0, 42 ); Vector3 EndPosition = new Vector3(18, 0, 84); TerrainModRequest request = new TerrainModRequest(amount, StartPosition, EndPosition, radius, Enums_Engine.TerrainModType.EQUALTO); // Mod the terrain base.NonControllerBasedTerrainMod(request); Statics_Game.GameSettings.isProblemFinished = true; return true; } } }