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 Challenge3 : ChallengeAbstract { string noForLoops = "for"; string whileCheck = "while (isBombArmed && bombCounter >= 0)"; string whileCheck2 = "while (step < 11)"; string stepCounter1 = "step ++"; string stepCounter2 = "step = step + 1"; string bombCounter1 = "bombCounter --"; string bombCounter2 = "bombCounter = bombCounter - 1"; string outCheckBridge1 = "You built step 1 of the bridge."; string outCheckBridge2 = "You built step 10 of the bridge."; string outCheckBomb3 = "You disarmed bomb 3."; string outCheckBomb2 = "You disarmed bomb 2."; string outCheckBomb1 = "You disarmed bomb 1."; string outCheckBomb0 = "You disarmed bomb 0."; public Challenge3(XmlNode problemNode) : base(problemNode) { this.id = 3; 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() { // insert three variables here // bool isBombArmed // int bombCounter // int step // insert first while loop logic here // use two checks and && (ampersand) them together { // insert second while loop logic here { // Call the CompilerMethods.buildBridge(int) // increment step } // Call the CompilerMethods.disarmBomb(int, bool) // decrement bombCounter } // set bool to false // Write the result of the bool using Console.WriteLine(); } } "; 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)) // no for loops //{ // if (studentCode.Contains(whileCheck)) // first while // { // if (studentCode.Contains(whileCheck2)) // nested while // { // if (studentCode.Contains(stepCounter1) || studentCode.Contains(stepCounter2)) // bridge counter incremented? // { // if (studentCode.Contains(bombCounter1) || studentCode.Contains(bombCounter2)) // bomb counter incremented? // { // // Check output // if (studentOutput.StartsWith(outCheckBridge1)) // does it begin with 1? // { // if (studentOutput.Contains(outCheckBridge2)) // does it end with 10? // { // if (studentOutput.Contains(outCheckBomb3) && studentOutput.Contains(outCheckBomb2) // && studentOutput.Contains(outCheckBomb1) && studentOutput.Contains(outCheckBomb0)) // is the bomboutput correct? // { // if (studentCode.Contains("false")) // did the bool get flipped to false? // { // 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 boolean [End Error Message]"); // GameForm.customErrorMessage = "Print out the results of the boolean in the Console.WriteLine statement."; // Statics_Game.GameSettings.triesNumber++; // return false; // } // else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] - Student bomb output incorrect [End Error Message]"); // GameForm.customErrorMessage = "Check your bomb counter - make sure you are decrementing the number and that you end at 0. Try again."; // Statics_Game.GameSettings.triesNumber++; // return false; // } // else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] - Student bridge 2 output incorrect [End Error Message]"); // GameForm.customErrorMessage = "The final int you pass into the bridgeBuilder method must be 10. Try again."; // Statics_Game.GameSettings.triesNumber++; // return false; // } // else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] - Student bridge 1 output 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 used bridge counter correctly [End Error Message]"); // GameForm.customErrorMessage = "Check your bomb counter - make sure you are decrementing the number. Try again."; // Statics_Game.GameSettings.triesNumber++; // return false; // } // else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] - Student used bomb counter correctly [End Error Message]"); // GameForm.customErrorMessage = "Check your bridge counter - make sure you are incrementing the number. Try again."; // Statics_Game.GameSettings.triesNumber++; // return false; // } // else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] - Student used a second while loop correctly [End Error Message]"); // GameForm.customErrorMessage = "Check your second while loop - make sure you are counting it ten times and that the equality is correct. Try again."; // Statics_Game.GameSettings.triesNumber++; // return false; // } // else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] - Student used a first while loop correctly [End Error Message]"); // GameForm.customErrorMessage = "Check your while loop - isBombArmed is first and the bombCounter is second. Ampersands are &&. 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(0.0f, 0.0f, 20.0f); // to get from island 4 to island 1, start at 82, 0, 20 and end up at 34, 0, 20 // Set start and endpoints of line Vector3 StartPosition = new Vector3(85, 0, 20); Vector3 EndPosition = new Vector3(31, 0, 20); 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; } } }