[gbrainy] Support for answer expressions and attributes in games.xml + related refactor



commit b1021e00b5b0c11f69805e0e2f19c64e9b37a3b4
Author: Jordi Mas <jmas softcatala org>
Date:   Fri Jul 16 16:36:15 2010 +0200

    Support for answer expressions and attributes in games.xml + related refactor

 data/games.xml                                 |   12 +++--
 src/Core/Core.csproj                           |    1 +
 src/Core/Main/Game.cs                          |   29 ++++-------
 src/Core/Main/GameAnswerCheckAttributes.cs     |   64 ++++++++++++++++++++++++
 src/Core/Main/Xml/GameXml.cs                   |   49 ++++++++++++++++++-
 src/Core/Main/Xml/GameXmlDefinition.cs         |    6 ++
 src/Core/Main/Xml/GameXmlFactory.cs            |   31 +++++++++++
 src/Core/Makefile.am                           |    1 +
 src/Games/Calculation/CalculationOperator.cs   |    4 +-
 src/Games/Calculation/CalculationRatio.cs      |    4 +-
 src/Games/Calculation/CalculationTwoNumbers.cs |    4 +-
 src/Games/Logic/PuzzleBuildTriangle.cs         |    4 +-
 src/Games/Logic/PuzzleFigureLetter.cs          |    4 +-
 src/Games/Logic/PuzzleTimeNow.cs               |    4 +-
 tests/Core/GameTest.cs                         |   40 +++++++-------
 15 files changed, 201 insertions(+), 56 deletions(-)
---
diff --git a/data/games.xml b/data/games.xml
index 813b36a..3e8b8f2 100644
--- a/data/games.xml
+++ b/data/games.xml
@@ -221,7 +221,7 @@
 			</variables>
 			<_question>How many boxes measuring 1 x 1 x 0.5 can be packed into a container measuring 6 x 5 x [z]?</_question>
 			<answer>[rslt]</answer>
-			<_rationale>You can pack 6 * 5 * [z] * 2 boxes.</_rationale>
+			<_rationale>You can fit 6 * 5 * [z] * 2 boxes.</_rationale>
 		</variant>
 	</game>
 
@@ -236,11 +236,15 @@
 				int idx = random.Next (years_start.Length - 1);
 				int year_start = years_start [idx];
 				int year_end = years_end [idx];
-				int rslt = years_start [idx + 1];
+				int rslt_a = years_start [idx + 1];
+				int rslt_b = years_end [idx + 1];
 			</variables>
-			<_question>[year_start] was a palindromic year as [year_end] was, a gap of 11 years. What will be the next year with the same gap to its precursor?</_question>
+			<_question>[year_start] was a palindromic year as [year_end] was, a gap of 11 years. What are the next two palindromic years after [year_end] with the same gap?</_question>
 			<_tip>A palindromic number is number that remains the same when its digits are reversed (e.g.: 2112).</_tip>
-			<answer>[rslt]</answer>
+			<answer>[rslt_a] | [rslt_b]</answer>
+			<_answer_show>[rslt_a] and [rslt_b]</_answer_show>
+			<answer_expression>[0-9]+</answer_expression>
+			<answer_checkattributes>Trim | MatchAll </answer_checkattributes>
 			<_rationale>Palindrome years occur usually at 110 year intervals except for the end of each millennium that occur at a 11 years interval.</_rationale>
 		</variant>
 
diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj
index d7316bf..5aa8a73 100644
--- a/src/Core/Core.csproj
+++ b/src/Core/Core.csproj
@@ -95,6 +95,7 @@
     <Compile Include="Libraries\GetText.cs" />
     <Compile Include="Platform\Unix.cs" />
     <Compile Include="Main\Xml\CodeEvaluation.cs" />
+    <Compile Include="Main\GameAnswerCheckAttributes.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ProjectExtensions>
diff --git a/src/Core/Main/Game.cs b/src/Core/Main/Game.cs
index f263dc6..b72f2c2 100644
--- a/src/Core/Main/Game.cs
+++ b/src/Core/Main/Game.cs
@@ -42,16 +42,7 @@ namespace gbrainy.Core.Main
 			All			= Easy | Medium | Master,
 		}
 
-		[Flags]
-		public enum AnswerCheckAttributes
-		{
-			None			= 0,
-			Trim			= 2,
-			IgnoreCase		= 4,
-			IgnoreSpaces		= 8,
-			MatchAll		= 16,
-			MatchAllInOrder		= 32,
-		}
+	
 
 		public const char AnswerSeparator = '|';
 		const int MAX_POSSIBLE_ANSWER = 7;
@@ -122,8 +113,8 @@ namespace gbrainy.Core.Main
 		}
 
 		// How to check the answer
-		public virtual AnswerCheckAttributes CheckAttributes {
-			get { return AnswerCheckAttributes.Trim | AnswerCheckAttributes.IgnoreCase; }
+		public virtual GameAnswerCheckAttributes CheckAttributes {
+			get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase; }
 		}
 
 		public virtual string AnswerCheckExpression {
@@ -390,8 +381,8 @@ namespace gbrainy.Core.Main
 			if (String.IsNullOrEmpty (answer))
 				return false;
 
-			ignore_case = (CheckAttributes & AnswerCheckAttributes.IgnoreCase) == AnswerCheckAttributes.IgnoreCase;
-			ignore_spaces = (CheckAttributes & AnswerCheckAttributes.IgnoreSpaces) == AnswerCheckAttributes.IgnoreSpaces;
+			ignore_case = (CheckAttributes & GameAnswerCheckAttributes.IgnoreCase) == GameAnswerCheckAttributes.IgnoreCase;
+			ignore_spaces = (CheckAttributes & GameAnswerCheckAttributes.IgnoreSpaces) == GameAnswerCheckAttributes.IgnoreSpaces;
 
 			if (ignore_case == true) // This necessary to make pattern selection (e.g. [a-z]) case insensitive
 				regex = new Regex (AnswerCheckExpression, RegexOptions.IgnoreCase);
@@ -408,21 +399,21 @@ namespace gbrainy.Core.Main
 					right_answers [i] = RemoveWhiteSpace (right_answers [i]);
 			}
 
-			if ((CheckAttributes & AnswerCheckAttributes.Trim) == AnswerCheckAttributes.Trim)
+			if ((CheckAttributes & GameAnswerCheckAttributes.Trim) == GameAnswerCheckAttributes.Trim)
 				answer = answer.Trim ();
 
 			if (ignore_spaces)
 				answer = RemoveWhiteSpace (answer);
 
 			// All strings from the list of expected answers (two numbers: 22 | 44) must present in the answer
-			if ((CheckAttributes & AnswerCheckAttributes.MatchAll) == AnswerCheckAttributes.MatchAll ||
-				(CheckAttributes & AnswerCheckAttributes.MatchAllInOrder) == AnswerCheckAttributes.MatchAllInOrder)
+			if ((CheckAttributes & GameAnswerCheckAttributes.MatchAll) == GameAnswerCheckAttributes.MatchAll ||
+				(CheckAttributes & GameAnswerCheckAttributes.MatchAllInOrder) == GameAnswerCheckAttributes.MatchAllInOrder)
 			{
 				int pos = 0;
 				match = regex.Match (answer);
 				while (String.IsNullOrEmpty (match.Value) == false)
 				{
-					if ((CheckAttributes & AnswerCheckAttributes.MatchAll) == AnswerCheckAttributes.MatchAll)
+					if ((CheckAttributes & GameAnswerCheckAttributes.MatchAll) == GameAnswerCheckAttributes.MatchAll)
 					{
 						for (int i = 0; i < right_answers.Length; i++)
 						{
@@ -442,7 +433,7 @@ namespace gbrainy.Core.Main
 					match = match.NextMatch ();
 				}
 
-				if ((CheckAttributes & AnswerCheckAttributes.MatchAllInOrder) == AnswerCheckAttributes.MatchAllInOrder)
+				if ((CheckAttributes & GameAnswerCheckAttributes.MatchAllInOrder) == GameAnswerCheckAttributes.MatchAllInOrder)
 					return true;
 
 				// Have all the expected answers been matched?
diff --git a/src/Core/Main/GameAnswerCheckAttributes.cs b/src/Core/Main/GameAnswerCheckAttributes.cs
new file mode 100644
index 0000000..6e25c60
--- /dev/null
+++ b/src/Core/Main/GameAnswerCheckAttributes.cs
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2007-2010 Jordi Mas i Hernàndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using System;
+using Mono.Unix;
+
+namespace gbrainy.Core.Main
+{
+	[Flags]
+	public enum GameAnswerCheckAttributes
+	{
+		None			= 0,
+		Trim			= 2,
+		IgnoreCase		= 4,
+		IgnoreSpaces		= 8,
+		MatchAll		= 16,
+		MatchAllInOrder		= 32,
+	}
+	
+	// Since we cannot override ToString in an enum type we use a helper class
+	public static class GameAnswerCheckAttributesDescription
+	{
+		// string (not localized) to enum representation 
+		static public GameAnswerCheckAttributes FromString (string type)
+		{
+			GameAnswerCheckAttributes attributes;
+
+			attributes = GameAnswerCheckAttributes.None;
+
+			if (type.IndexOf ("Trim", StringComparison.InvariantCultureIgnoreCase) != -1)
+				attributes |= GameAnswerCheckAttributes.Trim;
+
+			if (type.IndexOf ("IgnoreCase", StringComparison.InvariantCultureIgnoreCase) != -1)
+				attributes |= GameAnswerCheckAttributes.IgnoreCase;
+
+			if (type.IndexOf ("IgnoreSpaces", StringComparison.InvariantCultureIgnoreCase) != -1)
+				attributes |= GameAnswerCheckAttributes.IgnoreSpaces;
+
+			if (type.IndexOf ("MatchAll", StringComparison.InvariantCultureIgnoreCase) != -1)
+				attributes |= GameAnswerCheckAttributes.MatchAll;
+
+			if (type.IndexOf ("MatchAllInOrder", StringComparison.InvariantCultureIgnoreCase) != -1)
+				attributes |= GameAnswerCheckAttributes.MatchAllInOrder;
+
+			return attributes;
+		}
+	}
+}
diff --git a/src/Core/Main/Xml/GameXml.cs b/src/Core/Main/Xml/GameXml.cs
index e4af9c1..318455a 100644
--- a/src/Core/Main/Xml/GameXml.cs
+++ b/src/Core/Main/Xml/GameXml.cs
@@ -48,7 +48,48 @@ namespace gbrainy.Core.Main.Xml
 
 		DefinitionLocator current;
 		GameXmlDefinition game;
-		string question, answer, rationale;
+		string question, answer, rationale, answer_value;
+
+		public override GameAnswerCheckAttributes CheckAttributes  {
+			get {
+				GameAnswerCheckAttributes attrib;
+
+				if (game.Variants.Count > 0 && game.Variants[current.Variant].CheckAttributes != GameAnswerCheckAttributes.None)
+					attrib = game.Variants[current.Variant].CheckAttributes;
+				else
+					attrib =  game.CheckAttributes;
+
+				if (attrib == GameAnswerCheckAttributes.None)
+					return base.CheckAttributes;
+
+				return attrib;
+			}
+		}
+
+		public override string AnswerCheckExpression {
+			get {
+				string expression;
+
+				if (game.Variants.Count > 0 && String.IsNullOrEmpty (game.Variants[current.Variant].AnswerCheckExpression) == false)
+					expression = game.Variants[current.Variant].AnswerCheckExpression;
+				else
+					expression =  game.AnswerCheckExpression;
+
+				if (String.IsNullOrEmpty (expression))
+					return base.AnswerCheckExpression;
+	
+				return expression;
+			}
+		}
+
+		public override string AnswerValue {
+			get {
+				if (String.IsNullOrEmpty (answer_value))
+					return base.AnswerValue;
+
+				return answer_value;
+			}
+		}
 
 		static public List <GameXmlDefinition> Definitions {
 			set {
@@ -107,6 +148,11 @@ namespace gbrainy.Core.Main.Xml
 			else
 				rationale = CatalogGetString (game.Rationale);
 
+			if (variants && game.Variants[current.Variant].AnswerShow != null)
+				answer_value = game.Variants[current.Variant].AnswerShow;
+			else
+				answer_value = game.AnswerShow;
+
 			if (variants && game.Variants[current.Variant].Variables != null)
 				variables = game.Variants[current.Variant].Variables;
 			else
@@ -119,6 +165,7 @@ namespace gbrainy.Core.Main.Xml
 				question = CodeEvaluation.ReplaceVariables (question);
 				answer = CodeEvaluation.ReplaceVariables (answer);
 				rationale = CodeEvaluation.ReplaceVariables (rationale);
+				answer_value = CodeEvaluation.ReplaceVariables (answer_value);
 			}
 
 			right_answer = answer;
diff --git a/src/Core/Main/Xml/GameXmlDefinition.cs b/src/Core/Main/Xml/GameXmlDefinition.cs
index e1437ad..0855ac4 100644
--- a/src/Core/Main/Xml/GameXmlDefinition.cs
+++ b/src/Core/Main/Xml/GameXmlDefinition.cs
@@ -53,6 +53,10 @@ namespace gbrainy.Core.Main.Xml
 		public string Rationale { get; set; }
 		public string Answer { get; set; }
 		public string Variables { get; set; }
+		public GameAnswerCheckAttributes CheckAttributes { get; set; }
+		public string AnswerCheckExpression  { get; set; }
+		public string AnswerShow { get; set; }
+		string expression;
 
 		List <DrawingObject> drawing_objects;
 
@@ -81,6 +85,8 @@ namespace gbrainy.Core.Main.Xml
 			str.AppendLine ("Tip: " + Tip);
 			str.AppendLine ("Rationale: " + Rationale);
 			str.AppendLine ("Answer: " + Answer);
+			str.AppendLine ("CheckAttributes: " + CheckAttributes);
+			str.AppendLine ("AnswerCheckExpression: " + AnswerCheckExpression);
 
 			return str.ToString ();
 		}
diff --git a/src/Core/Main/Xml/GameXmlFactory.cs b/src/Core/Main/Xml/GameXmlFactory.cs
index b8e94b5..3cbfef5 100644
--- a/src/Core/Main/Xml/GameXmlFactory.cs
+++ b/src/Core/Main/Xml/GameXmlFactory.cs
@@ -216,6 +216,37 @@ namespace gbrainy.Core.Main.Xml
 							game.Answer = reader.ReadElementString ();
 
 						break;
+					case "_answer_show":
+						if (reader.NodeType != XmlNodeType.Element)
+							break;
+
+						if (processing_variant)
+							game.Variants[variant].AnswerShow = reader.ReadElementString ();
+						else
+							game.AnswerShow = reader.ReadElementString ();
+
+						break;
+					case "answer_expression":
+						if (reader.NodeType != XmlNodeType.Element)
+							break;
+
+						if (processing_variant)
+							game.Variants[variant].AnswerCheckExpression = reader.ReadElementString ();
+						else
+							game.AnswerCheckExpression = reader.ReadElementString ();
+
+						break;
+					case "answer_checkattributes":
+						if (reader.NodeType != XmlNodeType.Element)
+							break;
+
+						if (processing_variant)
+							game.Variants[variant].CheckAttributes = GameAnswerCheckAttributesDescription.FromString (reader.ReadElementString ());
+						else
+							game.CheckAttributes = GameAnswerCheckAttributesDescription.FromString (reader.ReadElementString ());
+
+						game.CheckAttributes = GameAnswerCheckAttributesDescription.FromString (reader.ReadElementString ());
+						break;
 					case "_tip":
 						if (reader.NodeType != XmlNodeType.Element)
 							break;
diff --git a/src/Core/Makefile.am b/src/Core/Makefile.am
index 2ad2d90..42a7ee5 100644
--- a/src/Core/Makefile.am
+++ b/src/Core/Makefile.am
@@ -12,6 +12,7 @@ CSDISTFILES =  \
 		$(srcdir)/Main/ColorPalette.cs		\
 		$(srcdir)/Main/IMouseEvent.cs		\
 		$(srcdir)/Main/Game.cs			\
+		$(srcdir)/Main/GameAnswerCheckAttributes.cs \
 		$(srcdir)/Main/GameManager.cs		\
 		$(srcdir)/Main/GameSession.cs		\
 		$(srcdir)/Main/GameSessionHistory.cs	\
diff --git a/src/Games/Calculation/CalculationOperator.cs b/src/Games/Calculation/CalculationOperator.cs
index 727d8b4..77350bc 100644
--- a/src/Games/Calculation/CalculationOperator.cs
+++ b/src/Games/Calculation/CalculationOperator.cs
@@ -53,8 +53,8 @@ namespace gbrainy.Games.Calculation
 			get { return "[+*-/]"; }
 		}
 
-		public override AnswerCheckAttributes CheckAttributes {
-			get { return AnswerCheckAttributes.Trim | AnswerCheckAttributes.MatchAll; }
+		public override GameAnswerCheckAttributes CheckAttributes {
+			get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll; }
 		}
 
 		public override string AnswerValue {
diff --git a/src/Games/Calculation/CalculationRatio.cs b/src/Games/Calculation/CalculationRatio.cs
index 9995e26..98e7bc2 100644
--- a/src/Games/Calculation/CalculationRatio.cs
+++ b/src/Games/Calculation/CalculationRatio.cs
@@ -57,8 +57,8 @@ namespace gbrainy.Games.Calculation
 			get { return Catalog.GetString ("A ratio specifies a proportion between two numbers. A ratio a:b means that for every 'a' parts you have 'b' parts.");}
 		}
 
-		public override AnswerCheckAttributes CheckAttributes {
-			get { return AnswerCheckAttributes.Trim | AnswerCheckAttributes.MatchAll; }
+		public override GameAnswerCheckAttributes CheckAttributes {
+			get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll; }
 		}
 
 		public override string AnswerCheckExpression {
diff --git a/src/Games/Calculation/CalculationTwoNumbers.cs b/src/Games/Calculation/CalculationTwoNumbers.cs
index bc177e1..53d44c7 100644
--- a/src/Games/Calculation/CalculationTwoNumbers.cs
+++ b/src/Games/Calculation/CalculationTwoNumbers.cs
@@ -60,8 +60,8 @@ namespace gbrainy.Games.Calculation
 			}
 		}
 
-		public override AnswerCheckAttributes CheckAttributes {
-			get { return AnswerCheckAttributes.Trim | AnswerCheckAttributes.MatchAll; }
+		public override GameAnswerCheckAttributes CheckAttributes {
+			get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll; }
 		}
 
 		public override string AnswerCheckExpression {
diff --git a/src/Games/Logic/PuzzleBuildTriangle.cs b/src/Games/Logic/PuzzleBuildTriangle.cs
index 7c6b45e..92c54fd 100644
--- a/src/Games/Logic/PuzzleBuildTriangle.cs
+++ b/src/Games/Logic/PuzzleBuildTriangle.cs
@@ -63,8 +63,8 @@ namespace gbrainy.Games.Logic
 			get { return Catalog.GetString ("The resulting triangle is isosceles.");}
 		}
 
-		public override AnswerCheckAttributes CheckAttributes {
-			get { return AnswerCheckAttributes.Trim | AnswerCheckAttributes.IgnoreCase | AnswerCheckAttributes.MatchAll; }
+		public override GameAnswerCheckAttributes CheckAttributes {
+			get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll; }
 		}
 
 		public override string AnswerCheckExpression {
diff --git a/src/Games/Logic/PuzzleFigureLetter.cs b/src/Games/Logic/PuzzleFigureLetter.cs
index 57d6a84..6f5e197 100644
--- a/src/Games/Logic/PuzzleFigureLetter.cs
+++ b/src/Games/Logic/PuzzleFigureLetter.cs
@@ -56,8 +56,8 @@ namespace gbrainy.Games.Logic
 			}
 		}
 
-		public override AnswerCheckAttributes CheckAttributes {
-			get { return AnswerCheckAttributes.Trim | AnswerCheckAttributes.IgnoreCase | AnswerCheckAttributes.MatchAll; }
+		public override GameAnswerCheckAttributes CheckAttributes {
+			get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll; }
 		}
 
 		public override string AnswerCheckExpression {
diff --git a/src/Games/Logic/PuzzleTimeNow.cs b/src/Games/Logic/PuzzleTimeNow.cs
index 0538a31..87b3715 100644
--- a/src/Games/Logic/PuzzleTimeNow.cs
+++ b/src/Games/Logic/PuzzleTimeNow.cs
@@ -53,8 +53,8 @@ namespace gbrainy.Games.Logic
 			}
 		}
 
-		public override AnswerCheckAttributes CheckAttributes {
-			get { return AnswerCheckAttributes.Trim | AnswerCheckAttributes.IgnoreCase | AnswerCheckAttributes.IgnoreSpaces; }
+		public override GameAnswerCheckAttributes CheckAttributes {
+			get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.IgnoreSpaces; }
 		}
 
 		protected override void Initialize ()
diff --git a/tests/Core/GameTest.cs b/tests/Core/GameTest.cs
index 0b56137..e77dd0d 100644
--- a/tests/Core/GameTest.cs
+++ b/tests/Core/GameTest.cs
@@ -27,7 +27,7 @@ namespace gbrainyTest
 	public class TestGame : Game
 	{
 		public string Expression { get; set; }
-		public Game.AnswerCheckAttributes Attributes { get; set; }
+		public GameAnswerCheckAttributes Attributes { get; set; }
 
 		public TestGame ()
 		{
@@ -59,7 +59,7 @@ namespace gbrainyTest
 			}
 		}
 
-		public override AnswerCheckAttributes CheckAttributes {
+		public override GameAnswerCheckAttributes CheckAttributes {
 			get { return Attributes; }
 		}
 
@@ -82,20 +82,20 @@ namespace gbrainyTest
 		{
 			TestGame game = new TestGame ();
 
-			game.Attributes = Game.AnswerCheckAttributes.None;
+			game.Attributes = GameAnswerCheckAttributes.None;
 			game.RightAnswer = "icon";
 			Assert.AreEqual (true, game.CheckAnswer ("icon"));
 			Assert.AreEqual (false, game.CheckAnswer (" icon "));
 
-			game.Attributes = Game.AnswerCheckAttributes.Trim;
+			game.Attributes = GameAnswerCheckAttributes.Trim;
 			Assert.AreEqual (true, game.CheckAnswer ("icon"));
 			Assert.AreEqual (true, game.CheckAnswer (" icon "));
 
-			game.Attributes = Game.AnswerCheckAttributes.MatchAll;
+			game.Attributes = GameAnswerCheckAttributes.MatchAll;
 			Assert.AreEqual (true, game.CheckAnswer ("icon"));
 			Assert.AreEqual (false, game.CheckAnswer (" icon "));
 
-			game.Attributes = Game.AnswerCheckAttributes.Trim | Game.AnswerCheckAttributes.MatchAll;
+			game.Attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
 			Assert.AreEqual (true, game.CheckAnswer ("icon"));
 			Assert.AreEqual (true, game.CheckAnswer (" icon "));
 		}
@@ -105,20 +105,20 @@ namespace gbrainyTest
 		{
 			TestGame game = new TestGame ();
 
-			game.Attributes = Game.AnswerCheckAttributes.None;
+			game.Attributes = GameAnswerCheckAttributes.None;
 			game.RightAnswer = "icon";
 			Assert.AreEqual (true, game.CheckAnswer ("icon"));
 			Assert.AreEqual (false, game.CheckAnswer ("ICON"));
 
-			game.Attributes = Game.AnswerCheckAttributes.IgnoreCase;
+			game.Attributes = GameAnswerCheckAttributes.IgnoreCase;
 			Assert.AreEqual (true, game.CheckAnswer ("icon"));
 			Assert.AreEqual (true, game.CheckAnswer ("ICON"));
 
-			game.Attributes = Game.AnswerCheckAttributes.MatchAll;
+			game.Attributes = GameAnswerCheckAttributes.MatchAll;
 			Assert.AreEqual (true, game.CheckAnswer ("icon"));
 			Assert.AreEqual (false, game.CheckAnswer ("ICON"));
 
-			game.Attributes = Game.AnswerCheckAttributes.IgnoreCase | Game.AnswerCheckAttributes.MatchAll;
+			game.Attributes = GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll;
 			Assert.AreEqual (true, game.CheckAnswer ("icon"));
 			Assert.AreEqual (true, game.CheckAnswer ("ICON"));
 		}
@@ -128,20 +128,20 @@ namespace gbrainyTest
 		{
 			TestGame game = new TestGame ();
 
-			game.Attributes = Game.AnswerCheckAttributes.None;
+			game.Attributes = GameAnswerCheckAttributes.None;
 			game.RightAnswer = "10 pm";
 			Assert.AreEqual (true, game.CheckAnswer ("10 pm"));
 			Assert.AreEqual (false, game.CheckAnswer ("10pm"));
 
-			game.Attributes = Game.AnswerCheckAttributes.IgnoreSpaces;
+			game.Attributes = GameAnswerCheckAttributes.IgnoreSpaces;
 			Assert.AreEqual (true, game.CheckAnswer ("10 pm"));
 			Assert.AreEqual (true, game.CheckAnswer ("10pm"));
 
-			game.Attributes = Game.AnswerCheckAttributes.MatchAll;
+			game.Attributes = GameAnswerCheckAttributes.MatchAll;
 			Assert.AreEqual (true, game.CheckAnswer ("10 pm"));
 			Assert.AreEqual (false, game.CheckAnswer ("10pm"));
 
-			game.Attributes = Game.AnswerCheckAttributes.IgnoreSpaces | Game.AnswerCheckAttributes.MatchAll;
+			game.Attributes = GameAnswerCheckAttributes.IgnoreSpaces | GameAnswerCheckAttributes.MatchAll;
 			Assert.AreEqual (true, game.CheckAnswer ("10 pm"));
 			Assert.AreEqual (true, game.CheckAnswer ("10pm"));
 		}
@@ -151,7 +151,7 @@ namespace gbrainyTest
 		{
 			TestGame game = new TestGame ();
 
-			game.Attributes = Game.AnswerCheckAttributes.MatchAllInOrder;
+			game.Attributes = GameAnswerCheckAttributes.MatchAllInOrder;
 			game.Expression = "[0-9]+";
 			game.RightAnswer = "10 | 20 | 30";
 
@@ -164,7 +164,7 @@ namespace gbrainyTest
 		{
 			TestGame game = new TestGame ();
 
-			game.Attributes = Game.AnswerCheckAttributes.MatchAll;
+			game.Attributes = GameAnswerCheckAttributes.MatchAll;
 			game.Expression = "[0-9]+";
 			game.RightAnswer = "10 | 20 | 30";
 			Assert.AreEqual (true, game.CheckAnswer ("10 20 30"));
@@ -203,7 +203,7 @@ namespace gbrainyTest
 		{
 			TestGame game = new TestGame ();
 			game.RightAnswer = "10 PM";
-			game.Attributes = Game.AnswerCheckAttributes.Trim | Game.AnswerCheckAttributes.IgnoreCase | Game.AnswerCheckAttributes.IgnoreSpaces;
+			game.Attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.IgnoreSpaces;
 
 			Assert.AreEqual (true, game.CheckAnswer ("10 PM"));
 			Assert.AreEqual (true, game.CheckAnswer ("10 pm"));
@@ -221,7 +221,7 @@ namespace gbrainyTest
 			TestGame game = new TestGame ();
 			game.RightAnswer = "+ | -";
 			game.Expression = "[+*-/]";
-			game.Attributes = Game.AnswerCheckAttributes.Trim | Game.AnswerCheckAttributes.MatchAllInOrder;
+			game.Attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAllInOrder;
 
 			Assert.AreEqual (true, game.CheckAnswer ("+ i -"));
 			Assert.AreEqual (true, game.CheckAnswer ("+ and -"));
@@ -238,7 +238,7 @@ namespace gbrainyTest
 	
 			game.RightAnswer = "A | B | C";
 			game.Expression = "[ABCDF]";
-			game.Attributes = Game.AnswerCheckAttributes.Trim | Game.AnswerCheckAttributes.IgnoreCase | Game.AnswerCheckAttributes.MatchAll;
+			game.Attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll;
 
 			Assert.AreEqual (true, game.CheckAnswer ("A B C"));
 			Assert.AreEqual (true, game.CheckAnswer ("C B A"));
@@ -277,7 +277,7 @@ namespace gbrainyTest
 			TestGame game = new TestGame ();
 			game.RightAnswer = "10 | 20";
 			game.Expression = "[0-9]+";
-			game.Attributes = Game.AnswerCheckAttributes.Trim | Game.AnswerCheckAttributes.MatchAll;
+			game.Attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
 
 			// Right answers
 			Assert.AreEqual (true, game.CheckAnswer ("10 and 20"));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]