예제 #1
0
        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)));
        }
예제 #2
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"));
        }
예제 #3
0
        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));
        }
예제 #4
0
        // 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);
            }
        }
예제 #5
0
        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));
        }
예제 #6
0
        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");
        }
예제 #7
0
        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));
        }
예제 #8
0
 public HighScorePage(Page parentPage)
 {
     ParentPage = parentPage;
     InitializeComponent();
     hs = HighScores.Load(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "Saves/HighScoreSave.txt"));
 }
예제 #9
0
 internal NetworkedGameOverPage(HighScores highScores, string name)
 {
     InitializeComponent();
     hs       = highScores;
     userName = name;
 }