gbrainy.Core.Main.PlayerHistory.SaveGameSession C# (CSharp) 메소드

SaveGameSession() 공개 메소드

public SaveGameSession ( GameSessionHistory score ) : void
score GameSessionHistory
리턴 void
        public void SaveGameSession(GameSessionHistory score)
        {
            if (score.GamesPlayed < Preferences.Get <int> (Preferences.MinPlayedGamesKey)) {
                last_game = -1;
                return;
            }

            if (Games.Count >= Preferences.Get <int> (Preferences.MaxStoredGamesKey))
                Games.RemoveAt (0);

            // Storing a copy to allow the input object to be modified
            Games.Add (score.Copy ());
            last_game = Games.Count - 1;
            Save ();
        }

Usage Example

        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");
        }
All Usage Examples Of gbrainy.Core.Main.PlayerHistory::SaveGameSession