public void PlayerScoreList() { if (File.Exists(FILE_NAME)) { File.Delete(FILE_NAME); } var list = new ScoreList <PlayerScore>(new PlayerScoreFile(FILE_NAME)); list.AddScore(new PlayerScore("Bjärn", 3)); list.AddScore(new PlayerScore("Snudin", 8)); list.AddScore(new PlayerScore("Satan", 6)); list.AddScore(new PlayerScore("Snigel", -4)); list.AddScore(new PlayerScore("Palettblad", 70)); // The expected score list is sorted by score, descending. var expectedList = new List <PlayerScore> { new PlayerScore("Palettblad", 70), new PlayerScore("Snudin", 8), new PlayerScore("Satan", 6), new PlayerScore("Bjärn", 3), new PlayerScore("Snigel", -4), }; Assert.Equal(expectedList, list.Scores); // Load the scores from the file again. var newList = new ScoreList <PlayerScore>(new PlayerScoreFile(FILE_NAME)); Assert.Equal(expectedList, newList.Scores); }
// Adds a new score public void SubmitScore(string playerName, int score) { m_scores.AddScore(new Score(playerName, score) { isCurrent = true }); // Add the new score to the list. (also sorts, and marks it as a score gotten this run) PlayerPrefs.SetString("scores", m_scores.ToBase64()); // Save to PlayerPrefs RespawnScores(); // Reload ui }
public void ScoreListKeepsScore() { ScoreList scorelist = new ScoreList(); Competitor competitor1 = new Competitor() { Name = "Comp1", Id = Guid.NewGuid() }; Competitor competitor2 = new Competitor() { Name = "Comp2", Id = Guid.NewGuid() }; scorelist.AddScore(competitor1, 10, competitor1); Assert.AreEqual(1, scorelist.ShowGameScoresForPlayer(competitor1).Count); }
/* * Saves the current player score to the score store with the nickname playerName. */ public void SaveScore(string playerName) { _scoreList.AddScore(new PlayerScore(playerName, _scoreKeeper.Score.Points)); }