[gbrainy/difficulty] Remove difficulty from Core
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy/difficulty] Remove difficulty from Core
- Date: Sat, 3 Sep 2022 18:03:46 +0000 (UTC)
commit 1c53b100e8240a4d77184ae74c81d4398ca1512c
Author: Jordi Mas <jmas softcatala org>
Date: Sat Sep 3 19:19:59 2022 +0200
Remove difficulty from Core
src/Core/Main/Game.cs | 15 +-------
src/Core/Main/GameDifficulty.cs | 56 -----------------------------
src/Core/Main/GameSession.cs | 7 +---
src/Core/Main/GameSessionHistoryExtended.cs | 4 +--
src/Core/Main/GameSessionPlayList.cs | 21 ++---------
src/Core/Main/Preferences.cs | 2 --
src/Core/Main/Score.cs | 48 ++++++-------------------
src/Core/Main/Xml/GameXmlDefinition.cs | 3 --
src/Core/Main/Xml/GameXmlFactory.cs | 7 ----
src/Core/Makefile.am | 1 -
10 files changed, 18 insertions(+), 146 deletions(-)
---
diff --git a/src/Core/Main/Game.cs b/src/Core/Main/Game.cs
index 650ed9e9..5c10c7d4 100644
--- a/src/Core/Main/Game.cs
+++ b/src/Core/Main/Game.cs
@@ -31,7 +31,6 @@ namespace gbrainy.Core.Main
private TimeSpan game_time;
private bool tip_used;
private bool preview;
- private GameDifficulty difficulty;
private ISynchronizeInvoke synchronize;
private readonly List <Toolkit.Container> containers;
private int variant;
@@ -45,7 +44,6 @@ namespace gbrainy.Core.Main
{
answer = new GameAnswer ();
containers = new List <Toolkit.Container> ();
- difficulty = GameDifficulty.Medium;
}
public GameAnswer Answer {
@@ -97,11 +95,6 @@ namespace gbrainy.Core.Main
get { return GameTypes.LogicPuzzle;}
}
- // Indicates in which difficulty levels the game should be shown
- public virtual GameDifficulty Difficulty {
- get { return GameDifficulty.Master | GameDifficulty.Medium | GameDifficulty.Easy; }
- }
-
// Indicates if the game should be excluded for color blind users
public virtual bool UsesColors {
get { return false;}
@@ -154,12 +147,6 @@ namespace gbrainy.Core.Main
set {preview = value; }
}
- // The level of difficulty selected for the current game
- public GameDifficulty CurrentDifficulty {
- set { difficulty = value; }
- get { return difficulty; }
- }
-
public string TipString {
get {
string tip = Tip;
@@ -211,7 +198,7 @@ namespace gbrainy.Core.Main
// Expected time in seconds that a player is expected to complete this game
public int ExpectedTime {
- get { return Main.Score.GameExpectedTime (Type, CurrentDifficulty); }
+ get { return Main.Score.GameExpectedTime (Type); }
}
public Widget [] Widgets {
diff --git a/src/Core/Main/GameSession.cs b/src/Core/Main/GameSession.cs
index 44181c15..9e17d76b 100644
--- a/src/Core/Main/GameSession.cs
+++ b/src/Core/Main/GameSession.cs
@@ -109,11 +109,6 @@ namespace gbrainy.Core.Main
set { play_list.GameType = value; }
}
- public GameDifficulty Difficulty {
- get { return play_list.Difficulty; }
- set { play_list.Difficulty = value; }
- }
-
public string GameTime {
get { return TimeSpanToStr (game_time);}
}
@@ -282,7 +277,7 @@ namespace gbrainy.Core.Main
return false;
game_score = CurrentGame.Score (answer);
- history.UpdateScore (CurrentGame.Type, Difficulty, game_score);
+ history.UpdateScore (CurrentGame.Type, game_score);
Status = SessionStatus.Answered;
return (game_score > 0 ? true : false);
diff --git a/src/Core/Main/GameSessionHistoryExtended.cs b/src/Core/Main/GameSessionHistoryExtended.cs
index 01276bf2..6b252614 100644
--- a/src/Core/Main/GameSessionHistoryExtended.cs
+++ b/src/Core/Main/GameSessionHistoryExtended.cs
@@ -44,10 +44,10 @@ namespace gbrainy.Core.Main
VerbalPlayed = VerbalWon = VerbalRawScore = 0;
}
- public void UpdateScore (GameTypes type, GameDifficulty difficulty, int game_score)
+ public void UpdateScore (GameTypes type, int game_score)
{
GameSessionHistoryExtended history = this;
- Score.SessionUpdateHistoryScore (ref history, type, difficulty, game_score);
+ Score.SessionUpdateHistoryScore (ref history, type, game_score);
}
}
}
diff --git a/src/Core/Main/GameSessionPlayList.cs b/src/Core/Main/GameSessionPlayList.cs
index ac62f0db..15ee5da9 100644
--- a/src/Core/Main/GameSessionPlayList.cs
+++ b/src/Core/Main/GameSessionPlayList.cs
@@ -21,12 +21,11 @@ using System.Collections.Generic;
namespace gbrainy.Core.Main
{
- // Manages a list of games to played within a session based on difficulty, game types and other
parameters
+ // Manages a list of games to played within a session based game types and other parameters
public class GameSessionPlayList
{
IEnumerator <int> enumerator;
- List <int> play_list; // Play list for the Selected difficulty, game types
- GameDifficulty difficulty;
+ List <int> play_list; // Play list for the Selected game types
bool color_blind;
bool dirty;
GameSession.Types game_type;
@@ -37,7 +36,6 @@ namespace gbrainy.Core.Main
this.manager = manager;
play_list = new List <int> ();
game_type = GameSession.Types.AllGames;
- difficulty = GameDifficulty.Medium;
RandomOrder = true;
dirty = true;
}
@@ -53,17 +51,6 @@ namespace gbrainy.Core.Main
}
}
- public GameDifficulty Difficulty {
- set {
- if (difficulty == value)
- return;
-
- difficulty = value;
- dirty = true;
- }
- get { return difficulty; }
- }
-
public GameManager GameManager {
get { return manager;}
set {
@@ -230,11 +217,9 @@ namespace gbrainy.Core.Main
if (first == null)
first = puzzle;
- if ((puzzle.Difficulty & difficulty) == difficulty)
- break;
+ break;
}
- puzzle.CurrentDifficulty = Difficulty;
return puzzle;
}
}
diff --git a/src/Core/Main/Preferences.cs b/src/Core/Main/Preferences.cs
index 71628ca0..b7362041 100644
--- a/src/Core/Main/Preferences.cs
+++ b/src/Core/Main/Preferences.cs
@@ -31,7 +31,6 @@ namespace gbrainy.Core.Main
public const string MemQuestionWarnKey = "MemQuestionWarn";
public const string MemQuestionTimeKey = "MemQuestionTime";
- public const string DifficultyKey = "Difficulty";
public const string MinPlayedGamesKey = "MinPlayedGames";
public const string MaxStoredGamesKey = "MaxStoredGames";
public const string ToolbarShowKey = "ToolbarShow";
@@ -129,7 +128,6 @@ namespace gbrainy.Core.Main
defaults.Add (MemQuestionWarnKey, true.ToString ());
defaults.Add (MemQuestionTimeKey, "6");
- defaults.Add (DifficultyKey, ((int)(GameDifficulty.Medium)).ToString ());
defaults.Add (MinPlayedGamesKey, "5");
defaults.Add (MaxStoredGamesKey, "20");
defaults.Add (ToolbarShowKey, true.ToString ());
diff --git a/src/Core/Main/Score.cs b/src/Core/Main/Score.cs
index 3e35237b..437080de 100644
--- a/src/Core/Main/Score.cs
+++ b/src/Core/Main/Score.cs
@@ -28,22 +28,9 @@ namespace gbrainy.Core.Main
*/
// Expected time in seconds that a player is expected to complete this game
- static public int GameExpectedTime (GameTypes type, GameDifficulty difficulty)
+ static public int GameExpectedTime (GameTypes type)
{
- double factor;
-
- switch (difficulty) {
- case GameDifficulty.Easy:
- factor = 1.3;
- break;
- case GameDifficulty.Master:
- factor = 0.7;
- break;
- case GameDifficulty.Medium:
- default:
- factor = 1.0;
- break;
- }
+ double factor = 1.0;
switch (type) {
case GameTypes.Memory:
@@ -98,11 +85,11 @@ namespace gbrainy.Core.Main
* The results are added to the games and scores arrays where we store the results for
the different game types (verbal, logic, etc)
* We apply a SessionScoreFormula function that balances the total result with the
number of
- games played (is not the same 100% games won playing 2 than 10 games) and the
difficulty
+ games played (is not the same 100% games won playing 2 than 10 games)
The final result is a number from 0 to 100
*/
- static public void SessionUpdateHistoryScore (ref GameSessionHistoryExtended history,
GameTypes type, GameDifficulty difficulty, int game_score)
+ static public void SessionUpdateHistoryScore (ref GameSessionHistoryExtended history,
GameTypes type, int game_score)
{
bool won;
int components = 0;
@@ -118,25 +105,25 @@ namespace gbrainy.Core.Main
history.LogicRawScore += game_score;
history.LogicPlayed++;
if (won) history.LogicWon++;
- history.LogicScore = SessionScoreFormula (ref history, type, difficulty);
+ history.LogicScore = SessionScoreFormula (ref history, type);
break;
case GameTypes.Memory:
history.MemoryRawScore += game_score;
history.MemoryPlayed++;
if (won) history.MemoryWon++;
- history.MemoryScore = SessionScoreFormula (ref history, type, difficulty);
+ history.MemoryScore = SessionScoreFormula (ref history, type);
break;
case GameTypes.Calculation:
history.MathRawScore += game_score;
history.MathPlayed++;
if (won) history.MathWon++;
- history.MathScore = SessionScoreFormula (ref history, type, difficulty);
+ history.MathScore = SessionScoreFormula (ref history, type);
break;
case GameTypes.VerbalAnalogy:
history.VerbalRawScore += game_score;
history.VerbalPlayed++;
if (won) history.VerbalWon++;
- history.VerbalScore = SessionScoreFormula (ref history, type, difficulty);
+ history.VerbalScore = SessionScoreFormula (ref history, type);
break;
default:
throw new InvalidOperationException ("Invalid switch value");
@@ -171,24 +158,11 @@ namespace gbrainy.Core.Main
//
// Applies scoring formula to the session
//
- static int SessionScoreFormula (ref GameSessionHistoryExtended history, GameTypes type,
GameDifficulty difficulty)
+ static int SessionScoreFormula (ref GameSessionHistoryExtended history, GameTypes type)
{
- int logbase, scored, played, won;
+ int scored, played, won;
double score, factor;
-
- switch (difficulty) {
- case GameDifficulty.Easy:
- logbase = 10;
- break;
- case GameDifficulty.Medium:
- logbase = 20;
- break;
- case GameDifficulty.Master:
- logbase = 30;
- break;
- default:
- throw new InvalidOperationException ("Invalid switch value");
- }
+ int logbase = 20;
switch (type) {
case GameTypes.LogicPuzzle:
diff --git a/src/Core/Main/Xml/GameXmlDefinition.cs b/src/Core/Main/Xml/GameXmlDefinition.cs
index 6829a966..ccd97baf 100644
--- a/src/Core/Main/Xml/GameXmlDefinition.cs
+++ b/src/Core/Main/Xml/GameXmlDefinition.cs
@@ -24,14 +24,12 @@ namespace gbrainy.Core.Main.Xml
public class GameXmlDefinition : GameXmlDefinitionVariant
{
public string Name { get; set; }
- public GameDifficulty Difficulty { get; set; }
public GameTypes Type { get; set; }
public List <GameXmlDefinitionVariant> Variants { get; set; }
public GameXmlDefinition ()
{
- Difficulty = GameDifficulty.Medium;
Type = GameTypes.LogicPuzzle; // TODO: temporary, should be mandatory in games.xml
Variants = new List <GameXmlDefinitionVariant> ();
}
@@ -46,7 +44,6 @@ namespace gbrainy.Core.Main.Xml
StringBuilder str = new StringBuilder ();
str.AppendLine ("Name: " + Name);
- str.AppendLine ("Difficulty: " + Difficulty);
str.AppendLine (base.ToString ());
foreach (GameXmlDefinitionVariant variant in Variants)
diff --git a/src/Core/Main/Xml/GameXmlFactory.cs b/src/Core/Main/Xml/GameXmlFactory.cs
index 31425e2b..f669f9a3 100644
--- a/src/Core/Main/Xml/GameXmlFactory.cs
+++ b/src/Core/Main/Xml/GameXmlFactory.cs
@@ -103,13 +103,6 @@ namespace gbrainy.Core.Main.Xml
game.Name = reader.ReadElementString ();
break;
- case "difficulty":
- if (reader.NodeType != XmlNodeType.Element)
- break;
-
- str = reader.ReadElementString ();
- game.Difficulty = GameDifficultyDescription.FromString (str);
- break;
case "svg":
if (reader.NodeType != XmlNodeType.Element)
break;
diff --git a/src/Core/Makefile.am b/src/Core/Makefile.am
index 7c7faa71..086745e9 100644
--- a/src/Core/Makefile.am
+++ b/src/Core/Makefile.am
@@ -15,7 +15,6 @@ CSDISTFILES = \
$(srcdir)/Main/GameAnswer.cs \
$(srcdir)/Main/GameAnswerCheckAttributes.cs \
$(srcdir)/Main/GameAnswerEventArgs.cs \
- $(srcdir)/Main/GameDifficulty.cs \
$(srcdir)/Main/GameLocator.cs \
$(srcdir)/Main/GameManager.cs \
$(srcdir)/Main/GameSession.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]