public void CheckNewScores_LowerScore_AddsNothing() { Game myGame = new Game(false); HighScores hiScore = new HighScores(new List <HiScore>()); hiScore.HiScores.Add(new HiScore("ben", 123)); hiScore.HiScores.Add(new HiScore("act", 234)); hiScore.HiScores.Add(new HiScore("deb", 345)); hiScore.HiScores.Add(new HiScore("hess", 456)); hiScore.HiScores.Add(new HiScore("dark", 567)); hiScore.HiScores.Add(new HiScore("bluff", 678)); hiScore.HiScores.Add(new HiScore("schaub", 789)); hiScore.HiScores.Add(new HiScore("mcgee", 890)); hiScore.HiScores.Add(new HiScore("knisely", 903)); hiScore.HiScores.Add(new HiScore("watson", 1)); myGame.Username = "******"; myGame.Points = 0; hiScore.CheckNewScores(myGame); Assert.IsFalse(hiScore.HiScores.Contains(new HiScore("Evisserate", 0))); }
public Game(bool isCheat) { IsCheat = isCheat; IsOver = false; Random = new Random(); ViewCamera = new Camera(this); Points = 0; Ticks = 0; HorizontalInput = 0; VerticalInput = 0; WellSpawnFreq = 400; WellDestabFreq = 4000; StableWells = new List <Well>(); UnstableWells = new List <Well>(); AIShips = new List <AIShip>(); Orbs = new List <Orb>(); GameObjects = new List <GameObject>(); highScores = HighScores.Load(Path.Combine(Directory.GetCurrentDirectory(), "Saves/HighScoreSave.txt")); }
public void Serialize_InitializedObject_StringNotEmpty() { string testval = "knisely%903%mcgee%890%schaub%789%bluff%678%dark%567%hess%456%deb%345%act%234%ben%123%watson%1%"; HighScores hiScore = new HighScores(new List <HiScore>()); hiScore.HiScores.Add(new HiScore("ben", 123)); hiScore.HiScores.Add(new HiScore("act", 234)); hiScore.HiScores.Add(new HiScore("deb", 345)); hiScore.HiScores.Add(new HiScore("hess", 456)); hiScore.HiScores.Add(new HiScore("dark", 567)); hiScore.HiScores.Add(new HiScore("bluff", 678)); hiScore.HiScores.Add(new HiScore("schaub", 789)); hiScore.HiScores.Add(new HiScore("mcgee", 890)); hiScore.HiScores.Add(new HiScore("knisely", 903)); hiScore.HiScores.Add(new HiScore("watson", 1)); hiScore.HiScores.Sort(HighScores.CompareHighScores); string serialized = hiScore.Serialize(); Assert.IsTrue(serialized.Equals(testval)); }
// Compares a HighScores instance to the current instance to see if their values match. Overrides object.Equals(). // Accepts an object reference (to cast as a HighScores object). // Returns true if the two instances' values are all equal. public override bool Equals(object obj) { HighScores newScore = obj as HighScores; if (newScore == null || newScore.hiScores.Count != hiScores.Count) { return(false); } else { for (int i = 0; i < 10; ++i) { if (!hiScores[i].Equals(newScore.hiScores[i])) { return(false); } } return(true); } }
public void Load_InputFile_ReturnsHighScoresObject() { string path = Path.Combine(Directory.GetCurrentDirectory(), "tests/HSLoad.txt"); HighScores hiScore = new HighScores(new List <HiScore>()); hiScore.HiScores.Add(new HiScore("ben", 123)); hiScore.HiScores.Add(new HiScore("act", 234)); hiScore.HiScores.Add(new HiScore("deb", 345)); hiScore.HiScores.Add(new HiScore("hess", 456)); hiScore.HiScores.Add(new HiScore("dark", 567)); hiScore.HiScores.Add(new HiScore("bluff", 678)); hiScore.HiScores.Add(new HiScore("schaub", 789)); hiScore.HiScores.Add(new HiScore("mcgee", 890)); hiScore.HiScores.Add(new HiScore("knisely", 903)); hiScore.HiScores.Add(new HiScore("watson", 1)); hiScore.HiScores.Sort(HighScores.CompareHighScores); HighScores score = HighScores.Load(path); Assert.IsTrue(score.Equals(hiScore)); }
public void AddNewScore_ValidInput_Adds() { Game myGame = new Game(false); HighScores hiScore = new HighScores(new List <HiScore>()); hiScore.HiScores.Add(new HiScore("ben", 123)); hiScore.HiScores.Add(new HiScore("act", 234)); hiScore.HiScores.Add(new HiScore("deb", 345)); hiScore.HiScores.Add(new HiScore("hess", 456)); hiScore.HiScores.Add(new HiScore("dark", 567)); hiScore.HiScores.Add(new HiScore("bluff", 678)); hiScore.HiScores.Add(new HiScore("schaub", 789)); hiScore.HiScores.Add(new HiScore("mcgee", 890)); hiScore.HiScores.Add(new HiScore("knisely", 903)); hiScore.HiScores.Add(new HiScore("watson", 1)); hiScore.HiScores.Sort(HighScores.CompareHighScores); myGame.Username = "******"; myGame.Points = 10; hiScore.AddNewScore(myGame.Username, myGame.Points); Assert.IsTrue(hiScore.HiScores[9].User == "Evisserate"); }
public void Deserialize_InputSerializedString_ReturnsHighScoresObject() { string serialized = "knisely%903%mcgee%890%schaub%789%bluff%678%dark%567%hess%456%deb%345%act%234%ben%123%watson%1%"; HighScores hiScore = new HighScores(new List <HiScore>()); hiScore.HiScores.Add(new HiScore("ben", 123)); hiScore.HiScores.Add(new HiScore("act", 234)); hiScore.HiScores.Add(new HiScore("deb", 345)); hiScore.HiScores.Add(new HiScore("hess", 456)); hiScore.HiScores.Add(new HiScore("dark", 567)); hiScore.HiScores.Add(new HiScore("bluff", 678)); hiScore.HiScores.Add(new HiScore("schaub", 789)); hiScore.HiScores.Add(new HiScore("mcgee", 890)); hiScore.HiScores.Add(new HiScore("knisely", 903)); hiScore.HiScores.Add(new HiScore("watson", 1)); hiScore.HiScores.Sort(HighScores.CompareHighScores); HighScores score = HighScores.Deserialize(serialized); Assert.IsTrue(score.Equals(hiScore)); }
public HighScorePage(Page parentPage) { ParentPage = parentPage; InitializeComponent(); hs = HighScores.Load(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "Saves/HighScoreSave.txt")); }
internal NetworkedGameOverPage(HighScores highScores, string name) { InitializeComponent(); hs = highScores; userName = name; }