Exemplo n.º 1
0
        public void Clean()
        {
            GameSessionHistory game = new GameSessionHistory();

            game.GamesPlayed = Preferences.Get <int> (Preferences.MinPlayedGamesKey);

            history            = new PlayerHistory();
            history.ConfigPath = ".";
            history.Clean();
            history.SaveGameSession(game);

            Assert.AreEqual(1, history.Games.Count);
            history.Clean();
            Assert.AreEqual(0, history.Games.Count);
        }
        public void MinGamesRecord()
        {
            PlayerHistory history;

            GameSessionHistory game = new GameSessionHistory();

            game.GamesPlayed = Preferences.Get <int> (Preferences.MinPlayedGamesKey);

            history            = new PlayerHistory();
            history.ConfigPath = ".";
            history.Clean();

            for (int i = 0; i < PlayerPersonalRecord.MIN_GAMES_RECORD - 2; i++)
            {
                history.SaveGameSession(game);
            }

            game.LogicScore = 10;
            history.SaveGameSession(game);

            Assert.AreEqual(0, history.GetLastGameRecords().Count,
                            "Did not reach MinPlayedGamesKey, the game should not be a person record yet");

            game.LogicScore = 30;
            history.SaveGameSession(game);

            Assert.AreEqual(1, history.GetLastGameRecords().Count,
                            "We have just recorded a personal record");

            game.LogicScore = 20;
            history.SaveGameSession(game);

            Assert.AreEqual(0, history.GetLastGameRecords().Count,
                            "Score saved was lower than previous, no record");
        }
Exemplo n.º 3
0
        public void PersonalRecordDone()
        {
            PlayerHistory history = new PlayerHistory()
            {
                ConfigPath = "."
            };
            GameSessionHistory game = new GameSessionHistory()
            {
                GamesPlayed = Preferences.Get <int> (Preferences.MinPlayedGamesKey)
            };

            history.Clean();
            for (int i = 0; i < PlayerPersonalRecord.MIN_GAMES_RECORD - 1; i++)
            {
                history.SaveGameSession(game);
            }

            game.LogicScore = 20;
            history.SaveGameSession(game);

            game.LogicScore = 30;
            history.SaveGameSession(game);

            Assert.AreEqual(1, history.GetLastGameRecords().Count, "We have just recorded a personal record");
        }
Exemplo n.º 4
0
        public void ScoreLowerThanPrevious()
        {
            PlayerHistory history = new PlayerHistory()
            {
                ConfigPath = "."
            };
            GameSessionHistory game = new GameSessionHistory()
            {
                GamesPlayed = Preferences.Get <int> (Preferences.MinPlayedGamesKey)
            };

            history.Clean();
            for (int i = 0; i < PlayerPersonalRecord.MIN_GAMES_RECORD - 1; i++)
            {
                history.SaveGameSession(game);
            }

            game.LogicScore = 30;
            history.SaveGameSession(game);

            game.LogicScore = 20;
            history.SaveGameSession(game);

            Assert.AreEqual(0, history.GetLastGameRecords().Count, "Score saved was lower than previous, no record");
        }
Exemplo n.º 5
0
 private void OnCleanHistory(object sender, EventArgs args)
 {
     if (ResponseType.Ok == HigMessageDialog.RunHigConfirmation(
             this,
             Gtk.DialogFlags.DestroyWithParent,
             Gtk.MessageType.Warning,
             Catalog.GetString("You are about to delete the player's game session history."),
             Catalog.GetString("If you proceed, you will lose the history of the previous game sessions. Do you want to continue?"),
             Catalog.GetString("_Delete")))
     {
         history.Clean();
     }
 }
Exemplo n.º 6
0
        public void PersonalRecordDoneButPreviousWas0()
        {
            PlayerHistory history = new PlayerHistory()
            {
                ConfigPath = "."
            };
            GameSessionHistory game = new GameSessionHistory()
            {
                GamesPlayed = Preferences.Get <int> (Preferences.MinPlayedGamesKey)
            };

            history.Clean();
            for (int i = 0; i < PlayerPersonalRecord.MIN_GAMES_RECORD; i++)
            {
                history.SaveGameSession(game);
            }

            game.LogicScore = 30;
            history.SaveGameSession(game);

            Assert.AreEqual(0, history.GetLastGameRecords().Count, "No record since previous was 0");
        }
Exemplo n.º 7
0
        public void MinGamesNotReached()
        {
            PlayerHistory history = new PlayerHistory()
            {
                ConfigPath = "."
            };
            GameSessionHistory game = new GameSessionHistory()
            {
                GamesPlayed = Preferences.Get <int> (Preferences.MinPlayedGamesKey)
            };

            history.Clean();
            for (int i = 0; i < PlayerPersonalRecord.MIN_GAMES_RECORD - 2; i++)
            {
                history.SaveGameSession(game);
            }

            game.LogicScore = 10;
            history.SaveGameSession(game);

            Assert.AreEqual(0, history.GetLastGameRecords().Count,
                            "Did not reach MinPlayedGamesKey, the game should not be a personal record yet");
        }