//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
namespace DarkWynter.App.ChallengeSet
{
#region Using Statements
using System;
using System.Collections.Generic;
using System.Text;
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.Engine.GameObjects;
using DarkWynter.Engine.EventControl;
using Microsoft.Xna.Framework.Graphics;
#endregion
///
/// The first challenge the player must complete
/// Located in level 1 - Medulla
/// Hello World
///
public class Challenge10 : ChallengeAbstract
{
string stringCheck = "string";
string numberCheck = "s";
string HelloCheck = "Hello";
string helloCheck = "hello";
///
/// Constructor for the first challenge, calls base (challengeAbstract)
///
/// XML Node
public Challenge10(XmlNode problemNode)
: base(problemNode)
{
this.id = 0;
foreach (XmlNode instrNode in problemNode)
{
challengeDialogue.Add(instrNode.Attributes["text"].Value);
}
}
///
/// Scaffolding code for the challenge
///
/// The String holding the scaffolding code (challengeSource)
public override string GetScaffolding()
{
challengeSource =
@"using System;
class Test
{
public static void MyFunction()
{
// Tell us who you are and your
// study ID number.
string name = ""[enter name]"";
Console.WriteLine(name);
// Say 'Hello' to Cera
Console.WriteLine(""[enter greeting]"");
}
}";
return challengeSource;
}
///
/// Parses the student code for validity
///
/// Student's Code
/// Output from the compiler
/// bool
public override bool ValidateStudentCode(string studentCode, string studentOutput)
{
// If base fails, return
if (!base.ValidateStudentCode(studentCode, studentOutput))
{ return false; }
// Clean up the output
// 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?
{
if ((studentOutput.Contains(HelloCheck)) || (studentOutput.Contains(helloCheck)))
{
// set the student name for the game
Statics_Engine.PlayerSettings.studentName = studentOutput.Split(new Char[] { '\r', '\n' })[0];
// Statics_Engine.PlayerSettings.studentIDNumber = int.Parse(studentOutput.Split(new Char[] { '\r', '\n' })[2]);
Statics_Engine.PlayerSettings.studentMessage = studentOutput.Split(new Char[] { '\r', '\n' })[3];
Statics_Engine.GameSettings.triesNumber++;
Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Success Message] Student input and output correct [End Success Message]");
App.CompilerControl.customErrorMessage = null;
GameEventHandler.CurrentGameConditions.triggerSanity = 10;
base.setExpPoints();
return true;
}
else
Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] Student did not say hello to the Thoughts. [End Error Message]");
App.CompilerControl.customErrorMessage = "Use the string 'Hello Cera' and try again.";
Statics_Engine.GameSettings.triesNumber++;
GameEventHandler.CurrentGameConditions.triggerSanity = 11;
return false;
}
else Logging.G2LLogList.Add(DateTime.Now.ToString() + " - [Error Message] Student did not change the name to something else. [End Error Message]");
App.CompilerControl.customErrorMessage = "Change the string name to your name. Try again.";
Statics_Engine.GameSettings.triesNumber++;
GameEventHandler.CurrentGameConditions.triggerSanity = 11;
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_Engine.GameSettings.triesNumber++;
GameEventHandler.CurrentGameConditions.triggerSanity = 11;
return false;
}
///
/// Run the set visualization
///
/// bool
public override bool RunVizualization()
{
// Go Fullscreen so they don't miss the viz...
// DarkWynter.Shell.UCAD.UCAD_Left_SplitContainer.Panel1Collapsed = true;
// DarkWynter.Shell.UCAD.UCAD_Right_SplitContainer.Panel2Collapsed = true;
// DarkWynter.Shell.UCAD.UCAD_Bottom_SplitContainer.Panel2Collapsed = true;
Statics_Engine.GameSettings.isProblemFinished = true;
GameEventHandler.CurrentGameConditions.lastNodeVisited = 1;
GameEventHandler.CurrentGameConditions.triggerSanity = -1;
// DEBUG HACK : Increment AIEvent Index
GameEventHandler.CurrentGameConditions._trigger_ID = 0;
return true;
}
}
}