using System; using System.Collections.Generic; using System.Text; using DarkWynter.Game.Globals; using DarkWynter.Engine.Globals; using System.Xml; using Microsoft.Xna.Framework; using DarkWynter.Engine.Utilities; namespace DarkWynter.Game.ChallengeSet { public class Challenge2 : ChallengeAbstract { string noForLoops = "for"; string whileChecks = "while"; string checkCounter = "buildBridge(step)"; string outCheckBridge1 = "You built step 1 of the bridge."; string outCheckBridge2 = "You built step 10 of the bridge."; public Challenge2(XmlNode problemNode) : base(problemNode) { this.id = 2; foreach (XmlNode instrNode in problemNode) { challengeDialogue.Add(instrNode.Attributes["text"].Value); } } public override string GetScaffolding() { challengeSource = @"using System; using DarkWynter.Engine.Compiler; public class Test { public static void MyFunction() { // Method to build the bridges // You need to give the method an int int step = 1; CompilerMethods.buildBridge(); } } "; return challengeSource; } public override bool ValidateStudentCode(string studentCode, string studentOutput) { // If base fails, return if (!base.ValidateStudentCode(studentCode, studentOutput)) { return false; } return true; //// Check input //if (!studentCode.Contains(noForLoops)) // did they use a for loop? //{ // if (studentCode.Contains(whileChecks)) // did they use a while loop? // { // if (studentCode.Contains(checkCounter)) // is the counter in the right place? // { // // Check output // if (studentOutput.StartsWith(outCheckBridge1)) // start with one? // { // if (studentOutput.Contains(outCheckBridge2)) // end with 10? // { // Statics_Game.GameSettings.triesNumber++; // Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Success Message] Student input and output correct [End Success Message]"); // base.setExpPoints(); // return true; // } // else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] Output 2 incorrect [End Error Message]"); // GameForm.customErrorMessage = "The final int you pass into the bridgeBuilder method must be 10. Try again."; // Statics_Game.GameSettings.triesNumber++; // GameForm.customErrorMessage = null; // return false; // } // else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] Output 1 incorrect [End Error Message]"); // GameForm.customErrorMessage = "The first int you pass into the bridgeBuilder method must be 1. Try again."; // Statics_Game.GameSettings.triesNumber++; // return false; // } // else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] Student did not place the counter correctly for the method[End Error Message]"); // GameForm.customErrorMessage = "You need to pass the variable step into the buildBridge method."; // Statics_Game.GameSettings.triesNumber++; // return false; // } // else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] Student used a while loop correctly [End Error Message]"); // GameForm.customErrorMessage = "Use a while loop. Try again."; // Statics_Game.GameSettings.triesNumber++; // return false; //} //else // Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] Student used a for loop [End Error Message]"); //GameForm.customErrorMessage = "Do not use a for loop in your code. Use a while loop instead. Try again."; //Statics_Game.GameSettings.triesNumber++; //return false; } public override bool RunVizualization() { float amount = 5.0f; int radius = 2; Vector3 position = new Vector3(95.0f, 0.0f, 0.0f); // to get from island 3 to island 4, start at 95, 0, 79 and end up at 95, 0, 28 // Set start and endpoints of line Vector3 StartPosition = new Vector3(95, 0, 82); Vector3 EndPosition = new Vector3(95, 0, 28); 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; } } }