[gbrainy] Decouple Answer logic from Game clas
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Decouple Answer logic from Game clas
- Date: Tue, 1 Mar 2011 21:09:36 +0000 (UTC)
commit a9b8dddbff66638e23dede2c7888365d8a5ccc58
Author: Jordi Mas <jmas softcatala org>
Date: Tue Mar 1 22:11:29 2011 +0100
Decouple Answer logic from Game clas
po/POTFILES.in | 1 +
src/Clients/Classical/gbrainy.cs | 6 +-
src/Clients/WebForms/Game.aspx.cs | 2 +-
src/Core/Core.csproj | 2 +
src/Core/Main/Game.cs | 184 ++-----------------
src/Core/Main/GameAnswer.cs | 196 ++++++++++++++++++++
src/Core/Main/GameAnswerEventArgs.cs | 34 ++++
src/Core/Main/PdfExporter.cs | 2 +-
src/Core/Main/Verbal/Analogies.cs | 8 +-
src/Core/Main/Verbal/AnalogiesMultipleOptions.cs | 8 +-
.../Main/Verbal/AnalogiesPairOfWordsCompare.cs | 2 +-
.../Main/Verbal/AnalogiesPairOfWordsOptions.cs | 8 +-
src/Core/Main/Verbal/AnalogiesQuestionAnswer.cs | 2 +-
src/Core/Main/Xml/GameXml.cs | 89 +++++----
src/Core/Main/Xml/GameXmlDefinitionVariant.cs | 6 +-
src/Core/Main/Xml/GameXmlFactory.cs | 12 +-
src/Core/Main/Xml/OptionDrawingObject.cs | 6 +-
src/Core/Makefile.am | 2 +
src/Games/Calculation/CalculationArithmetical.cs | 4 +-
src/Games/Calculation/CalculationAverage.cs | 8 +-
src/Games/Calculation/CalculationCloserFraction.cs | 8 +-
src/Games/Calculation/CalculationFractions.cs | 4 +-
.../Calculation/CalculationGreatestDivisor.cs | 10 +-
src/Games/Calculation/CalculationOperator.cs | 12 +-
src/Games/Calculation/CalculationPrimes.cs | 10 +-
src/Games/Calculation/CalculationProportions.cs | 8 +-
src/Games/Calculation/CalculationRatio.cs | 12 +-
src/Games/Calculation/CalculationTwoNumbers.cs | 18 +--
src/Games/Logic/Puzzle3DCube.cs | 2 +-
src/Games/Logic/PuzzleBalance.cs | 2 +-
src/Games/Logic/PuzzleBuildTriangle.cs | 22 +--
src/Games/Logic/PuzzleCirclesSquare.cs | 2 +-
src/Games/Logic/PuzzleClocks.cs | 12 +-
src/Games/Logic/PuzzleCountCircles.cs | 2 +-
src/Games/Logic/PuzzleCountSeries.cs | 6 +-
src/Games/Logic/PuzzleCounting.cs | 2 +-
src/Games/Logic/PuzzleCoverPercentage.cs | 7 +-
src/Games/Logic/PuzzleCube.cs | 2 +-
src/Games/Logic/PuzzleDice.cs | 2 +-
src/Games/Logic/PuzzleDivideCircle.cs | 4 +-
src/Games/Logic/PuzzleEquation.cs | 2 +-
src/Games/Logic/PuzzleExtraCircle.cs | 8 +-
src/Games/Logic/PuzzleFigureLetter.cs | 17 +-
src/Games/Logic/PuzzleFigurePattern.cs | 6 +-
src/Games/Logic/PuzzleFigures.cs | 16 +-
src/Games/Logic/PuzzleFourSided.cs | 4 +-
src/Games/Logic/PuzzleHandshakes.cs | 2 +-
src/Games/Logic/PuzzleLargerShape.cs | 12 +-
src/Games/Logic/PuzzleLines.cs | 2 +-
src/Games/Logic/PuzzleMatrixGroups.cs | 2 +-
src/Games/Logic/PuzzleMatrixNumbers.cs | 2 +-
src/Games/Logic/PuzzleMissingPiece.cs | 8 +-
src/Games/Logic/PuzzleMissingSlice.cs | 8 +-
src/Games/Logic/PuzzleMostInCommon.cs | 8 +-
src/Games/Logic/PuzzleMoveFigure.cs | 4 +-
src/Games/Logic/PuzzleNextFigure.cs | 8 +-
src/Games/Logic/PuzzleNumericRelation.cs | 2 +-
src/Games/Logic/PuzzleNumericSequence.cs | 2 +-
src/Games/Logic/PuzzleOstracism.cs | 10 +-
src/Games/Logic/PuzzlePencil.cs | 18 +-
src/Games/Logic/PuzzlePeopleTable.cs | 6 +-
src/Games/Logic/PuzzlePercentage.cs | 7 +-
src/Games/Logic/PuzzlePredicateLogic.cs | 24 ++--
src/Games/Logic/PuzzleQuadrilaterals.cs | 8 +-
src/Games/Logic/PuzzleRelatedNumbers.cs | 2 +-
src/Games/Logic/PuzzleSquareDots.cs | 8 +-
src/Games/Logic/PuzzleSquareSheets.cs | 2 +-
src/Games/Logic/PuzzleSquares.cs | 4 +-
src/Games/Logic/PuzzleSquaresAndLetters.cs | 2 +-
src/Games/Logic/PuzzleTetris.cs | 8 +-
src/Games/Logic/PuzzleTimeNow.cs | 10 +-
src/Games/Logic/PuzzleTrains.cs | 2 +-
src/Games/Logic/PuzzleTriangles.cs | 4 +-
src/Games/Logic/PuzzleTrianglesWithNumbers.cs | 6 +-
src/Games/Memory/MemoryColouredFigures.cs | 8 +-
src/Games/Memory/MemoryColouredText.cs | 2 +-
src/Games/Memory/MemoryCountDots.cs | 2 +-
src/Games/Memory/MemoryFacts.cs | 8 +-
src/Games/Memory/MemoryFigures.cs | 2 +-
src/Games/Memory/MemoryFiguresAndText.cs | 2 +-
src/Games/Memory/MemoryFiguresNumbers.cs | 8 +-
src/Games/Memory/MemoryIndications.cs | 14 +-
src/Games/Memory/MemoryNumbers.cs | 2 +-
src/Games/Memory/MemoryWords.cs | 2 +-
tests/Core/GameTest.cs | 102 ++++------
tests/Core/GameXmlFactoryTest.cs | 6 +-
86 files changed, 573 insertions(+), 548 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 23c59ab..11218bd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,6 +11,7 @@ src/Core/Views/WelcomeView.cs
src/Core/Libraries/SVGImage.cs
src/Core/Main/ColorPalette.cs
src/Core/Main/Game.cs
+src/Core/Main/GameAnswer.cs
src/Core/Main/GameManager.cs
src/Core/Main/GameSession.cs
src/Core/Main/GameTips.cs
diff --git a/src/Clients/Classical/gbrainy.cs b/src/Clients/Classical/gbrainy.cs
index 6f37fd0..665ec25 100755
--- a/src/Clients/Classical/gbrainy.cs
+++ b/src/Clients/Classical/gbrainy.cs
@@ -494,9 +494,9 @@ namespace gbrainy.Clients.Classical
}
// The user has clicked with the mouse in an answer and generated this event
- void OnAnswerFromGame (object obj, Game.AnswerEventArgs args)
+ void OnAnswerFromGame (object obj, GameAnswerEventArgs args)
{
- answer_entry.Text = args.Answer;
+ answer_entry.Text = args.AnswerText;
OnAnswerButtonClicked (this, EventArgs.Empty);
session.CurrentGame.AnswerEvent -= OnAnswerFromGame; // User can only answer once
}
@@ -530,7 +530,7 @@ namespace gbrainy.Clients.Classical
session.EnableTimer = false;
answer_entry.Text = String.Empty;
UpdateStatusBar ();
- UpdateSolution (answer + " " + session.CurrentGame.Answer,
+ UpdateSolution (answer + " " + session.CurrentGame.AnswerText,
correct == true ? GameDrawingArea.SolutionType.CorrectAnswer :
GameDrawingArea.SolutionType.InvalidAnswer);
diff --git a/src/Clients/WebForms/Game.aspx.cs b/src/Clients/WebForms/Game.aspx.cs
index a9520c9..8de898c 100644
--- a/src/Clients/WebForms/Game.aspx.cs
+++ b/src/Clients/WebForms/Game.aspx.cs
@@ -292,7 +292,7 @@ namespace gbrainy.Clients.WebForms
result_label.CssClass = null;
}
- rationale_label.Text = WebSession.GameState.CurrentGame.Answer;
+ rationale_label.Text = WebSession.GameState.CurrentGame.AnswerText;
answer_button.Enabled = false;
}
}
diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj
index 3b66de6..d4ce4f7 100644
--- a/src/Core/Core.csproj
+++ b/src/Core/Core.csproj
@@ -111,6 +111,8 @@
<Compile Include="Libraries\TranslationsCatalog.cs" />
<Compile Include="Services\IConfiguration.cs" />
<Compile Include="Services\MemoryConfiguration.cs" />
+ <Compile Include="Main\GameAnswer.cs" />
+ <Compile Include="Main\GameAnswerEventArgs.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
diff --git a/src/Core/Main/Game.cs b/src/Core/Main/Game.cs
index 9283974..b7cfb26 100644
--- a/src/Core/Main/Game.cs
+++ b/src/Core/Main/Game.cs
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ * Copyright (C) 2007-2011 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
@@ -31,23 +31,8 @@ namespace gbrainy.Core.Main
{
abstract public class Game : IDrawable, IDrawRequest, IMouseEvent
{
-
- public const char AnswerSeparator = '|';
- const int MAX_POSSIBLE_ANSWER = 7;
-
- public class AnswerEventArgs : EventArgs
- {
- public AnswerEventArgs (string answer)
- {
- Answer = answer;
- }
-
- public string Answer { get; set; }
- }
-
private bool draw_answer;
private Cairo.Color default_color;
- protected string right_answer;
protected Random random;
private TimeSpan game_time;
private bool tip_used;
@@ -56,15 +41,22 @@ namespace gbrainy.Core.Main
private ISynchronizeInvoke synchronize;
private List <Toolkit.Container> containers;
private int variant;
+ private GameAnswer answer;
public event EventHandler DrawRequest;
public event EventHandler <UpdateUIStateEventArgs> UpdateUIElement;
- public event EventHandler <AnswerEventArgs> AnswerEvent;
+ public event EventHandler <GameAnswerEventArgs> AnswerEvent;
protected Game ()
{
containers = new List <Toolkit.Container> ();
difficulty = GameDifficulty.Medium;
+ answer = new GameAnswer ();
+ }
+
+ public GameAnswer Answer {
+ get {return answer; }
+ set {answer = value; }
}
#region Methods to override in your own games
@@ -101,19 +93,10 @@ namespace gbrainy.Core.Main
get { return GameTypes.LogicPuzzle;}
}
- // How to check the answer
- public virtual GameAnswerCheckAttributes CheckAttributes {
- get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase; }
- }
-
- public virtual string AnswerCheckExpression {
- get { return ".+"; }
- }
-
// Right answer as shown to the user. Usually equals to right_answer, can be different
// when the answer contains multiple options (e.g. 1 | 2 shown as 1 and 2).
public virtual string AnswerValue {
- get { return right_answer; }
+ get { return Answer.Correct; }
}
// Indicates in which difficulty levels the game should be shown
@@ -140,12 +123,12 @@ namespace gbrainy.Core.Main
if (value < 0 || value > Variants)
throw new ArgumentOutOfRangeException (String.Format ("Variant out of range {0}", value));
- variant = value;
+ variant = value;
}
}
// Builds a text answer for the puzzle
- public virtual string Answer {
+ public virtual string AnswerText {
get {
string str;
@@ -153,7 +136,7 @@ namespace gbrainy.Core.Main
if (String.IsNullOrEmpty (Rationale))
return str;
-
+
// Translators: answer + rationale of the answer
return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} {1}"), str, Rationale);
}
@@ -286,7 +269,7 @@ namespace gbrainy.Core.Main
container.SelectedEvent += delegate (object sender, SeletectedEventArgs e)
{
if (AnswerEvent != null)
- AnswerEvent (this, new AnswerEventArgs ((string) e.DataEx));
+ AnswerEvent (this, new GameAnswerEventArgs ((string) e.DataEx));
};
containers.Add (container);
@@ -294,52 +277,6 @@ namespace gbrainy.Core.Main
public virtual void Finish () {}
- protected string GetPossibleAnswersExpression ()
- {
- StringBuilder str = new StringBuilder ();
- str.Append ("[");
- for (int i = 0; i < MAX_POSSIBLE_ANSWER; i++)
- str.Append (GetPossibleAnswer (i));
-
- str.Append ("]");
- return str.ToString ();
- }
-
- static public string GetPossibleAnswer (int answer)
- {
- switch (answer) {
- // Translators Note
- // The following series of answers may need to be adapted
- // in cultures with alphabets different to the Latin one.
- // The idea is to enumerate a sequence of possible answers
- // For languages represented with the Latin alphabet use
- // the same than English
- case 0: // First possible answer for a series (e.g.: Figure A)
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("A");
- case 1: // Second possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("B");
- case 2: // Third possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("C");
- case 3: // Fourth possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("D");
- case 4: // Fifth possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("E");
- case 5: // Sixth possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("F");
- case 6: // Seventh possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("G");
- case 7: // Eighth possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("H");
- default:
- throw new ArgumentOutOfRangeException ("Do not have an option for this answer");
- }
- }
-
- public string GetPossibleFigureAnswer (int answer)
- {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Figure {0}"), GetPossibleAnswer (answer));
- }
-
protected void InitDraw (CairoContextEx gr, int width, int height, bool rtl)
{
gr.Scale (width, height);
@@ -364,98 +301,7 @@ namespace gbrainy.Core.Main
public virtual bool CheckAnswer (string answer)
{
- Regex regex;
- Match match;
- bool ignore_case, ignore_spaces;
-
- if (String.IsNullOrEmpty (answer))
- return false;
-
- 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);
- else
- regex = new Regex (AnswerCheckExpression);
-
- string [] right_answers = right_answer.Split (AnswerSeparator);
-
- for (int i = 0; i < right_answers.Length; i++)
- {
- right_answers [i] = right_answers[i].Trim ();
-
- if (ignore_spaces)
- right_answers [i] = RemoveWhiteSpace (right_answers [i]);
- }
-
- 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 & GameAnswerCheckAttributes.MatchAll) == GameAnswerCheckAttributes.MatchAll ||
- (CheckAttributes & GameAnswerCheckAttributes.MatchAllInOrder) == GameAnswerCheckAttributes.MatchAllInOrder)
- {
- int pos = 0;
- match = regex.Match (answer);
- while (String.IsNullOrEmpty (match.Value) == false)
- {
- if ((CheckAttributes & GameAnswerCheckAttributes.MatchAll) == GameAnswerCheckAttributes.MatchAll)
- {
- for (int i = 0; i < right_answers.Length; i++)
- {
- if (String.Compare (match.Value, right_answers[i], ignore_case) == 0)
- {
- right_answers[i] = null;
- break;
- }
- }
- }
- else //MatchAllInOrder
- {
- if (String.Compare (match.Value, right_answers[pos++], ignore_case) != 0)
- return false;
-
- }
- match = match.NextMatch ();
- }
-
- if ((CheckAttributes & GameAnswerCheckAttributes.MatchAllInOrder) == GameAnswerCheckAttributes.MatchAllInOrder)
- return true;
-
- // Have all the expected answers been matched?
- for (int i = 0; i < right_answers.Length; i++)
- {
- if (right_answers[i] != null)
- return false;
- }
-
- return true;
- }
- else // Any string from the list of possible answers (answer1 | answer2) present in the answer will do it
- {
- foreach (string s in right_answers)
- {
- match = regex.Match (answer);
- if (String.Compare (match.Value, s, ignore_case) == 0)
- return true;
- }
- }
- return false;
- }
-
- static string RemoveWhiteSpace (string source)
- {
- string str = string.Empty;
- for (int n = 0; n < source.Length; n++)
- {
- if (char.IsWhiteSpace (source [n]) == false)
- str += source [n];
- }
- return str;
+ return Answer.CheckAnswer (answer);
}
public void EnableMouseEvents (bool enable)
diff --git a/src/Core/Main/GameAnswer.cs b/src/Core/Main/GameAnswer.cs
new file mode 100644
index 0000000..1fd9717
--- /dev/null
+++ b/src/Core/Main/GameAnswer.cs
@@ -0,0 +1,196 @@
+/*
+ * Copyright (C) 2007-2011 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 System.ComponentModel;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+using System.Text;
+
+
+using gbrainy.Core.Toolkit;
+using gbrainy.Core.Services;
+
+namespace gbrainy.Core.Main
+{
+ public class GameAnswer
+ {
+ static char separator = '|';
+ const int MAX_POSSIBLE_ANSWER = 7;
+
+ public GameAnswer ()
+ {
+ CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase;
+ CheckExpression = ".+";
+ }
+
+ public char Separator {
+ get { return separator; }
+ }
+
+ public string Correct { get; set; }
+
+ public string CheckExpression { get; set; }
+
+ public GameAnswerCheckAttributes CheckAttributes { get; set; }
+
+ public string GetMultiOptionsExpression ()
+ {
+ StringBuilder str = new StringBuilder ();
+ str.Append ("[");
+ for (int i = 0; i < MAX_POSSIBLE_ANSWER; i++)
+ str.Append (GetMultiOption (i));
+
+ str.Append ("]");
+ return str.ToString ();
+ }
+
+ static public string GetMultiOption (int answer)
+ {
+ switch (answer) {
+ // Translators Note
+ // The following series of answers may need to be adapted
+ // in cultures with alphabets different to the Latin one.
+ // The idea is to enumerate a sequence of possible answers
+ // For languages represented with the Latin alphabet use
+ // the same than English
+ case 0: // First possible answer for a series (e.g.: Figure A)
+ return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("A");
+ case 1: // Second possible answer for a series
+ return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("B");
+ case 2: // Third possible answer for a series
+ return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("C");
+ case 3: // Fourth possible answer for a series
+ return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("D");
+ case 4: // Fifth possible answer for a series
+ return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("E");
+ case 5: // Sixth possible answer for a series
+ return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("F");
+ case 6: // Seventh possible answer for a series
+ return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("G");
+ case 7: // Eighth possible answer for a series
+ return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("H");
+ default:
+ throw new ArgumentOutOfRangeException ("Do not have an option for this answer");
+ }
+ }
+
+ public string GetMultiOptionFigureName (int answer)
+ {
+ return String.Format (ServiceLocator.Instance.GetService <ITranslations> ()
+ .GetString ("Figure {0}"), GetMultiOption (answer));
+ }
+
+ public bool CheckAnswer (string answer)
+ {
+ Regex regex;
+ Match match;
+ bool ignore_case, ignore_spaces;
+
+ if (String.IsNullOrEmpty (answer))
+ return false;
+
+ 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 (CheckExpression, RegexOptions.IgnoreCase);
+ else
+ regex = new Regex (CheckExpression);
+
+ string [] right_answers = Correct.Split (Separator);
+
+ for (int i = 0; i < right_answers.Length; i++)
+ {
+ right_answers [i] = right_answers[i].Trim ();
+
+ if (ignore_spaces)
+ right_answers [i] = RemoveWhiteSpace (right_answers [i]);
+ }
+
+ 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 & GameAnswerCheckAttributes.MatchAll) == GameAnswerCheckAttributes.MatchAll ||
+ (CheckAttributes & GameAnswerCheckAttributes.MatchAllInOrder) == GameAnswerCheckAttributes.MatchAllInOrder)
+ {
+ int pos = 0;
+ match = regex.Match (answer);
+ while (String.IsNullOrEmpty (match.Value) == false)
+ {
+ if ((CheckAttributes & GameAnswerCheckAttributes.MatchAll) == GameAnswerCheckAttributes.MatchAll)
+ {
+ for (int i = 0; i < right_answers.Length; i++)
+ {
+ if (String.Compare (match.Value, right_answers[i], ignore_case) == 0)
+ {
+ right_answers[i] = null;
+ break;
+ }
+ }
+ }
+ else //MatchAllInOrder
+ {
+ if (String.Compare (match.Value, right_answers[pos++], ignore_case) != 0)
+ return false;
+
+ }
+ match = match.NextMatch ();
+ }
+
+ if ((CheckAttributes & GameAnswerCheckAttributes.MatchAllInOrder) == GameAnswerCheckAttributes.MatchAllInOrder)
+ return true;
+
+ // Have all the expected answers been matched?
+ for (int i = 0; i < right_answers.Length; i++)
+ {
+ if (right_answers[i] != null)
+ return false;
+ }
+
+ return true;
+ }
+ else // Any string from the list of possible answers (answer1 | answer2) present in the answer will do it
+ {
+ foreach (string s in right_answers)
+ {
+ match = regex.Match (answer);
+ if (String.Compare (match.Value, s, ignore_case) == 0)
+ return true;
+ }
+ }
+ return false;
+ }
+
+ static string RemoveWhiteSpace (string source)
+ {
+ string str = string.Empty;
+ for (int n = 0; n < source.Length; n++)
+ {
+ if (char.IsWhiteSpace (source [n]) == false)
+ str += source [n];
+ }
+ return str;
+ }
+ }
+}
diff --git a/src/Core/Main/GameAnswerEventArgs.cs b/src/Core/Main/GameAnswerEventArgs.cs
new file mode 100644
index 0000000..a1978e2
--- /dev/null
+++ b/src/Core/Main/GameAnswerEventArgs.cs
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2007-2011 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;
+
+namespace gbrainy.Core.Main
+{
+ public class GameAnswerEventArgs : EventArgs
+ {
+ public GameAnswerEventArgs (string answer)
+ {
+ AnswerText = answer;
+ }
+
+ public string AnswerText { get; set; }
+ }
+}
+
diff --git a/src/Core/Main/PdfExporter.cs b/src/Core/Main/PdfExporter.cs
index 5d0d66f..97f1b88 100644
--- a/src/Core/Main/PdfExporter.cs
+++ b/src/Core/Main/PdfExporter.cs
@@ -162,7 +162,7 @@ namespace gbrainy.Core.Main
cr.UseMarkup = true;
for (int i = 0; i < games.Length; i++)
{
- str = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Game {0}. {1}"), i + 1, games[i].Answer);
+ str = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Game {0}. {1}"), i + 1, games[i].AnswerText);
// Draw Solution
cr.DrawStringWithWrapping (x + margin, y + margin, str, width - margin);
diff --git a/src/Core/Main/Verbal/Analogies.cs b/src/Core/Main/Verbal/Analogies.cs
index d1ca366..124869a 100644
--- a/src/Core/Main/Verbal/Analogies.cs
+++ b/src/Core/Main/Verbal/Analogies.cs
@@ -47,11 +47,11 @@ namespace gbrainy.Core.Main.Verbal
}
}
- public override string Answer {
+ public override string AnswerText {
get {
string str;
if (current == null || current.MultipleAnswers == false)
- return base.Answer;
+ return base.AnswerText;
str = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Possible correct answers are: {0}."), AnswerValue);
@@ -75,12 +75,12 @@ namespace gbrainy.Core.Main.Verbal
public override string AnswerValue {
get {
if (current == null || current.MultipleAnswers == false)
- return right_answer;
+ return Answer.Correct;
string [] items;
string str = string.Empty;
- items = right_answer.Split (AnalogiesFactory.Separator);
+ items = Answer.Correct.Split (AnalogiesFactory.Separator);
for (int i = 0 ; i < items.Length; i++)
{
diff --git a/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs b/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs
index 1514c6d..2711ff8 100644
--- a/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs
+++ b/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs
@@ -55,7 +55,7 @@ namespace gbrainy.Core.Main.Verbal
for (int n = 0; n < current.answers.Length; n++)
{
- str+= GetPossibleAnswer (n);
+ str+= GameAnswer.GetMultiOption (n);
if (n +1 < current.answers.Length) {
// Translators: this the separator used when concatenating possible options for answering verbal analogies
@@ -83,7 +83,7 @@ namespace gbrainy.Core.Main.Verbal
if (current == null || current.answers == null)
return;
- right_answer = GetPossibleAnswer (current.right);
+ Answer.Correct = GameAnswer.GetMultiOption (current.right);
Container container = new Container (DrawAreaX + 0.1, 0.50, 0.5, current.answers.Length * 0.15);
AddWidget (container);
@@ -95,14 +95,14 @@ namespace gbrainy.Core.Main.Verbal
drawable_area.Y = DrawAreaY + 0.2 + i * 0.15;
container.AddChild (drawable_area);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
int n = (int) e.Data;
e.Context.MoveTo (0.05, 0.02);
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GetPossibleAnswer (n), current.answers[n].ToString ()));
+ e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GameAnswer.GetMultiOption (n), current.answers[n].ToString ()));
};
}
}
diff --git a/src/Core/Main/Verbal/AnalogiesPairOfWordsCompare.cs b/src/Core/Main/Verbal/AnalogiesPairOfWordsCompare.cs
index ea6848c..c5d2bb9 100644
--- a/src/Core/Main/Verbal/AnalogiesPairOfWordsCompare.cs
+++ b/src/Core/Main/Verbal/AnalogiesPairOfWordsCompare.cs
@@ -76,7 +76,7 @@ namespace gbrainy.Core.Main.Verbal
sample = string.Empty;
samples = items [0].Trim ();
- right_answer = current.answers [current.right];
+ Answer.Correct = current.answers [current.right];
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs b/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs
index fbfd255..c876e71 100644
--- a/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs
+++ b/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs
@@ -56,7 +56,7 @@ namespace gbrainy.Core.Main.Verbal
for (int n = 0; n < current.answers.Length; n++)
{
- str+= GetPossibleAnswer (n);
+ str+= GameAnswer.GetMultiOption (n);
if (n +1 < current.answers.Length) {
// Translators: this the separator used when concatenating possible options for answering verbal analogies
@@ -89,7 +89,7 @@ namespace gbrainy.Core.Main.Verbal
samples = items [0].Trim ();
- right_answer = GetPossibleAnswer (current.right);
+ Answer.Correct = GameAnswer.GetMultiOption (current.right);
Container container = new Container (DrawAreaX + 0.1, 0.50, 0.5, current.answers.Length * 0.15);
AddWidget (container);
@@ -101,7 +101,7 @@ namespace gbrainy.Core.Main.Verbal
drawable_area.Y = DrawAreaY + 0.25 + i * 0.15;
container.AddChild (drawable_area);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
@@ -109,7 +109,7 @@ namespace gbrainy.Core.Main.Verbal
//e.Context.SetPangoLargeFontSize ();
e.Context.MoveTo (0.05, 0.02);
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GetPossibleAnswer (n), current.answers[n].ToString ()));
+ e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GameAnswer.GetMultiOption (n), current.answers[n].ToString ()));
};
}
}
diff --git a/src/Core/Main/Verbal/AnalogiesQuestionAnswer.cs b/src/Core/Main/Verbal/AnalogiesQuestionAnswer.cs
index 619ab81..0ded272 100644
--- a/src/Core/Main/Verbal/AnalogiesQuestionAnswer.cs
+++ b/src/Core/Main/Verbal/AnalogiesQuestionAnswer.cs
@@ -50,7 +50,7 @@ namespace gbrainy.Core.Main.Verbal
return;
if (current.answers != null)
- right_answer = current.answers [current.right];
+ Answer.Correct = current.answers [current.right];
}
}
}
diff --git a/src/Core/Main/Xml/GameXml.cs b/src/Core/Main/Xml/GameXml.cs
index f2fce4f..001dbda 100644
--- a/src/Core/Main/Xml/GameXml.cs
+++ b/src/Core/Main/Xml/GameXml.cs
@@ -55,37 +55,6 @@ namespace gbrainy.Core.Main.Xml
string question, answer, rationale, answer_value;
List <OptionDrawingObject> options;
- 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 {
@@ -104,7 +73,7 @@ namespace gbrainy.Core.Main.Xml
}
public override GameTypes Type {
- get { return game.Type;}
+ get { return game.Type; }
}
public override string Name {
@@ -131,6 +100,36 @@ namespace gbrainy.Core.Main.Xml
}
}
+ void SetCheckExpression ()
+ {
+ 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;
+
+ Answer.CheckExpression = expression;
+ }
+
+ void SetCheckAttributes ()
+ {
+ 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;
+
+ Answer.CheckAttributes = attrib;
+ }
+
protected override void Initialize ()
{
string variables;
@@ -178,10 +177,10 @@ namespace gbrainy.Core.Main.Xml
else
question = CatalogGetString (game.Question);
- if (variants && game.Variants[current.Variant].Answer != null)
- answer = CatalogGetString (game.Variants[current.Variant].Answer);
+ if (variants && game.Variants[current.Variant].AnswerText != null)
+ answer = CatalogGetString (game.Variants[current.Variant].AnswerText);
else
- answer = CatalogGetString (game.Answer);
+ answer = CatalogGetString (game.AnswerText);
if (variants && game.Variants[current.Variant].Rationale != null)
rationale = CatalogGetString (game.Variants[current.Variant].Rationale);
@@ -209,15 +208,15 @@ namespace gbrainy.Core.Main.Xml
{
if (option.Correct == true)
{
- right_answer = option.Answer;
+ Answer.Correct = option.AnswerText;
break;
}
}
for (int i = 0; i < options.Count - 1; i++)
- answers += String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}, "), GetPossibleAnswer (i));
+ answers += String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}, "), GameAnswer.GetMultiOption (i));
- answers += String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}."), GetPossibleAnswer (options.Count - 1));
+ answers += String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}."), GameAnswer.GetMultiOption (options.Count - 1));
// Translators {0}: list of options (A, B, C)
answers = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Answer {0}"), answers);
@@ -225,8 +224,11 @@ namespace gbrainy.Core.Main.Xml
}
else
{
- right_answer = answer;
+ Answer.Correct = answer;
}
+
+ SetCheckExpression ();
+ SetCheckAttributes ();
}
void CreateDrawingObjects (GameXmlDefinitionVariant game)
@@ -311,7 +313,7 @@ namespace gbrainy.Core.Main.Xml
option.CopyRandomizedProperties (originals [random_indices [index]]);
// For randomized options the answer is always the option letter
- option.Answer = GetPossibleAnswer (index);
+ option.AnswerText = GameAnswer.GetMultiOption (index);
index++;
}
}
@@ -338,7 +340,7 @@ namespace gbrainy.Core.Main.Xml
container.AddChild (drawable_area);
drawable_area.Data = idx;
- drawable_area.DataEx = GetPossibleAnswer (idx);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (idx);
options.Add (option);
idx++;
@@ -383,6 +385,9 @@ namespace gbrainy.Core.Main.Xml
if (game.Variants.Count > 0)
CreateDrawingObjects (game.Variants[current.Variant]); // Draw variant specific objects
+
+ SetCheckExpression ();
+ SetCheckAttributes ();
}
}
@@ -469,7 +474,7 @@ namespace gbrainy.Core.Main.Xml
{
string answer;
- answer = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) "), GetPossibleAnswer (option));
+ answer = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) "), GameAnswer.GetMultiOption (option));
return str.Replace (option_prefix, answer);
}
diff --git a/src/Core/Main/Xml/GameXmlDefinitionVariant.cs b/src/Core/Main/Xml/GameXmlDefinitionVariant.cs
index 8065226..259869e 100644
--- a/src/Core/Main/Xml/GameXmlDefinitionVariant.cs
+++ b/src/Core/Main/Xml/GameXmlDefinitionVariant.cs
@@ -28,7 +28,7 @@ namespace gbrainy.Core.Main.Xml
public LocalizableString Question { get; set; }
public string Tip { get; set; }
public LocalizableString Rationale { get; set; }
- public string Answer { get; set; }
+ public string AnswerText { get; set; }
public string Variables { get; set; }
public GameAnswerCheckAttributes CheckAttributes { get; set; }
public string AnswerCheckExpression { get; set; }
@@ -60,9 +60,9 @@ namespace gbrainy.Core.Main.Xml
str.AppendLine ("Question: " + Question);
str.AppendLine ("Tip: " + Tip);
str.AppendLine ("Rationale: " + Rationale);
- str.AppendLine ("Answer: " + Answer);
+ str.AppendLine ("Answer: " + AnswerText);
str.AppendLine ("CheckAttributes: " + CheckAttributes);
- str.AppendLine ("AnswerCheckExpression: " + AnswerCheckExpression);
+ str.AppendLine ("Answer.CheckExpression: " + AnswerCheckExpression);
return str.ToString ();
}
diff --git a/src/Core/Main/Xml/GameXmlFactory.cs b/src/Core/Main/Xml/GameXmlFactory.cs
index 5ace3ad..6cb502a 100644
--- a/src/Core/Main/Xml/GameXmlFactory.cs
+++ b/src/Core/Main/Xml/GameXmlFactory.cs
@@ -271,9 +271,9 @@ namespace gbrainy.Core.Main.Xml
break;
if (processing_variant)
- game.Variants[variant].Answer = reader.ReadElementString ();
+ game.Variants[variant].AnswerText = reader.ReadElementString ();
else
- game.Answer = reader.ReadElementString ();
+ game.AnswerText = reader.ReadElementString ();
break;
case "_answer_show":
@@ -340,7 +340,7 @@ namespace gbrainy.Core.Main.Xml
option = new OptionDrawingObject ();
break;
case XmlNodeType.EndElement:
- if (String.IsNullOrEmpty (option.Answer) && option.RandomizedOrder == false)
+ if (String.IsNullOrEmpty (option.AnswerText) && option.RandomizedOrder == false)
throw new InvalidOperationException ("If the option is not randomized, you need to define an answer");
option = null;
@@ -357,10 +357,10 @@ namespace gbrainy.Core.Main.Xml
else
game.AddDrawingObject (option);
- option.Answer = reader.GetAttribute ("answer");
+ option.AnswerText = reader.GetAttribute ("answer");
- if (String.IsNullOrEmpty (option.Answer))
- option.Answer = reader.GetAttribute ("_answer");
+ if (String.IsNullOrEmpty (option.AnswerText))
+ option.AnswerText = reader.GetAttribute ("_answer");
str = reader.GetAttribute ("x");
if (String.IsNullOrEmpty (str) == false)
diff --git a/src/Core/Main/Xml/OptionDrawingObject.cs b/src/Core/Main/Xml/OptionDrawingObject.cs
index 2f932e2..b7c9838 100644
--- a/src/Core/Main/Xml/OptionDrawingObject.cs
+++ b/src/Core/Main/Xml/OptionDrawingObject.cs
@@ -28,7 +28,7 @@ namespace gbrainy.Core.Main.Xml
public double Y { get; set; }
public double Width { get; set; }
public double Height { get; set; }
- public string Answer { get; set; }
+ public string AnswerText { get; set; }
public bool Correct { get; set; }
public bool RandomizedOrder { get; set; }
@@ -53,7 +53,7 @@ namespace gbrainy.Core.Main.Xml
public void CopyRandomizedProperties (OptionDrawingObject obj)
{
- Answer = obj.Answer;
+ AnswerText = obj.AnswerText;
Correct = obj.Correct;
drawing_objects = obj.drawing_objects;
}
@@ -67,7 +67,7 @@ namespace gbrainy.Core.Main.Xml
option.Y = Y;
option.Width = Width;
option.Height = Height;
- option.Answer = Answer;
+ option.AnswerText = AnswerText;
option.Correct = Correct;
option.RandomizedOrder = RandomizedOrder;
diff --git a/src/Core/Makefile.am b/src/Core/Makefile.am
index 62979ba..67e19aa 100644
--- a/src/Core/Makefile.am
+++ b/src/Core/Makefile.am
@@ -12,7 +12,9 @@ CSDISTFILES = \
$(srcdir)/Main/ColorPalette.cs \
$(srcdir)/Main/IMouseEvent.cs \
$(srcdir)/Main/Game.cs \
+ $(srcdir)/Main/GameAnswer.cs \
$(srcdir)/Main/GameAnswerCheckAttributes.cs \
+ $(srcdir)/Main/GameAnswerEventArgs.cs \
$(srcdir)/Main/GameDifficulty.cs \
$(srcdir)/Main/GameManager.cs \
$(srcdir)/Main/GameSession.cs \
diff --git a/src/Games/Calculation/CalculationArithmetical.cs b/src/Games/Calculation/CalculationArithmetical.cs
index 16f0c1d..056da69 100644
--- a/src/Games/Calculation/CalculationArithmetical.cs
+++ b/src/Games/Calculation/CalculationArithmetical.cs
@@ -97,7 +97,7 @@ namespace gbrainy.Games.Calculation
break;
}
}
- right_answer = result.ToString ();
+ Answer.Correct = result.ToString ();
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
@@ -137,7 +137,7 @@ namespace gbrainy.Games.Calculation
gr.Stroke ();
if (DrawAnswer) {
- gr.DrawTextAlignedRight (aligned_pos, operand_y + 0.03, right_answer);
+ gr.DrawTextAlignedRight (aligned_pos, operand_y + 0.03, Answer.Correct);
}
}
diff --git a/src/Games/Calculation/CalculationAverage.cs b/src/Games/Calculation/CalculationAverage.cs
index cd27159..0d08a43 100644
--- a/src/Games/Calculation/CalculationAverage.cs
+++ b/src/Games/Calculation/CalculationAverage.cs
@@ -53,7 +53,7 @@ namespace gbrainy.Games.Calculation
return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Given the numbers: {0}. Which of the following numbers is the nearest to the average? Answer {1}, {2}, {3} or {4}."), nums,
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3));}
}
public override string Tip {
@@ -146,7 +146,7 @@ namespace gbrainy.Games.Calculation
}
}
- right_answer += GetPossibleAnswer (which);
+ Answer.Correct += GameAnswer.GetMultiOption (which);
// Options
double x = DrawAreaX + 0.25, y = DrawAreaY + 0.16;
@@ -160,7 +160,7 @@ namespace gbrainy.Games.Calculation
drawable_area.Y = y + i * 0.15;
container.AddChild (drawable_area);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
@@ -169,7 +169,7 @@ namespace gbrainy.Games.Calculation
e.Context.SetPangoLargeFontSize ();
e.Context.MoveTo (0.02, 0.02);
- e.Context.ShowPangoText (String.Format ("{0}) {1:##0.###}", GetPossibleAnswer (n) , options [indx]));
+ e.Context.ShowPangoText (String.Format ("{0}) {1:##0.###}", GameAnswer.GetMultiOption (n) , options [indx]));
};
}
}
diff --git a/src/Games/Calculation/CalculationCloserFraction.cs b/src/Games/Calculation/CalculationCloserFraction.cs
index 98c38e8..a837bd6 100644
--- a/src/Games/Calculation/CalculationCloserFraction.cs
+++ b/src/Games/Calculation/CalculationCloserFraction.cs
@@ -44,7 +44,7 @@ namespace gbrainy.Games.Calculation
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of the following numbers is closer to {0:##0.###}? Answer {1}, {2}, {3} or {4}."), question_num,
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3));}
}
public override string Rationale {
@@ -135,7 +135,7 @@ namespace gbrainy.Games.Calculation
which = random.Next (options_cnt);
ans_idx = random_indices[which];
question_num = options[ans_idx * 2] / options[(ans_idx * 2) + 1];
- right_answer += GetPossibleAnswer (which);
+ Answer.Correct += GameAnswer.GetMultiOption (which);
// Options
double x = DrawAreaX + 0.25, y = DrawAreaY + 0.16;
@@ -149,7 +149,7 @@ namespace gbrainy.Games.Calculation
drawable_area.Y = y + i * 0.15;
container.AddChild (drawable_area);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
@@ -158,7 +158,7 @@ namespace gbrainy.Games.Calculation
e.Context.SetPangoLargeFontSize ();
e.Context.MoveTo (0.02, 0.02);
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GetPossibleAnswer (n) ,
+ e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GameAnswer.GetMultiOption (n) ,
options [indx * 2] + " / " + options [(indx * 2) +1]));
};
}
diff --git a/src/Games/Calculation/CalculationFractions.cs b/src/Games/Calculation/CalculationFractions.cs
index 4b06f59..c3ebc37 100644
--- a/src/Games/Calculation/CalculationFractions.cs
+++ b/src/Games/Calculation/CalculationFractions.cs
@@ -129,7 +129,7 @@ namespace gbrainy.Games.Calculation
}
}
- right_answer = String.Format (format_string, rslt);
+ Answer.Correct = String.Format (format_string, rslt);
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
@@ -209,7 +209,7 @@ namespace gbrainy.Games.Calculation
catch (FormatException) {
return false;
}
- return right_answer.Equals (String.Format (format_string, rslt));
+ return Answer.Correct.Equals (String.Format (format_string, rslt));
}
}
}
diff --git a/src/Games/Calculation/CalculationGreatestDivisor.cs b/src/Games/Calculation/CalculationGreatestDivisor.cs
index df02913..dcc0bf1 100644
--- a/src/Games/Calculation/CalculationGreatestDivisor.cs
+++ b/src/Games/Calculation/CalculationGreatestDivisor.cs
@@ -44,7 +44,7 @@ namespace gbrainy.Games.Calculation
public override string Question {
get { return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString (
"Which of the possible divisors is the greatest that divides all numbers? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3));
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3));
}
}
@@ -129,7 +129,7 @@ namespace gbrainy.Games.Calculation
}
}
- right_answer = answer.ToString ();
+ Answer.Correct = answer.ToString ();
// Drawing objects
Container container = new Container (DrawAreaX + 0.2, DrawAreaY + 0.25, 0.4, answers.Length * 0.15);
@@ -142,14 +142,14 @@ namespace gbrainy.Games.Calculation
drawable_area.Y = DrawAreaY + 0.27 + i * 0.15;
container.AddChild (drawable_area);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
int d = (int) e.Data;
e.Context.SetPangoLargeFontSize ();
e.Context.MoveTo (0.07, 0.02);
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GetPossibleAnswer (d),
+ e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GameAnswer.GetMultiOption (d),
answers[d].ToString ()));
};
}
@@ -262,7 +262,7 @@ namespace gbrainy.Games.Calculation
if (base.CheckAnswer (answer) == true)
return true;
- if (String.Compare (answer, GetPossibleAnswer (answer_idx), true) == 0)
+ if (String.Compare (answer, GameAnswer.GetMultiOption (answer_idx), true) == 0)
return true;
return false;
diff --git a/src/Games/Calculation/CalculationOperator.cs b/src/Games/Calculation/CalculationOperator.cs
index cb89ce5..91b436a 100644
--- a/src/Games/Calculation/CalculationOperator.cs
+++ b/src/Games/Calculation/CalculationOperator.cs
@@ -47,14 +47,6 @@ namespace gbrainy.Games.Calculation
get {return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which operators make {0}, {1}, and {2} equal {3}? Answer using '+-/*'."), number_a, number_b, number_c, total);}
}
- public override string AnswerCheckExpression {
- get { return "[+*-/]"; }
- }
-
- public override GameAnswerCheckAttributes CheckAttributes {
- get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll; }
- }
-
public override string AnswerValue {
get { return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} and {1}"), oper1, oper2); }
}
@@ -116,7 +108,9 @@ namespace gbrainy.Games.Calculation
break;
}
- right_answer = String.Format ("{0} | {1}", oper1, oper2);
+ Answer.Correct = String.Format ("{0} | {1}", oper1, oper2);
+ Answer.CheckExpression = "[+*-/]";
+ Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Calculation/CalculationPrimes.cs b/src/Games/Calculation/CalculationPrimes.cs
index 8d178ee..800f953 100644
--- a/src/Games/Calculation/CalculationPrimes.cs
+++ b/src/Games/Calculation/CalculationPrimes.cs
@@ -75,7 +75,7 @@ namespace gbrainy.Games.Calculation
public override string Question {
get { return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of the following numbers is a prime? A prime number is a positive integer that has exactly two different positive divisors, 1 and itself. Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3));}
}
public override string Tip {
@@ -114,7 +114,7 @@ namespace gbrainy.Games.Calculation
answer_idx = random.Next (numbers.Length);
answer = primes [random.Next (max_primeidx + 1)];
numbers [answer_idx] = answer;
- right_answer = answer.ToString ();
+ Answer.Correct = answer.ToString ();
// Drawing objects
double x = DrawAreaX + 0.25, y = DrawAreaY + 0.16;
@@ -128,7 +128,7 @@ namespace gbrainy.Games.Calculation
drawable_area.Y = y + i * 0.15;
container.AddChild (drawable_area);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
@@ -136,7 +136,7 @@ namespace gbrainy.Games.Calculation
e.Context.SetPangoLargeFontSize ();
e.Context.MoveTo (0.02, 0.02);
- e.Context.ShowPangoText (String.Format ("{0}) {1:##0.###}", GetPossibleAnswer (n) , numbers [n]));
+ e.Context.ShowPangoText (String.Format ("{0}) {1:##0.###}", GameAnswer.GetMultiOption (n) , numbers [n]));
};
}
}
@@ -175,7 +175,7 @@ namespace gbrainy.Games.Calculation
if (base.CheckAnswer (answer) == true)
return true;
- if (String.Compare (answer, GetPossibleAnswer (answer_idx), true) == 0)
+ if (String.Compare (answer, GameAnswer.GetMultiOption (answer_idx), true) == 0)
return true;
return false;
diff --git a/src/Games/Calculation/CalculationProportions.cs b/src/Games/Calculation/CalculationProportions.cs
index 99d6523..f84220e 100644
--- a/src/Games/Calculation/CalculationProportions.cs
+++ b/src/Games/Calculation/CalculationProportions.cs
@@ -45,7 +45,7 @@ namespace gbrainy.Games.Calculation
get {
return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What is {0}% of {1}/{2}? Answer {3}, {4}, {5} or {6}."),
- percentage, num, den, GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3));}
+ percentage, num, den, GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3));}
}
protected override void Initialize ()
@@ -92,7 +92,7 @@ namespace gbrainy.Games.Calculation
}
}
- right_answer += GetPossibleAnswer (which);
+ Answer.Correct += GameAnswer.GetMultiOption (which);
// Options
double x = DrawAreaX + 0.25, y = DrawAreaY + 0.16;
@@ -106,7 +106,7 @@ namespace gbrainy.Games.Calculation
drawable_area.Y = y + i * 0.15;
container.AddChild (drawable_area);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
@@ -115,7 +115,7 @@ namespace gbrainy.Games.Calculation
e.Context.SetPangoLargeFontSize ();
e.Context.MoveTo (0.02, 0.02);
- e.Context.ShowPangoText (String.Format ("{0}) {1:##0.##}", GetPossibleAnswer (n), options [indx]));
+ e.Context.ShowPangoText (String.Format ("{0}) {1:##0.##}", GameAnswer.GetMultiOption (n), options [indx]));
};
}
}
diff --git a/src/Games/Calculation/CalculationRatio.cs b/src/Games/Calculation/CalculationRatio.cs
index 4a02abe..ce74a24 100644
--- a/src/Games/Calculation/CalculationRatio.cs
+++ b/src/Games/Calculation/CalculationRatio.cs
@@ -55,14 +55,6 @@ namespace gbrainy.Games.Calculation
get { return ServiceLocator.Instance.GetService <ITranslations> ().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 GameAnswerCheckAttributes CheckAttributes {
- get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll; }
- }
-
- public override string AnswerCheckExpression {
- get { return "[0-9]+"; }
- }
-
public override string AnswerValue {
get { return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} and {1}"), number_a, number_b); }
}
@@ -93,7 +85,9 @@ namespace gbrainy.Games.Calculation
ratio_b = 3 + random.Next (random_max);
number_b = number_a / ratio_a * ratio_b;
- right_answer = String.Format ("{0} | {1}", number_a, number_b);
+ Answer.Correct = String.Format ("{0} | {1}", number_a, number_b);
+ Answer.CheckExpression = "[0-9]+";
+ Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Calculation/CalculationTwoNumbers.cs b/src/Games/Calculation/CalculationTwoNumbers.cs
index 8851110..ec16230 100644
--- a/src/Games/Calculation/CalculationTwoNumbers.cs
+++ b/src/Games/Calculation/CalculationTwoNumbers.cs
@@ -29,7 +29,6 @@ namespace gbrainy.Games.Calculation
int number_a, number_b;
int op1, op2, max_operand;
SubGameTypes type;
- GameAnswerCheckAttributes attributes;
enum SubGameTypes
{
@@ -59,21 +58,13 @@ namespace gbrainy.Games.Calculation
}
}
- public override GameAnswerCheckAttributes CheckAttributes {
- get { return attributes; }
- }
-
- public override string AnswerCheckExpression {
- get { return "[-0-9]+"; }
- }
-
public override string AnswerValue {
get { return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} and {1}"), number_a, number_b); }
}
protected override void Initialize ()
{
- attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
+ Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
type = (SubGameTypes) random.Next ((int) SubGameTypes.Length);
switch (CurrentDifficulty) {
@@ -109,7 +100,8 @@ namespace gbrainy.Games.Calculation
}
op2 = number_a * number_b;
- right_answer = String.Format ("{0} | {1}", number_a, number_b);
+ Answer.Correct = String.Format ("{0} | {1}", number_a, number_b);
+ Answer.CheckExpression = "[-0-9]+";
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
@@ -150,8 +142,8 @@ namespace gbrainy.Games.Calculation
number_a = -num_b;
number_b = -num_a;
- right_answer = String.Format ("{0} | {1}", number_a, number_b);
- attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAllInOrder;
+ Answer.Correct = String.Format ("{0} | {1}", number_a, number_b);
+ Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAllInOrder;
if (base.CheckAnswer (answer) == true)
return true;
diff --git a/src/Games/Logic/Puzzle3DCube.cs b/src/Games/Logic/Puzzle3DCube.cs
index 38e9f5b..459a4a7 100644
--- a/src/Games/Logic/Puzzle3DCube.cs
+++ b/src/Games/Logic/Puzzle3DCube.cs
@@ -59,7 +59,7 @@ namespace gbrainy.Games.Logic
rows = columns = depth = 4 + random.Next (max_random);
ans = rows * columns * depth;
- right_answer += ans.ToString ();
+ Answer.Correct += ans.ToString ();
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleBalance.cs b/src/Games/Logic/PuzzleBalance.cs
index 09ebb3a..12d4aeb 100644
--- a/src/Games/Logic/PuzzleBalance.cs
+++ b/src/Games/Logic/PuzzleBalance.cs
@@ -71,7 +71,7 @@ namespace gbrainy.Games.Logic
for (int i = 0; i < elements; i++)
ans += balances [(group * elements * 6) + (4 * elements) + i];
- right_answer = ans.ToString ();
+ Answer.Correct = ans.ToString ();
}
public void DrawBalance (CairoContextEx gr, double x, double y, int index, bool full)
diff --git a/src/Games/Logic/PuzzleBuildTriangle.cs b/src/Games/Logic/PuzzleBuildTriangle.cs
index 9b0c9c7..79ef6b2 100644
--- a/src/Games/Logic/PuzzleBuildTriangle.cs
+++ b/src/Games/Logic/PuzzleBuildTriangle.cs
@@ -54,21 +54,13 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which three pieces can you use together to build a triangle? Answer using the three figure names, e.g.: {0}{1}{2}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2));}
}
public override string Tip {
get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The resulting triangle is isosceles.");}
}
- public override GameAnswerCheckAttributes CheckAttributes {
- get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll; }
- }
-
- public override string AnswerCheckExpression {
- get { return GetPossibleAnswersExpression ();}
- }
-
public override string AnswerValue {
get { return answers[0] + answers[1] + answers[2]; }
}
@@ -95,18 +87,20 @@ namespace gbrainy.Games.Logic
{
switch ((Figures) random_indices_answers[i]) {
case Figures.TriangleB:
- answers[0] = GetPossibleAnswer (i);
+ answers[0] = GameAnswer.GetMultiOption (i);
break;
case Figures.TriangleC:
- answers[1] = GetPossibleAnswer (i);
+ answers[1] = GameAnswer.GetMultiOption (i);
break;
case Figures.Square:
- answers[2] = GetPossibleAnswer (i);
+ answers[2] = GameAnswer.GetMultiOption (i);
break;
}
}
- right_answer = answers[0] + " | " + answers[1] + " | " + answers[2];
+ Answer.Correct = answers[0] + " | " + answers[1] + " | " + answers[2];
+ Answer.CheckExpression = Answer.GetMultiOptionsExpression ();
+ Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll;
}
private static void DrawFigure (CairoContextEx gr, double x, double y, Figures figure)
@@ -165,7 +159,7 @@ namespace gbrainy.Games.Logic
{
DrawFigure (gr, x, y, (Figures) random_indices_answers[i]);
gr.MoveTo (x, y + 0.13);
- gr.ShowPangoText (GetPossibleFigureAnswer (i));
+ gr.ShowPangoText (Answer.GetMultiOptionFigureName (i));
if (i == (total_figures / 2) - 1) {
y+= 0.30;
diff --git a/src/Games/Logic/PuzzleCirclesSquare.cs b/src/Games/Logic/PuzzleCirclesSquare.cs
index a1168c6..22409c7 100644
--- a/src/Games/Logic/PuzzleCirclesSquare.cs
+++ b/src/Games/Logic/PuzzleCirclesSquare.cs
@@ -46,7 +46,7 @@ namespace gbrainy.Games.Logic
protected override void Initialize ()
{
- right_answer = "68";
+ Answer.Correct = "68";
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleClocks.cs b/src/Games/Logic/PuzzleClocks.cs
index 17da526..29eaa35 100644
--- a/src/Games/Logic/PuzzleClocks.cs
+++ b/src/Games/Logic/PuzzleClocks.cs
@@ -42,7 +42,7 @@ namespace gbrainy.Games.Logic
get {return (String.Format (
// Translators: {0} is replaced by 'Figure X'
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("To what number should the large handle of the '{0}' clock point? Answer using numbers."),
- GetPossibleFigureAnswer (3)));}
+ Answer.GetMultiOptionFigureName (3)));}
}
public override string Rationale {
@@ -85,7 +85,7 @@ namespace gbrainy.Games.Logic
position += addition;
}
- right_answer = handles[7].ToString ();
+ Answer.Correct = handles[7].ToString ();
// First row
HorizontalContainer container = new HorizontalContainer (DrawAreaX, 0.05, 0.8, 0.45);
@@ -99,7 +99,7 @@ namespace gbrainy.Games.Logic
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
DrawClock (e.Context, 0.2, 0.16, handles[0], handles[1], true);
- e.Context.DrawTextCentered (drawable_area.Width / 2, 0.36, GetPossibleFigureAnswer (0));
+ e.Context.DrawTextCentered (drawable_area.Width / 2, 0.36, Answer.GetMultiOptionFigureName (0));
e.Context.Stroke ();
};
@@ -111,7 +111,7 @@ namespace gbrainy.Games.Logic
{
DrawClock (e.Context, 0.2, 0.16, handles[2], handles[3], true);
e.Context.MoveTo (0.03, 0.29);
- e.Context.DrawTextCentered (drawable_area.Width / 2, 0.36, GetPossibleFigureAnswer (1));
+ e.Context.DrawTextCentered (drawable_area.Width / 2, 0.36, Answer.GetMultiOptionFigureName (1));
e.Context.Stroke ();
};
@@ -126,7 +126,7 @@ namespace gbrainy.Games.Logic
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
DrawClock (e.Context, 0.2, 0.16, handles[4], handles[5], true);
- e.Context.DrawTextCentered (drawable_area.Width / 2, 0.36, GetPossibleFigureAnswer (2));
+ e.Context.DrawTextCentered (drawable_area.Width / 2, 0.36, Answer.GetMultiOptionFigureName (2));
e.Context.Stroke ();
};
@@ -138,7 +138,7 @@ namespace gbrainy.Games.Logic
{
DrawClock (e.Context, 0.2, 0.16, handles[6], handles[7], DrawAnswer == true);
e.Context.MoveTo (0.03, 0.29);
- e.Context.DrawTextCentered (drawable_area.Width / 2, 0.36, GetPossibleFigureAnswer (3));
+ e.Context.DrawTextCentered (drawable_area.Width / 2, 0.36, Answer.GetMultiOptionFigureName (3));
e.Context.Stroke ();
};
diff --git a/src/Games/Logic/PuzzleCountCircles.cs b/src/Games/Logic/PuzzleCountCircles.cs
index 71eda1d..78a83ff 100644
--- a/src/Games/Logic/PuzzleCountCircles.cs
+++ b/src/Games/Logic/PuzzleCountCircles.cs
@@ -84,7 +84,7 @@ namespace gbrainy.Games.Logic
circles[i] = new ItemCircle (x, y, rad);
}
- right_answer = n_circles.ToString ();
+ Answer.Correct = n_circles.ToString ();
}
diff --git a/src/Games/Logic/PuzzleCountSeries.cs b/src/Games/Logic/PuzzleCountSeries.cs
index 79e3da7..55eaadb 100644
--- a/src/Games/Logic/PuzzleCountSeries.cs
+++ b/src/Games/Logic/PuzzleCountSeries.cs
@@ -60,19 +60,19 @@ namespace gbrainy.Games.Logic
{
case GameType.HowManyNines:
question = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many numbers '9' are required to represent the numbers between 10 to 100?");
- right_answer = "19";
+ Answer.Correct = "19";
numbers = new short [] {19, 29, 39, 49, 59, 69, 79, 89, 90, 91, 92 , 93, 94, 95, 96, 97, 98, 99};
break;
case GameType.HowManyBiggerDigits:
question = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many two digit numbers occur where the first digit is larger than the second (e.g.: 20 and 21)?");
- right_answer = "45";
+ Answer.Correct = "45";
numbers = new short [] {10, 20, 21, 30, 31, 32, 40, 41, 42, 43, 50, 51, 52, 53, 54, 60, 61, 62, 63, 64, 65, 70, 71, 72, 73, 74, 75, 76, 80, 81, 82, 83, 84, 85, 86, 87, 90, 91, 92, 93, 94, 95, 96, 97, 98};
break;
case GameType.HowManySmallerDigits:
question = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many two digit numbers occur where the first digit is smaller than the second (e.g.: 12 and 13)?");
- right_answer = "36";
+ Answer.Correct = "36";
numbers = new short [] {12, 13, 14, 15, 16, 17, 18, 19, 23, 24, 25, 26, 27, 28, 29, 34, 35, 36, 37, 38, 39, 45, 46, 47, 48, 49, 56, 57, 58, 59, 67, 68, 69, 78, 79, 89};
break;
default:
diff --git a/src/Games/Logic/PuzzleCounting.cs b/src/Games/Logic/PuzzleCounting.cs
index 0a14e1b..05e4bf8 100644
--- a/src/Games/Logic/PuzzleCounting.cs
+++ b/src/Games/Logic/PuzzleCounting.cs
@@ -101,7 +101,7 @@ namespace gbrainy.Games.Logic
throw new Exception ("Unexpected value");
}
- right_answer = (ans).ToString ();
+ Answer.Correct = (ans).ToString ();
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleCoverPercentage.cs b/src/Games/Logic/PuzzleCoverPercentage.cs
index 2c52ead..d545af9 100644
--- a/src/Games/Logic/PuzzleCoverPercentage.cs
+++ b/src/Games/Logic/PuzzleCoverPercentage.cs
@@ -39,10 +39,6 @@ namespace gbrainy.Games.Logic
get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What percentage of the figure is colored?");}
}
- public override string AnswerCheckExpression {
- get { return "[0-9]+";}
- }
-
protected override void Initialize ()
{
int total = 0;
@@ -74,7 +70,8 @@ namespace gbrainy.Games.Logic
partial_zones = random.Next (2) + 1;
total += partial_zones * 5;
- right_answer = total.ToString ();
+ Answer.Correct = total.ToString ();
+ Answer.CheckExpression = "[0-9]+";
}
private static void Fill (CairoContextEx gr, double x, double y, double w, double h)
diff --git a/src/Games/Logic/PuzzleCube.cs b/src/Games/Logic/PuzzleCube.cs
index 0490f60..5de1999 100755
--- a/src/Games/Logic/PuzzleCube.cs
+++ b/src/Games/Logic/PuzzleCube.cs
@@ -53,7 +53,7 @@ namespace gbrainy.Games.Logic
{
int pair = random.Next (pairs);
question = (char) (48 + question_answer[pair * 2]);
- right_answer += (char) (48 + question_answer[(pair * 2) + 1]);
+ Answer.Correct += (char) (48 + question_answer[(pair * 2) + 1]);
Container container;
DrawableArea drawable_area;
diff --git a/src/Games/Logic/PuzzleDice.cs b/src/Games/Logic/PuzzleDice.cs
index 635bec0..9460817 100644
--- a/src/Games/Logic/PuzzleDice.cs
+++ b/src/Games/Logic/PuzzleDice.cs
@@ -79,7 +79,7 @@ namespace gbrainy.Games.Logic
protected override void Initialize ()
{
problem = random.Next (problems.Length);
- right_answer = problems[problem].answer;
+ Answer.Correct = problems[problem].answer;
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleDivideCircle.cs b/src/Games/Logic/PuzzleDivideCircle.cs
index a9038a2..c7f57b4 100644
--- a/src/Games/Logic/PuzzleDivideCircle.cs
+++ b/src/Games/Logic/PuzzleDivideCircle.cs
@@ -58,10 +58,10 @@ namespace gbrainy.Games.Logic
switch (dots) {
case 5:
- right_answer = "16";
+ Answer.Correct = "16";
break;
case 6:
- right_answer = "30";
+ Answer.Correct = "30";
break;
}
}
diff --git a/src/Games/Logic/PuzzleEquation.cs b/src/Games/Logic/PuzzleEquation.cs
index ce230ff..6e676e3 100644
--- a/src/Games/Logic/PuzzleEquation.cs
+++ b/src/Games/Logic/PuzzleEquation.cs
@@ -62,7 +62,7 @@ namespace gbrainy.Games.Logic
}
formula = String.Format ("{0} * {1} + {2} * {3} - {4} = ?", num_a, num_b, num_c, num_d, num_e);
- right_answer = (order).ToString ();
+ Answer.Correct = (order).ToString ();
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleExtraCircle.cs b/src/Games/Logic/PuzzleExtraCircle.cs
index 44dcf5e..78adcc4 100644
--- a/src/Games/Logic/PuzzleExtraCircle.cs
+++ b/src/Games/Logic/PuzzleExtraCircle.cs
@@ -60,7 +60,7 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which circle does not belong to the group? It is not a sequence of elements. Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3));}
}
public override string Tip {
@@ -99,7 +99,7 @@ namespace gbrainy.Games.Logic
start_indices[i] = (random_indices[i]);
ans_pos = random.Next (circles);
- right_answer = GetPossibleAnswer (ans_pos);
+ Answer.Correct = GameAnswer.GetMultiOption (ans_pos);
const double text_offset = 0.04;
const double witdh_used = 0.9; // Total width used for drawing all the figures
@@ -127,7 +127,7 @@ namespace gbrainy.Games.Logic
drawable_area = new DrawableArea (box_size, box_size);
drawable_area.SelectedArea = new Rectangle ((box_size - box_size) / 2, 0, box_size, box_size);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
@@ -139,7 +139,7 @@ namespace gbrainy.Games.Logic
DrawCircle (e.Context, x1, y1, circle.Colors, start_indices [idx]);
e.Context.DrawTextCentered (e.Width / 2, box_size + text_offset,
- GetPossibleFigureAnswer (idx));
+ Answer.GetMultiOptionFigureName (idx));
e.Context.Stroke ();
};
container.AddChild (drawable_area);
diff --git a/src/Games/Logic/PuzzleFigureLetter.cs b/src/Games/Logic/PuzzleFigureLetter.cs
index 47d435b..ea371b3 100644
--- a/src/Games/Logic/PuzzleFigureLetter.cs
+++ b/src/Games/Logic/PuzzleFigureLetter.cs
@@ -54,14 +54,6 @@ namespace gbrainy.Games.Logic
}
}
- public override GameAnswerCheckAttributes CheckAttributes {
- get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll; }
- }
-
- public override string AnswerCheckExpression {
- get { return GetPossibleAnswersExpression ();}
- }
-
public override string AnswerValue {
get {
switch (question) {
@@ -83,17 +75,20 @@ namespace gbrainy.Games.Logic
switch (question) {
case QuestionType.TwoSquares:
- right_answer = "A | B | F";
+ Answer.Correct = "A | B | F";
break;
case QuestionType.TwoCercles:
- right_answer = "C | D | F";
+ Answer.Correct = "C | D | F";
break;
case QuestionType.ThreeCercles:
- right_answer = "A | C | E";
+ Answer.Correct = "A | C | E";
break;
default:
throw new InvalidOperationException ();
}
+
+ Answer.CheckExpression = Answer.GetMultiOptionsExpression ();
+ Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll;
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleFigurePattern.cs b/src/Games/Logic/PuzzleFigurePattern.cs
index 438028c..87fe32e 100644
--- a/src/Games/Logic/PuzzleFigurePattern.cs
+++ b/src/Games/Logic/PuzzleFigurePattern.cs
@@ -43,7 +43,7 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What figure should replace the question mark? Answer {0}, {1} or {2}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2));}
}
public override string Tip {
@@ -64,7 +64,7 @@ namespace gbrainy.Games.Logic
for (int i = 0; i < (int) Figures.Last; i++)
{
if (random_indices[i] == (int) Figures.Cross) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
}
@@ -208,7 +208,7 @@ namespace gbrainy.Games.Logic
}
gr.MoveTo (x, y + 0.18);
- gr.ShowPangoText (GetPossibleFigureAnswer (i));
+ gr.ShowPangoText (Answer.GetMultiOptionFigureName (i));
x += figure_size + space_x;
}
diff --git a/src/Games/Logic/PuzzleFigures.cs b/src/Games/Logic/PuzzleFigures.cs
index 4ac9c3a..f08979a 100644
--- a/src/Games/Logic/PuzzleFigures.cs
+++ b/src/Games/Logic/PuzzleFigures.cs
@@ -59,11 +59,11 @@ namespace gbrainy.Games.Logic
StringBuilder sb = new StringBuilder (3);
- sb.Append (GetPossibleAnswer (figures[random_indices [5]]));
- sb.Append (GetPossibleAnswer (figures[6 + random_indices [5]]));
- sb.Append (GetPossibleAnswer (figures[(2 * 6) + random_indices [5]]));
+ sb.Append (GameAnswer.GetMultiOption (figures[random_indices [5]]));
+ sb.Append (GameAnswer.GetMultiOption (figures[6 + random_indices [5]]));
+ sb.Append (GameAnswer.GetMultiOption (figures[(2 * 6) + random_indices [5]]));
- right_answer = sb.ToString ();
+ Answer.Correct = sb.ToString ();
HorizontalContainer container = new HorizontalContainer (DrawAreaX, 0.75, 0.8, 0.1);
AddWidget (container);
@@ -75,7 +75,7 @@ namespace gbrainy.Games.Logic
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
e.Context.MoveTo (0, 0.05);
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} ->"), GetPossibleAnswer (0)));
+ e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} ->"), GameAnswer.GetMultiOption (0)));
e.Context.DrawPentagon (0.1, 0, 0.1);
e.Context.Stroke ();
};
@@ -87,7 +87,7 @@ namespace gbrainy.Games.Logic
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
e.Context.MoveTo (0, 0.05);
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} ->"), GetPossibleAnswer (1)));
+ e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} ->"), GameAnswer.GetMultiOption (1)));
e.Context.Stroke ();
e.Context.Arc (0.15, 0.05, 0.05, 0, 2 * Math.PI);
e.Context.Stroke ();
@@ -100,7 +100,7 @@ namespace gbrainy.Games.Logic
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
e.Context.MoveTo (0, 0.05);
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} ->"), GetPossibleAnswer (2)));
+ e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} ->"), GameAnswer.GetMultiOption (2)));
e.Context.DrawEquilateralTriangle (0.1, 0, 0.1);
};
}
@@ -161,7 +161,7 @@ namespace gbrainy.Games.Logic
y += 0.16;
gr.MoveTo (x, y);
gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("E.g: {0}{1}{2} (pentagon, triangle, circle)"),
- GetPossibleAnswer (0), GetPossibleAnswer (2), GetPossibleAnswer (1)));
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (1)));
}
}
}
diff --git a/src/Games/Logic/PuzzleFourSided.cs b/src/Games/Logic/PuzzleFourSided.cs
index 5a26712..a371a7a 100644
--- a/src/Games/Logic/PuzzleFourSided.cs
+++ b/src/Games/Logic/PuzzleFourSided.cs
@@ -57,9 +57,9 @@ namespace gbrainy.Games.Logic
if (type == 0)
- right_answer = "13";
+ Answer.Correct = "13";
else
- right_answer = "17";
+ Answer.Correct = "17";
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleHandshakes.cs b/src/Games/Logic/PuzzleHandshakes.cs
index 171c7f8..f203f49 100644
--- a/src/Games/Logic/PuzzleHandshakes.cs
+++ b/src/Games/Logic/PuzzleHandshakes.cs
@@ -62,7 +62,7 @@ namespace gbrainy.Games.Logic
for (int i = 1; i < people; i++)
handshakes += i;
- right_answer = people.ToString ();
+ Answer.Correct = people.ToString ();
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleLargerShape.cs b/src/Games/Logic/PuzzleLargerShape.cs
index dce4b8e..514ba7b 100644
--- a/src/Games/Logic/PuzzleLargerShape.cs
+++ b/src/Games/Logic/PuzzleLargerShape.cs
@@ -120,7 +120,7 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which larger shape can you make combining the first two figures? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3));}
}
protected override void Initialize ()
@@ -148,7 +148,7 @@ namespace gbrainy.Games.Logic
for (int i = 0; i < answers; i++)
{
if (random_indices[i] == ranswer) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
}
@@ -187,7 +187,7 @@ namespace gbrainy.Games.Logic
{
drawable_area = new DrawableArea (container.Width / 2, 0.25);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
container.AddChild (drawable_area);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
@@ -195,7 +195,7 @@ namespace gbrainy.Games.Logic
int n = (int) e.Data;
DrawPossibleAnswer (e.Context, 0.12, 0.03, answer, random_indices [n], n);
- e.Context.DrawTextCentered (drawable_area.Width / 2, 0.22, GetPossibleFigureAnswer (n));
+ e.Context.DrawTextCentered (drawable_area.Width / 2, 0.22, Answer.GetMultiOptionFigureName (n));
e.Context.Stroke ();
};
}
@@ -207,7 +207,7 @@ namespace gbrainy.Games.Logic
{
drawable_area = new DrawableArea (container.Width / 2, 0.25);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
container.AddChild (drawable_area);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
@@ -215,7 +215,7 @@ namespace gbrainy.Games.Logic
int n = (int) e.Data;
DrawPossibleAnswer (e.Context, 0.12, 0.03, answer, random_indices [n], n);
- e.Context.DrawTextCentered (drawable_area.Width / 2, 0.22, GetPossibleFigureAnswer (n));
+ e.Context.DrawTextCentered (drawable_area.Width / 2, 0.22, Answer.GetMultiOptionFigureName (n));
e.Context.Stroke ();
};
}
diff --git a/src/Games/Logic/PuzzleLines.cs b/src/Games/Logic/PuzzleLines.cs
index 61b3898..dd3779c 100644
--- a/src/Games/Logic/PuzzleLines.cs
+++ b/src/Games/Logic/PuzzleLines.cs
@@ -70,7 +70,7 @@ namespace gbrainy.Games.Logic
break;
}
- right_answer = (fig1 + fig2).ToString ();
+ Answer.Correct = (fig1 + fig2).ToString ();
}
static private void DrawLine (CairoContextEx gr, double x, double y, double w, double h)
diff --git a/src/Games/Logic/PuzzleMatrixGroups.cs b/src/Games/Logic/PuzzleMatrixGroups.cs
index 5cb7fea..ac75f23 100644
--- a/src/Games/Logic/PuzzleMatrixGroups.cs
+++ b/src/Games/Logic/PuzzleMatrixGroups.cs
@@ -82,7 +82,7 @@ namespace gbrainy.Games.Logic
if (count > 5 && count < 10)
completed = true;
}
- right_answer = numbers[good_pos].ToString ();
+ Answer.Correct = numbers[good_pos].ToString ();
}
private int GetUnique (int max)
diff --git a/src/Games/Logic/PuzzleMatrixNumbers.cs b/src/Games/Logic/PuzzleMatrixNumbers.cs
index 9b10bee..b9abb6b 100644
--- a/src/Games/Logic/PuzzleMatrixNumbers.cs
+++ b/src/Games/Logic/PuzzleMatrixNumbers.cs
@@ -122,7 +122,7 @@ namespace gbrainy.Games.Logic
}
}
- right_answer = numbers[3*coordinateA + 3*coordinateB].ToString ();
+ Answer.Correct = numbers[3*coordinateA + 3*coordinateB].ToString ();
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleMissingPiece.cs b/src/Games/Logic/PuzzleMissingPiece.cs
index 5375bfc..1095249 100644
--- a/src/Games/Logic/PuzzleMissingPiece.cs
+++ b/src/Games/Logic/PuzzleMissingPiece.cs
@@ -38,7 +38,7 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which square completes the figure below? Answer {0}, {1} or {2}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2));}
}
public override string Tip {
@@ -58,7 +58,7 @@ namespace gbrainy.Games.Logic
for (int i = 0; i < random_indices.Count; i++) {
if (random_indices [i] == 0) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
}
@@ -73,7 +73,7 @@ namespace gbrainy.Games.Logic
drawable_area.SelectedArea = new Rectangle (0, 0, sub_figure, sub_figure);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
container.AddChild (drawable_area);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
@@ -82,7 +82,7 @@ namespace gbrainy.Games.Logic
DrawAnswerFigures (e.Context, 0, 0, random_indices [n]);
e.Context.MoveTo (0, 0.2);
- e.Context.ShowPangoText (GetPossibleFigureAnswer (n));
+ e.Context.ShowPangoText (Answer.GetMultiOptionFigureName (n));
};
}
}
diff --git a/src/Games/Logic/PuzzleMissingSlice.cs b/src/Games/Logic/PuzzleMissingSlice.cs
index 8496366..9753cea 100644
--- a/src/Games/Logic/PuzzleMissingSlice.cs
+++ b/src/Games/Logic/PuzzleMissingSlice.cs
@@ -65,7 +65,7 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The slices below have some kind of relation. Which is the missing slice in the circle below? Answer {0}, {1} or {2}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2));}
}
public override string Tip {
@@ -84,7 +84,7 @@ namespace gbrainy.Games.Logic
random_indices = new ArrayListIndicesRandom (slices.Length / items_per_slice);
random_indices.Initialize ();
ans_pos = random.Next (possible_answers);
- right_answer = GetPossibleAnswer (ans_pos);
+ Answer.Correct = GameAnswer.GetMultiOption (ans_pos);
bad_answers = new int [possible_answers * items_per_slice];
for (int i = 0; i < bad_answers.Length; i++) {
@@ -100,7 +100,7 @@ namespace gbrainy.Games.Logic
drawable_area = new DrawableArea (0.8 / 3, 0.3);
drawable_area.SelectedArea = new Rectangle (0, 0, radius, 0.2);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
container.AddChild (drawable_area);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
@@ -122,7 +122,7 @@ namespace gbrainy.Games.Logic
}
e.Context.MoveTo (0.0, 0.25);
- e.Context.ShowPangoText (GetPossibleFigureAnswer (n));
+ e.Context.ShowPangoText (Answer.GetMultiOptionFigureName (n));
e.Context.Stroke ();
};
}
diff --git a/src/Games/Logic/PuzzleMostInCommon.cs b/src/Games/Logic/PuzzleMostInCommon.cs
index e6162f4..66dbfac 100644
--- a/src/Games/Logic/PuzzleMostInCommon.cs
+++ b/src/Games/Logic/PuzzleMostInCommon.cs
@@ -79,7 +79,7 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of the possible answers have the most in common with the four given figures? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3));}
}
public override string Tip {
@@ -115,7 +115,7 @@ namespace gbrainy.Games.Logic
for (int i = 0; i < random_indices_answers.Count; i++) {
if ((int) random_indices_answers [i] == 0) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
}
@@ -184,7 +184,7 @@ namespace gbrainy.Games.Logic
drawable_area = new DrawableArea (figure_size, figure_size + 0.05);
drawable_area.SelectedArea = new Rectangle (0.05, 0.05, 0.15, 0.15);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
@@ -192,7 +192,7 @@ namespace gbrainy.Games.Logic
DrawFigure (e.Context, 0.05, 0.05, (FigureElement []) answers[random_indices_answers[n]]);
e.Context.MoveTo (0.05, 0.22);
- e.Context.ShowPangoText (GetPossibleFigureAnswer (n));
+ e.Context.ShowPangoText (Answer.GetMultiOptionFigureName (n));
};
container.AddChild (drawable_area);
diff --git a/src/Games/Logic/PuzzleMoveFigure.cs b/src/Games/Logic/PuzzleMoveFigure.cs
index 15aa22a..3790a3f 100644
--- a/src/Games/Logic/PuzzleMoveFigure.cs
+++ b/src/Games/Logic/PuzzleMoveFigure.cs
@@ -58,10 +58,10 @@ namespace gbrainy.Games.Logic
switch (type)
{
case 0:
- right_answer = "3";
+ Answer.Correct = "3";
break;
case 1:
- right_answer = "5";
+ Answer.Correct = "5";
break;
}
diff --git a/src/Games/Logic/PuzzleNextFigure.cs b/src/Games/Logic/PuzzleNextFigure.cs
index f5996a1..083a9d6 100644
--- a/src/Games/Logic/PuzzleNextFigure.cs
+++ b/src/Games/Logic/PuzzleNextFigure.cs
@@ -56,7 +56,7 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which is the next logical figure in the sequence? Answer {0}, {1} or {2}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2));}
}
@@ -74,7 +74,7 @@ namespace gbrainy.Games.Logic
for (int i = 0; i < (int) Figures.Last; i++)
{
if (random_indices[i] == (int) Figures.Third) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
}
@@ -89,7 +89,7 @@ namespace gbrainy.Games.Logic
drawable_area = new DrawableArea (space_figures, 0.2);
drawable_area.SelectedArea = new Rectangle (0, 0, figure_size, figure_size);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
container.AddChild (drawable_area);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
@@ -111,7 +111,7 @@ namespace gbrainy.Games.Logic
}
e.Context.MoveTo (0.02, 0.25);
- e.Context.ShowPangoText (GetPossibleFigureAnswer (n));
+ e.Context.ShowPangoText (Answer.GetMultiOptionFigureName (n));
e.Context.Stroke ();
};
}
diff --git a/src/Games/Logic/PuzzleNumericRelation.cs b/src/Games/Logic/PuzzleNumericRelation.cs
index dd11924..f021693 100644
--- a/src/Games/Logic/PuzzleNumericRelation.cs
+++ b/src/Games/Logic/PuzzleNumericRelation.cs
@@ -111,7 +111,7 @@ namespace gbrainy.Games.Logic
validate = Validate (numbers, formula, question);
}
- right_answer = numbers[question].ToString ();
+ Answer.Correct = numbers[question].ToString ();
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleNumericSequence.cs b/src/Games/Logic/PuzzleNumericSequence.cs
index 2000994..2bb32ea 100644
--- a/src/Games/Logic/PuzzleNumericSequence.cs
+++ b/src/Games/Logic/PuzzleNumericSequence.cs
@@ -107,7 +107,7 @@ namespace gbrainy.Games.Logic
}
}
- right_answer = numbers[max_num-1].ToString ();
+ Answer.Correct = numbers[max_num-1].ToString ();
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleOstracism.cs b/src/Games/Logic/PuzzleOstracism.cs
index 205bff6..00b637f 100644
--- a/src/Games/Logic/PuzzleOstracism.cs
+++ b/src/Games/Logic/PuzzleOstracism.cs
@@ -56,7 +56,7 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which element does not belong to the group? It is not related to divisibility of the numbers. Answer {0}, {1}, {2}, {3} or {4}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3), GetPossibleAnswer (4));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3), GameAnswer.GetMultiOption (4));}
}
public override string Tip {
@@ -127,12 +127,12 @@ namespace gbrainy.Games.Logic
random_indices = new ArrayListIndicesRandom (equations.Length);
random_indices.Initialize ();
- right_answer = string.Empty;
+ Answer.Correct = string.Empty;
for (int i = 0; i < random_indices.Count; i++)
{
if (random_indices[i] == wrong_answer) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
}
@@ -147,7 +147,7 @@ namespace gbrainy.Games.Logic
drawable_area.Y = DrawAreaY + 0.2 + i * 0.1;
container.AddChild (drawable_area);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
@@ -156,7 +156,7 @@ namespace gbrainy.Games.Logic
e.Context.SetPangoLargeFontSize ();
e.Context.MoveTo (0.05, 0.02);
// Translators: this "option) answer" for example "a) "21 x 60 = 1260". This should not be changed for most of the languages
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GetPossibleAnswer (n), equations [random_indices[n]]));
+ e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GameAnswer.GetMultiOption (n), equations [random_indices[n]]));
};
}
}
diff --git a/src/Games/Logic/PuzzlePencil.cs b/src/Games/Logic/PuzzlePencil.cs
index 22f3252..cca0389 100644
--- a/src/Games/Logic/PuzzlePencil.cs
+++ b/src/Games/Logic/PuzzlePencil.cs
@@ -41,20 +41,20 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format ( ServiceLocator.Instance.GetService <ITranslations> ().GetString
("Which of the following figures cannot be drawn without crossing any previous lines nor lifting the pencil? Answer {0}, {1}, {2}, {3} or {4}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3), GetPossibleAnswer (4));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3), GameAnswer.GetMultiOption (4));}
}
protected override void Initialize ()
{
random_indices = new ArrayListIndicesRandom (figures);
random_indices.Initialize ();
- right_answer = string.Empty;
+ Answer.Correct = string.Empty;
for (int i = 0; i < random_indices.Count; i++) {
if (random_indices[i] != answer_index)
continue;
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
@@ -86,7 +86,7 @@ namespace gbrainy.Games.Logic
drawable_area = new DrawableArea (box_size, figure_size);
drawable_area.SelectedArea = new Rectangle ((box_size - figure_size) / 2, 0, figure_size, figure_size);
drawable_area.Data = figure;
- drawable_area.DataEx = GetPossibleAnswer (figure);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (figure);
switch (random_indices[figure]) {
case 0:
@@ -94,7 +94,7 @@ namespace gbrainy.Games.Logic
{
DrawTriangle (e.Context, (e.Width - figure_size) / 2, 0);
e.Context.DrawTextCentered (e.Width / 2, figure_size + text_offset,
- GetPossibleFigureAnswer ((int) e.Data));
+ Answer.GetMultiOptionFigureName ((int) e.Data));
};
break;
case 1:
@@ -102,7 +102,7 @@ namespace gbrainy.Games.Logic
{
DrawDiamon (e.Context, (e.Width - figure_size) / 2, 0);
e.Context.DrawTextCentered (e.Width / 2, figure_size + text_offset,
- GetPossibleFigureAnswer ((int) e.Data));
+ Answer.GetMultiOptionFigureName ((int) e.Data));
};
break;
case 2:
@@ -110,7 +110,7 @@ namespace gbrainy.Games.Logic
{
DrawRectangleWithTriangles (e.Context, (e.Width - figure_size) / 2, 0);
e.Context.DrawTextCentered (e.Width / 2, figure_size + text_offset,
- GetPossibleFigureAnswer ((int) e.Data));
+ Answer.GetMultiOptionFigureName ((int) e.Data));
};
break;
case 3:
@@ -118,7 +118,7 @@ namespace gbrainy.Games.Logic
{
DrawThreeTriangles (e.Context, (e.Width - figure_size) / 2, 0);
e.Context.DrawTextCentered (e.Width / 2, figure_size + text_offset,
- GetPossibleFigureAnswer ((int) e.Data));
+ Answer.GetMultiOptionFigureName ((int) e.Data));
};
break;
case answer_index:
@@ -126,7 +126,7 @@ namespace gbrainy.Games.Logic
{
DrawRectangleWithCross (e.Context, (e.Width - figure_size) / 2, 0);
e.Context.DrawTextCentered (e.Width / 2, figure_size + text_offset,
- GetPossibleFigureAnswer ((int) e.Data));
+ Answer.GetMultiOptionFigureName ((int) e.Data));
};
break;
}
diff --git a/src/Games/Logic/PuzzlePeopleTable.cs b/src/Games/Logic/PuzzlePeopleTable.cs
index 1d0b837..e1d7799 100644
--- a/src/Games/Logic/PuzzlePeopleTable.cs
+++ b/src/Games/Logic/PuzzlePeopleTable.cs
@@ -61,17 +61,17 @@ namespace gbrainy.Games.Logic
case 0:
ques1 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("5th");
ques2 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("19th");
- right_answer = "28";
+ Answer.Correct = "28";
break;
case 1:
ques1 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("4th");
ques2 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("12th");
- right_answer = "16";
+ Answer.Correct = "16";
break;
case 2:
ques1 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("9th");
ques2 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("22nd");
- right_answer = "26";
+ Answer.Correct = "26";
break;
}
}
diff --git a/src/Games/Logic/PuzzlePercentage.cs b/src/Games/Logic/PuzzlePercentage.cs
index 1ddda96..e1b3dfd 100644
--- a/src/Games/Logic/PuzzlePercentage.cs
+++ b/src/Games/Logic/PuzzlePercentage.cs
@@ -51,10 +51,6 @@ namespace gbrainy.Games.Logic
}
}
- public override string AnswerCheckExpression {
- get { return "[0-9]+";}
- }
-
protected override void Initialize ()
{
int ans;
@@ -120,7 +116,8 @@ namespace gbrainy.Games.Logic
throw new Exception ("Unexpected value");
}
- right_answer = (ans).ToString ();
+ Answer.Correct = (ans).ToString ();
+ Answer.CheckExpression = "[0-9]+";
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzlePredicateLogic.cs b/src/Games/Logic/PuzzlePredicateLogic.cs
index a83e8bf..7e5d58f 100644
--- a/src/Games/Logic/PuzzlePredicateLogic.cs
+++ b/src/Games/Logic/PuzzlePredicateLogic.cs
@@ -54,7 +54,7 @@ namespace gbrainy.Games.Logic
Predicate [] predicates =
{
new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If all painters are artists and some citizens of Barcelona are artists. Which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3)),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some citizens of Barcelona are painters"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All citizens of Barcelona are painters"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("No citizen of Barcelona is a painter"),
@@ -62,7 +62,7 @@ namespace gbrainy.Games.Logic
3),
new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If no ill artist is happy and some artists are happy. Which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3)),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some artist are not ill"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some painters are not artists"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All artists are happy"),
@@ -70,7 +70,7 @@ namespace gbrainy.Games.Logic
0),
new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("People that travel always buy a map. You are not going to travel. Which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3)),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You do not have any map"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You do not buy a map"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All people have a map"),
@@ -78,7 +78,7 @@ namespace gbrainy.Games.Logic
3),
new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If you whistle if you are happy and you always smile when you whistle, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3)),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You smile if you are happy"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You are only happy if you whistle"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You whistle if you are not happy"),
@@ -86,7 +86,7 @@ namespace gbrainy.Games.Logic
0),
new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If your course is always honest and your course is always the best policy, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3)),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Honesty is sometimes the best policy"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Honesty is always the best policy"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Honesty is not always the best policy"),
@@ -94,7 +94,7 @@ namespace gbrainy.Games.Logic
0),
new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If no old misers are cheerful and some old misers are thin, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3)),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some thin people are not cheerful"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Thin people are not cheerful"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Cheerful people are not thin"),
@@ -102,7 +102,7 @@ namespace gbrainy.Games.Logic
0),
new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If all pigs are fat and nothing that is fed on barley-water is fat, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3)),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All animals fed on barley-water are non pigs"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("No pigs are fed on barley-water"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Pigs are not fed on barley-water"),
@@ -110,7 +110,7 @@ namespace gbrainy.Games.Logic
3),
new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If some pictures are first attempts and no first attempts are really good, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3)),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some bad pictures are not first attempts"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some pictures are not really good"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All bad pictures are first attempts"),
@@ -118,7 +118,7 @@ namespace gbrainy.Games.Logic
1),
new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If you have been out for a walk and you are feeling better, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3)),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("To feel better, you must go out for a walk"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If you go out for a walk, you will feel better"),
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some who go out for a walk feel better"),
@@ -150,7 +150,7 @@ namespace gbrainy.Games.Logic
for (int i = 0; i < answers; i++)
{
if (random_indices[i] == correct_answer) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
}
@@ -165,7 +165,7 @@ namespace gbrainy.Games.Logic
drawable_area.Y = DrawAreaY + 0.15 + i * 0.18;
container.AddChild (drawable_area);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
@@ -173,7 +173,7 @@ namespace gbrainy.Games.Logic
int option = random_indices [data];
e.Context.SetPangoNormalFontSize ();
- e.Context.DrawStringWithWrapping (0.05, 0.02, String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GetPossibleAnswer (data),
+ e.Context.DrawStringWithWrapping (0.05, 0.02, String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), GameAnswer.GetMultiOption (data),
predicates[question].options[option].ToString ()), 0.8 - DrawAreaX);
e.Context.Stroke ();
};
diff --git a/src/Games/Logic/PuzzleQuadrilaterals.cs b/src/Games/Logic/PuzzleQuadrilaterals.cs
index 0ad8a12..3fe5603 100644
--- a/src/Games/Logic/PuzzleQuadrilaterals.cs
+++ b/src/Games/Logic/PuzzleQuadrilaterals.cs
@@ -47,8 +47,8 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of the following figures does not belong to the group? Answer {0}, {1}, {2}, {3}, {4} or {5}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3), GetPossibleAnswer (4),
- GetPossibleAnswer (5));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3), GameAnswer.GetMultiOption (4),
+ GameAnswer.GetMultiOption (5));}
}
public override string Rationale {
@@ -65,7 +65,7 @@ namespace gbrainy.Games.Logic
for (int i = 0; i < (int) Figures.Last; i++)
{
if ((Figures) random_indices[i] == Figures.FigureA) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
}
@@ -140,7 +140,7 @@ namespace gbrainy.Games.Logic
for (int i = 0; i < random_indices.Count; i++) {
DrawFigure (gr, x, y, (Figures) random_indices[i]);
gr.MoveTo (x, y - 0.02 + figure_size * 1.6);
- gr.ShowPangoText (GetPossibleFigureAnswer (i));
+ gr.ShowPangoText (Answer.GetMultiOptionFigureName (i));
if (i == 2) {
x = DrawAreaX;
diff --git a/src/Games/Logic/PuzzleRelatedNumbers.cs b/src/Games/Logic/PuzzleRelatedNumbers.cs
index 6c817f6..8966cc3 100644
--- a/src/Games/Logic/PuzzleRelatedNumbers.cs
+++ b/src/Games/Logic/PuzzleRelatedNumbers.cs
@@ -194,7 +194,7 @@ namespace gbrainy.Games.Logic
lines [5] = CreateNumbers (operation, 2);
lines [6] = CreateNumbers (operation, 1);
- right_answer = (lines [lines.Length - 1].Middle).ToString ();
+ Answer.Correct = (lines [lines.Length - 1].Middle).ToString ();
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleSquareDots.cs b/src/Games/Logic/PuzzleSquareDots.cs
index f718f82..5bcd97c 100644
--- a/src/Games/Logic/PuzzleSquareDots.cs
+++ b/src/Games/Logic/PuzzleSquareDots.cs
@@ -207,7 +207,7 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return (String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which is the next logical figure in the sequence? Answer {0}, {1} or {2}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2)));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2)));}
}
protected override void Initialize ()
@@ -225,7 +225,7 @@ namespace gbrainy.Games.Logic
drawable_area = new DrawableArea (figure_size + space_figures, figure_size + 0.1);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.SelectedArea = new Rectangle (space_figures / 2, space_figures / 2, figure_size, figure_size);
container.AddChild (drawable_area);
@@ -234,13 +234,13 @@ namespace gbrainy.Games.Logic
{
DrawPossibleAnswer (e.Context, space_figures / 2, space_figures / 2, possible_answers [(int)e.Data]);
e.Context.DrawTextCentered (space_figures / 2 + figure_size / 2, space_figures + figure_size + 0.02,
- GetPossibleFigureAnswer ((int)e.Data));
+ Answer.GetMultiOptionFigureName ((int)e.Data));
};
}
for (int i = 0; i < possible_answers.Count; i++) {
if (possible_answers[i] == 0) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
}
diff --git a/src/Games/Logic/PuzzleSquareSheets.cs b/src/Games/Logic/PuzzleSquareSheets.cs
index f7bbbd1..f2f1af6 100644
--- a/src/Games/Logic/PuzzleSquareSheets.cs
+++ b/src/Games/Logic/PuzzleSquareSheets.cs
@@ -45,7 +45,7 @@ namespace gbrainy.Games.Logic
protected override void Initialize ()
{
- right_answer = "4";
+ Answer.Correct = "4";
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleSquares.cs b/src/Games/Logic/PuzzleSquares.cs
index 5943d7c..c8bfe4d 100644
--- a/src/Games/Logic/PuzzleSquares.cs
+++ b/src/Games/Logic/PuzzleSquares.cs
@@ -65,9 +65,9 @@ namespace gbrainy.Games.Logic
if (type == 0) {
rows++;
columns++;
- right_answer = "30";
+ Answer.Correct = "30";
} else {
- right_answer = "14";
+ Answer.Correct = "14";
}
}
diff --git a/src/Games/Logic/PuzzleSquaresAndLetters.cs b/src/Games/Logic/PuzzleSquaresAndLetters.cs
index b19272b..ead304f 100644
--- a/src/Games/Logic/PuzzleSquaresAndLetters.cs
+++ b/src/Games/Logic/PuzzleSquaresAndLetters.cs
@@ -62,7 +62,7 @@ namespace gbrainy.Games.Logic
}
}
- right_answer = ToStr (characters[((figures - 1) * 4) + 3]);
+ Answer.Correct = ToStr (characters[((figures - 1) * 4) + 3]);
characters[((figures - 1) * 4) + 3] = '?';
}
diff --git a/src/Games/Logic/PuzzleTetris.cs b/src/Games/Logic/PuzzleTetris.cs
index b04f1c7..83af9a8 100644
--- a/src/Games/Logic/PuzzleTetris.cs
+++ b/src/Games/Logic/PuzzleTetris.cs
@@ -38,7 +38,7 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What figure completes the set below? Answer {0}, {1} or {2}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2));}
}
public override string Rationale {
@@ -57,7 +57,7 @@ namespace gbrainy.Games.Logic
for (int i = 0; i < random_indices_answers.Count; i++) {
if ((int) random_indices_answers [i] == 0) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
}
@@ -70,7 +70,7 @@ namespace gbrainy.Games.Logic
{
drawable_area = new DrawableArea (0.8 / 3, 0.4);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
container.AddChild (drawable_area);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
@@ -79,7 +79,7 @@ namespace gbrainy.Games.Logic
DrawAnswerFigures (e.Context, 0.05, 0.2, random_indices_answers [n]);
e.Context.MoveTo (0.05, 0.33);
- e.Context.ShowPangoText (GetPossibleFigureAnswer (n));
+ e.Context.ShowPangoText (Answer.GetMultiOptionFigureName (n));
};
}
}
diff --git a/src/Games/Logic/PuzzleTimeNow.cs b/src/Games/Logic/PuzzleTimeNow.cs
index 8a45190..6f9f1f0 100644
--- a/src/Games/Logic/PuzzleTimeNow.cs
+++ b/src/Games/Logic/PuzzleTimeNow.cs
@@ -50,11 +50,7 @@ namespace gbrainy.Games.Logic
return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You have to calculate the hour from which the distance is the same for the given times, and then add the {0} hours to convert it to present time."), after);
}
}
-
- public override GameAnswerCheckAttributes CheckAttributes {
- get { return GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.IgnoreSpaces; }
- }
-
+
protected override void Initialize ()
{
int hour;
@@ -73,7 +69,9 @@ namespace gbrainy.Games.Logic
// Explanation of the date and time format specifications can be found here:
// http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx
// For 12-hour clock format use {0:%h} and for 24-hour clock format use {0:%H}. The date formats {0:h} and {0:H} are invalid.
- right_answer = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0:h tt}"), ans);
+ Answer.Correct = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0:h tt}"), ans);
+
+ Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.IgnoreSpaces;
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleTrains.cs b/src/Games/Logic/PuzzleTrains.cs
index 0022d65..ca1bdf0 100644
--- a/src/Games/Logic/PuzzleTrains.cs
+++ b/src/Games/Logic/PuzzleTrains.cs
@@ -134,7 +134,7 @@ namespace gbrainy.Games.Logic
}
ans = (int) rslt;
- right_answer = (ans).ToString ();
+ Answer.Correct = (ans).ToString ();
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleTriangles.cs b/src/Games/Logic/PuzzleTriangles.cs
index 8f8c4fb..6b943bf 100644
--- a/src/Games/Logic/PuzzleTriangles.cs
+++ b/src/Games/Logic/PuzzleTriangles.cs
@@ -56,9 +56,9 @@ namespace gbrainy.Games.Logic
type = random.Next (2);
if (type == 0)
- right_answer = "16";
+ Answer.Correct = "16";
else
- right_answer = "8";
+ Answer.Correct = "8";
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Logic/PuzzleTrianglesWithNumbers.cs b/src/Games/Logic/PuzzleTrianglesWithNumbers.cs
index 9e473cc..a443940 100644
--- a/src/Games/Logic/PuzzleTrianglesWithNumbers.cs
+++ b/src/Games/Logic/PuzzleTrianglesWithNumbers.cs
@@ -78,15 +78,15 @@ namespace gbrainy.Games.Logic
group = random.Next (3);
switch (group) {
case 0:
- right_answer = "10";
+ Answer.Correct = "10";
answer_number = "210";
break;
case 1:
- right_answer = "160";
+ Answer.Correct = "160";
answer_number = "160";
break;
case 2:
- right_answer = "60";
+ Answer.Correct = "60";
answer_number = "120";
break;
}
diff --git a/src/Games/Memory/MemoryColouredFigures.cs b/src/Games/Memory/MemoryColouredFigures.cs
index e67775f..07a8c78 100644
--- a/src/Games/Memory/MemoryColouredFigures.cs
+++ b/src/Games/Memory/MemoryColouredFigures.cs
@@ -58,7 +58,7 @@ namespace gbrainy.Games.Memory
public override string MemoryQuestion {
get { return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of these figures was previously shown? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3));}
}
protected override void Initialize ()
@@ -94,7 +94,7 @@ namespace gbrainy.Games.Memory
for (int i = 0; i < answers_order.Count; i++) {
if (answers_order[i] == 0) {
- right_answer += GetPossibleAnswer (i);
+ Answer.Correct += GameAnswer.GetMultiOption (i);
break;
}
}
@@ -115,7 +115,7 @@ namespace gbrainy.Games.Memory
container.AddChild (drawable_area);
drawable_area.SelectedArea = new Rectangle (0.05, 0, 0.3, 0.3);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
@@ -124,7 +124,7 @@ namespace gbrainy.Games.Memory
palette.Alpha = alpha;
DrawSquare (e.Context, 0.05, 0, squares_colours, squares * answers_order[n]);
e.Context.MoveTo (0.05, 0 + block_space - 0.02);
- e.Context.ShowPangoText (GetPossibleFigureAnswer (n));
+ e.Context.ShowPangoText (Answer.GetMultiOptionFigureName (n));
e.Context.Stroke ();
};
}
diff --git a/src/Games/Memory/MemoryColouredText.cs b/src/Games/Memory/MemoryColouredText.cs
index 589bcc4..b7d4a7c 100644
--- a/src/Games/Memory/MemoryColouredText.cs
+++ b/src/Games/Memory/MemoryColouredText.cs
@@ -78,7 +78,7 @@ namespace gbrainy.Games.Memory
}
question = random.Next (colors_shown);
- right_answer = palette.Name (color_order [question]);
+ Answer.Correct = palette.Name (color_order [question]);
question_colorname = palette.Name (question);
base.Initialize ();
diff --git a/src/Games/Memory/MemoryCountDots.cs b/src/Games/Memory/MemoryCountDots.cs
index 34595c7..465595d 100644
--- a/src/Games/Memory/MemoryCountDots.cs
+++ b/src/Games/Memory/MemoryCountDots.cs
@@ -81,7 +81,7 @@ namespace gbrainy.Games.Memory
before = dotsPerColor[i];
}
- right_answer = (dotsPerColor[0]+1).ToString ();
+ Answer.Correct = (dotsPerColor[0]+1).ToString ();
base.Initialize ();
}
diff --git a/src/Games/Memory/MemoryFacts.cs b/src/Games/Memory/MemoryFacts.cs
index 68ad7ca..07f7a7c 100644
--- a/src/Games/Memory/MemoryFacts.cs
+++ b/src/Games/Memory/MemoryFacts.cs
@@ -53,10 +53,6 @@ namespace gbrainy.Games.Memory
get { return question;}
}
- public override string AnswerCheckExpression {
- get { return "[0-9]+";}
- }
-
protected override void Initialize ()
{
int fact_idx, quest_idx, questions;
@@ -87,11 +83,13 @@ namespace gbrainy.Games.Memory
fact_idx = random.Next (questions);
quest_idx = random.Next (facts [fact_idx].Length);
question = facts [fact_idx].questions [quest_idx];
- right_answer = (facts [fact_idx].answers [quest_idx]).ToString ();
+ Answer.Correct = (facts [fact_idx].answers [quest_idx]).ToString ();
+ Answer.CheckExpression = "[0-9]+";
// Since this particular test requires to read and understand text
// lets give the user twice time to be able to understand the text properly
TotalTime = TotalTime * 2;
+
}
Fact GetFact (int index)
diff --git a/src/Games/Memory/MemoryFigures.cs b/src/Games/Memory/MemoryFigures.cs
index 27e3376..499c91b 100644
--- a/src/Games/Memory/MemoryFigures.cs
+++ b/src/Games/Memory/MemoryFigures.cs
@@ -102,7 +102,7 @@ namespace gbrainy.Games.Memory
break;
}
}
- right_answer = question_answer.ToString ();
+ Answer.Correct = question_answer.ToString ();
base.Initialize ();
// Answers controls
diff --git a/src/Games/Memory/MemoryFiguresAndText.cs b/src/Games/Memory/MemoryFiguresAndText.cs
index 738b480..97b7f21 100644
--- a/src/Games/Memory/MemoryFiguresAndText.cs
+++ b/src/Games/Memory/MemoryFiguresAndText.cs
@@ -106,7 +106,7 @@ namespace gbrainy.Games.Memory
}
question_pos = random.Next (figures_active);
- right_answer = FigureType.ToString (figures[question_pos]);
+ Answer.Correct = FigureType.ToString (figures[question_pos]);
base.Initialize ();
}
diff --git a/src/Games/Memory/MemoryFiguresNumbers.cs b/src/Games/Memory/MemoryFiguresNumbers.cs
index f13ccff..482b8c8 100644
--- a/src/Games/Memory/MemoryFiguresNumbers.cs
+++ b/src/Games/Memory/MemoryFiguresNumbers.cs
@@ -42,7 +42,7 @@ namespace gbrainy.Games.Memory
public override string MemoryQuestion {
get { return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which one of these squares was previously shown? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3));}
}
protected override void Initialize ()
@@ -77,7 +77,7 @@ namespace gbrainy.Games.Memory
for (int i = 0; i < answers_order.Count; i++) {
if ((int) answers_order[i] == 0) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
break;
}
}
@@ -98,7 +98,7 @@ namespace gbrainy.Games.Memory
container.AddChild (drawable_area);
drawable_area.SelectedArea = new Rectangle (0.05, 0, 0.3, 0.3);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
@@ -106,7 +106,7 @@ namespace gbrainy.Games.Memory
DrawSquare (e.Context, 0.05, 0, numbers, squares * answers_order[n]);
e.Context.MoveTo (0.05, block_space - 0.02);
- e.Context.ShowPangoText (GetPossibleFigureAnswer (n));
+ e.Context.ShowPangoText (Answer.GetMultiOptionFigureName (n));
e.Context.Stroke ();
};
}
diff --git a/src/Games/Memory/MemoryIndications.cs b/src/Games/Memory/MemoryIndications.cs
index a8b76fa..18e0baf 100644
--- a/src/Games/Memory/MemoryIndications.cs
+++ b/src/Games/Memory/MemoryIndications.cs
@@ -163,7 +163,7 @@ namespace gbrainy.Games.Memory
get {
return String.Format (
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of the following graphics represent the indications previously given? Answer {0}, {1}, {2} or {3}."),
- GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3));}
+ GameAnswer.GetMultiOption (0), GameAnswer.GetMultiOption (1), GameAnswer.GetMultiOption (2), GameAnswer.GetMultiOption (3));}
}
protected override void Initialize ()
@@ -229,7 +229,7 @@ namespace gbrainy.Games.Memory
for (int i = 0; i < answers.Count; i++) {
if (answers [i] == 0) {
- right_answer = GetPossibleAnswer (i);
+ Answer.Correct = GameAnswer.GetMultiOption (i);
ans = i;
break;
}
@@ -245,14 +245,14 @@ namespace gbrainy.Games.Memory
container.AddChild (drawable_area);
drawable_area.SelectedArea = new Rectangle (0, 0, 0.45, 0.3);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
int n = (int) e.Data;
DrawPossibleAnswers (e.Context, 0.2, 0.1, WhichAnswer (answers[n]));
e.Context.MoveTo (0.2, 0.12 + 0.2);
- e.Context.ShowPangoText (GetPossibleFigureAnswer (n));
+ e.Context.ShowPangoText (Answer.GetMultiOptionFigureName (n));
};
}
@@ -266,14 +266,14 @@ namespace gbrainy.Games.Memory
container.AddChild (drawable_area);
drawable_area.SelectedArea = new Rectangle (0, 0, 0.45, 0.3);
drawable_area.Data = i;
- drawable_area.DataEx = GetPossibleAnswer (i);
+ drawable_area.DataEx = GameAnswer.GetMultiOption (i);
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
int n = (int) e.Data;
DrawPossibleAnswers (e.Context, 0.2, 0.1, WhichAnswer (answers[n]));
e.Context.MoveTo (0.2, 0.12 + 0.2);
- e.Context.ShowPangoText (GetPossibleFigureAnswer (n));
+ e.Context.ShowPangoText (Answer.GetMultiOptionFigureName (n));
};
}
}
@@ -330,7 +330,7 @@ namespace gbrainy.Games.Memory
}
DrawPossibleAnswers (gr, 0.7, 0.3, WhichAnswer (answers[ans]));
gr.MoveTo (0.7, 0.5);
- gr.ShowPangoText (GetPossibleFigureAnswer (ans));
+ gr.ShowPangoText (Answer.GetMultiOptionFigureName (ans));
gr.Stroke ();
}
}
diff --git a/src/Games/Memory/MemoryNumbers.cs b/src/Games/Memory/MemoryNumbers.cs
index b62f185..0eaa4dc 100644
--- a/src/Games/Memory/MemoryNumbers.cs
+++ b/src/Games/Memory/MemoryNumbers.cs
@@ -155,7 +155,7 @@ namespace gbrainy.Games.Memory
}
Challenge.Numbers = nums;
- right_answer = current_game.Answer;
+ Answer.Correct = current_game.Answer;
}
// Generate a random number that is unique at the numbers array
diff --git a/src/Games/Memory/MemoryWords.cs b/src/Games/Memory/MemoryWords.cs
index aaf02fa..179f73f 100644
--- a/src/Games/Memory/MemoryWords.cs
+++ b/src/Games/Memory/MemoryWords.cs
@@ -112,7 +112,7 @@ namespace gbrainy.Games.Memory
words_order.Initialize ();
answer = random.Next (showed);
tmp = words_order [answer];
- right_answer = words [tmp];
+ Answer.Correct = words [tmp];
base.Initialize ();
}
diff --git a/tests/Core/GameTest.cs b/tests/Core/GameTest.cs
index e77dd0d..cac290d 100644
--- a/tests/Core/GameTest.cs
+++ b/tests/Core/GameTest.cs
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ * Copyright (C) 2010-2011 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
@@ -26,12 +26,9 @@ namespace gbrainyTest
{
public class TestGame : Game
{
- public string Expression { get; set; }
- public GameAnswerCheckAttributes Attributes { get; set; }
-
public TestGame ()
{
- Attributes = base.CheckAttributes;
+
}
public override string Question {
@@ -43,24 +40,7 @@ namespace gbrainyTest
}
public string PossibleAnswersExpression {
- get { return GetPossibleAnswersExpression (); }
- }
-
- public string RightAnswer {
- set { right_answer = value; }
- }
-
- public override string AnswerCheckExpression {
- get {
- if (String.IsNullOrEmpty (Expression))
- return base.AnswerCheckExpression;
-
- return Expression;
- }
- }
-
- public override GameAnswerCheckAttributes CheckAttributes {
- get { return Attributes; }
+ get { return Answer.GetMultiOptionsExpression (); }
}
protected override void Initialize () {}
@@ -82,20 +62,20 @@ namespace gbrainyTest
{
TestGame game = new TestGame ();
- game.Attributes = GameAnswerCheckAttributes.None;
- game.RightAnswer = "icon";
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.None;
+ game.Answer.Correct = "icon";
Assert.AreEqual (true, game.CheckAnswer ("icon"));
Assert.AreEqual (false, game.CheckAnswer (" icon "));
- game.Attributes = GameAnswerCheckAttributes.Trim;
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.Trim;
Assert.AreEqual (true, game.CheckAnswer ("icon"));
Assert.AreEqual (true, game.CheckAnswer (" icon "));
- game.Attributes = GameAnswerCheckAttributes.MatchAll;
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.MatchAll;
Assert.AreEqual (true, game.CheckAnswer ("icon"));
Assert.AreEqual (false, game.CheckAnswer (" icon "));
- game.Attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
Assert.AreEqual (true, game.CheckAnswer ("icon"));
Assert.AreEqual (true, game.CheckAnswer (" icon "));
}
@@ -105,20 +85,20 @@ namespace gbrainyTest
{
TestGame game = new TestGame ();
- game.Attributes = GameAnswerCheckAttributes.None;
- game.RightAnswer = "icon";
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.None;
+ game.Answer.Correct = "icon";
Assert.AreEqual (true, game.CheckAnswer ("icon"));
Assert.AreEqual (false, game.CheckAnswer ("ICON"));
- game.Attributes = GameAnswerCheckAttributes.IgnoreCase;
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.IgnoreCase;
Assert.AreEqual (true, game.CheckAnswer ("icon"));
Assert.AreEqual (true, game.CheckAnswer ("ICON"));
- game.Attributes = GameAnswerCheckAttributes.MatchAll;
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.MatchAll;
Assert.AreEqual (true, game.CheckAnswer ("icon"));
Assert.AreEqual (false, game.CheckAnswer ("ICON"));
- game.Attributes = GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll;
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll;
Assert.AreEqual (true, game.CheckAnswer ("icon"));
Assert.AreEqual (true, game.CheckAnswer ("ICON"));
}
@@ -128,20 +108,20 @@ namespace gbrainyTest
{
TestGame game = new TestGame ();
- game.Attributes = GameAnswerCheckAttributes.None;
- game.RightAnswer = "10 pm";
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.None;
+ game.Answer.Correct = "10 pm";
Assert.AreEqual (true, game.CheckAnswer ("10 pm"));
Assert.AreEqual (false, game.CheckAnswer ("10pm"));
- game.Attributes = GameAnswerCheckAttributes.IgnoreSpaces;
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.IgnoreSpaces;
Assert.AreEqual (true, game.CheckAnswer ("10 pm"));
Assert.AreEqual (true, game.CheckAnswer ("10pm"));
- game.Attributes = GameAnswerCheckAttributes.MatchAll;
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.MatchAll;
Assert.AreEqual (true, game.CheckAnswer ("10 pm"));
Assert.AreEqual (false, game.CheckAnswer ("10pm"));
- game.Attributes = GameAnswerCheckAttributes.IgnoreSpaces | GameAnswerCheckAttributes.MatchAll;
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.IgnoreSpaces | GameAnswerCheckAttributes.MatchAll;
Assert.AreEqual (true, game.CheckAnswer ("10 pm"));
Assert.AreEqual (true, game.CheckAnswer ("10pm"));
}
@@ -151,9 +131,9 @@ namespace gbrainyTest
{
TestGame game = new TestGame ();
- game.Attributes = GameAnswerCheckAttributes.MatchAllInOrder;
- game.Expression = "[0-9]+";
- game.RightAnswer = "10 | 20 | 30";
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.MatchAllInOrder;
+ game.Answer.CheckExpression = "[0-9]+";
+ game.Answer.Correct = "10 | 20 | 30";
Assert.AreEqual (true, game.CheckAnswer ("10 20 30"));
Assert.AreEqual (false, game.CheckAnswer ("30 20 10"));
@@ -164,9 +144,9 @@ namespace gbrainyTest
{
TestGame game = new TestGame ();
- game.Attributes = GameAnswerCheckAttributes.MatchAll;
- game.Expression = "[0-9]+";
- game.RightAnswer = "10 | 20 | 30";
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.MatchAll;
+ game.Answer.CheckExpression = "[0-9]+";
+ game.Answer.Correct = "10 | 20 | 30";
Assert.AreEqual (true, game.CheckAnswer ("10 20 30"));
Assert.AreEqual (true, game.CheckAnswer ("30 20 10"));
}
@@ -178,10 +158,10 @@ namespace gbrainyTest
{
TestGame game = new TestGame ();
- game.RightAnswer = "icon";
+ game.Answer.Correct = "icon";
Assert.AreEqual (true, game.CheckAnswer ("icon"));
- game.RightAnswer = "icona";
+ game.Answer.Correct = "icona";
Assert.AreEqual (true, game.CheckAnswer ("icona"));
}
@@ -190,7 +170,7 @@ namespace gbrainyTest
{
TestGame game = new TestGame ();
- game.RightAnswer = "option1 | option2";
+ game.Answer.Correct = "option1 | option2";
Assert.AreEqual (true, game.CheckAnswer ("option1"));
Assert.AreEqual (true, game.CheckAnswer ("option2"));
Assert.AreEqual (true, game.CheckAnswer (" option2 "));
@@ -202,8 +182,8 @@ namespace gbrainyTest
public void CheckPuzzleTimeNowAnswer ()
{
TestGame game = new TestGame ();
- game.RightAnswer = "10 PM";
- game.Attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.IgnoreSpaces;
+ game.Answer.Correct = "10 PM";
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.IgnoreSpaces;
Assert.AreEqual (true, game.CheckAnswer ("10 PM"));
Assert.AreEqual (true, game.CheckAnswer ("10 pm"));
@@ -219,9 +199,9 @@ namespace gbrainyTest
public void CheckCalculationOperator ()
{
TestGame game = new TestGame ();
- game.RightAnswer = "+ | -";
- game.Expression = "[+*-/]";
- game.Attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAllInOrder;
+ game.Answer.Correct = "+ | -";
+ game.Answer.CheckExpression = "[+*-/]";
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAllInOrder;
Assert.AreEqual (true, game.CheckAnswer ("+ i -"));
Assert.AreEqual (true, game.CheckAnswer ("+ and -"));
@@ -236,9 +216,9 @@ namespace gbrainyTest
{
TestGame game = new TestGame ();
- game.RightAnswer = "A | B | C";
- game.Expression = "[ABCDF]";
- game.Attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll;
+ game.Answer.Correct = "A | B | C";
+ game.Answer.CheckExpression = "[ABCDF]";
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll;
Assert.AreEqual (true, game.CheckAnswer ("A B C"));
Assert.AreEqual (true, game.CheckAnswer ("C B A"));
@@ -258,14 +238,14 @@ namespace gbrainyTest
{
TestGame game = new TestGame ();
- game.RightAnswer = "10";
- game.Expression = "[0-9]+";
+ game.Answer.Correct = "10";
+ game.Answer.CheckExpression = "[0-9]+";
Assert.AreEqual (true, game.CheckAnswer ("10%"));
Assert.AreEqual (true, game.CheckAnswer ("10 %"));
Assert.AreEqual (true, game.CheckAnswer ("10"));
- game.RightAnswer = "9";
+ game.Answer.Correct = "9";
Assert.AreEqual (true, game.CheckAnswer ("9%"));
Assert.AreEqual (true, game.CheckAnswer ("9 %"));
Assert.AreEqual (true, game.CheckAnswer ("9"));
@@ -275,9 +255,9 @@ namespace gbrainyTest
public void TwoNumbersAnswer ()
{
TestGame game = new TestGame ();
- game.RightAnswer = "10 | 20";
- game.Expression = "[0-9]+";
- game.Attributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
+ game.Answer.Correct = "10 | 20";
+ game.Answer.CheckExpression = "[0-9]+";
+ game.Answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
// Right answers
Assert.AreEqual (true, game.CheckAnswer ("10 and 20"));
diff --git a/tests/Core/GameXmlFactoryTest.cs b/tests/Core/GameXmlFactoryTest.cs
index 6e9f197..187f683 100644
--- a/tests/Core/GameXmlFactoryTest.cs
+++ b/tests/Core/GameXmlFactoryTest.cs
@@ -55,7 +55,7 @@ namespace gbrainyTest
Assert.AreEqual ("Rationale text", definition.Rationale.String);
Assert.AreEqual ("How many degrees rotates the minute hand of a clock?", definition.Question.String);
Assert.AreEqual ("How many degrees rotates the minute hand of a clocks?", definition.Question.PluralString);
- Assert.AreEqual ("[rslt]", definition.Answer);
+ Assert.AreEqual ("[rslt]", definition.AnswerText);
}
@@ -108,13 +108,13 @@ namespace gbrainyTest
// Variant: John is 46 years old.
variant = definition.Variants [0];
Assert.AreEqual (true, variant.Question.String.Contains ("John is 46 years old"));
- Assert.AreEqual ("[son]", variant.Answer);
+ Assert.AreEqual ("[son]", variant.AnswerText);
Assert.AreEqual (true, variant.Variables.Contains ("int father = 46;"));
// Variant: John's age is nowadays 2 times his son's age.
variant = definition.Variants [1];
Assert.AreEqual (true, variant.Question.String.Contains ("John's age is nowadays 2 times his son's age."));
- Assert.AreEqual ("24", variant.Answer);
+ Assert.AreEqual ("24", variant.AnswerText);
Assert.AreEqual (true, variant.Variables.Contains ("int ago = years [idx];"));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]