[gbrainy/refactoring] Remove unused property & move Result Method where it belongs
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy/refactoring] Remove unused property & move Result Method where it belongs
- Date: Fri, 29 Jul 2011 18:55:46 +0000 (UTC)
commit 6eeb4c553ee0bc71074ebd703c266859bd0f32b1
Author: Jordi Mas <jmas softcatala org>
Date: Fri Jul 29 20:55:13 2011 +0200
Remove unused property & move Result Method where it belongs
src/Core/Main/GameSession.cs | 35 ++---------------------------------
src/Core/Main/GameSessionHistory.cs | 24 ++++++++++++++++++++++++
src/Core/Views/FinishView.cs | 2 +-
3 files changed, 27 insertions(+), 34 deletions(-)
---
diff --git a/src/Core/Main/GameSession.cs b/src/Core/Main/GameSession.cs
index d2fa03f..f059b29 100644
--- a/src/Core/Main/GameSession.cs
+++ b/src/Core/Main/GameSession.cs
@@ -53,7 +53,6 @@ namespace gbrainy.Core.Main
private GameManager game_manager;
private System.Timers.Timer timer;
private bool paused;
- private string current_time;
private TimeSpan one_sec = TimeSpan.FromSeconds (1);
private SessionStatus status;
private ViewsControler controler;
@@ -151,12 +150,6 @@ namespace gbrainy.Core.Main
set { game_manager = value;}
}
- public string TimePlayed {
- get {
- return (current_time == null) ? TimeSpanToStr (TimeSpan.FromSeconds (0)) : current_time;
- }
- }
-
public string TimePerGame {
get {
TimeSpan average;
@@ -174,7 +167,8 @@ namespace gbrainy.Core.Main
string played, time, game;
played = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Games played: {0} (Score: {1})"), history.GamesPlayed, history.TotalScore);
- time = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Time: {0}"), current_time);
+ time = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Time: {0}"),
+ paused == false ? GameTime : ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Paused"));
if (CurrentGame != null) {
// Translators: {0} is the name of the game
@@ -188,28 +182,6 @@ namespace gbrainy.Core.Main
}
}
- // Summarizes how the game did go
- public string Result {
- get {
- string s;
-
- if (history.GamesPlayed >= 10) {
- int percentage_won = (int) (100 * history.GamesWon / history.GamesPlayed);
- if (percentage_won >= 90)
- s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Outstanding results");
- else if (percentage_won >= 70)
- s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Excellent results");
- else if (percentage_won >= 50)
- s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Good results");
- else if (percentage_won >= 30)
- s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Poor results");
- else s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Disappointing results");
- } else
- s = string.Empty;
-
- return s;
- }
- }
public void New ()
{
@@ -222,7 +194,6 @@ namespace gbrainy.Core.Main
history.Clear ();
game_time = TimeSpan.Zero;
- current_time = TimeSpanToStr (game_time);
timer.SynchronizingObject = SynchronizingObject;
EnableTimer = true;
}
@@ -277,7 +248,6 @@ namespace gbrainy.Core.Main
{
EnableTimer = false;
paused = true;
- current_time = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Paused");
if (CurrentGame != null)
CurrentGame.EnableMouseEvents (false);
@@ -314,7 +284,6 @@ namespace gbrainy.Core.Main
game_time = game_time.Add (one_sec);
CurrentGame.GameTime = CurrentGame.GameTime + one_sec;
- current_time = TimeSpanToStr (game_time);
}
if (UpdateUIElement == null)
diff --git a/src/Core/Main/GameSessionHistory.cs b/src/Core/Main/GameSessionHistory.cs
index 5ca5f13..ad39b51 100644
--- a/src/Core/Main/GameSessionHistory.cs
+++ b/src/Core/Main/GameSessionHistory.cs
@@ -20,6 +20,8 @@
using System;
using System.Xml.Serialization;
+using gbrainy.Core.Services;
+
namespace gbrainy.Core.Main
{
[Serializable]
@@ -67,6 +69,28 @@ namespace gbrainy.Core.Main
history.VerbalScore = VerbalScore;
return history;
}
+
+ public string Result {
+ get {
+ string s;
+
+ if (GamesPlayed >= 10) {
+ int percentage_won = (int) (100 * GamesWon / GamesPlayed);
+ if (percentage_won >= 90)
+ s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Outstanding results");
+ else if (percentage_won >= 70)
+ s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Excellent results");
+ else if (percentage_won >= 50)
+ s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Good results");
+ else if (percentage_won >= 30)
+ s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Poor results");
+ else s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Disappointing results");
+ } else
+ s = string.Empty;
+
+ return s;
+ }
+ }
}
}
diff --git a/src/Core/Views/FinishView.cs b/src/Core/Views/FinishView.cs
index c9ace22..6d24e1f 100644
--- a/src/Core/Views/FinishView.cs
+++ b/src/Core/Views/FinishView.cs
@@ -143,7 +143,7 @@ namespace gbrainy.Core.Views
y += 0.08;
gr.MoveTo (x, y);
- s = session.Result;
+ s = session.History.Result;
if (s == string.Empty)
gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Games won: {0} ({1} played)"), session.History.GamesWon, session.History.GamesPlayed));
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]