Example #1
0
        public void GameInstantiatesWithPlayerStartingAt01()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 5, 5, 0, 1);

            Assert.AreEqual(0, gameToTest.Player.CurrentPosition.Horizontal);
            Assert.AreEqual(1, gameToTest.Player.CurrentPosition.Vertical);
        }
Example #2
0
        public void GameContinues()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 5, 3, 0, 1);
            var dummyEvent = new PlayerEvents
            {
                GameOver = false
            };

            gameToTest.HandlePlayerEvent(this, dummyEvent);

            Assert.AreEqual(false, gameToTest.GameOver);
        }
Example #3
0
        public void GameStopsOnGameOver()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 5, 3, 0, 1);
            var dummyEvent = new PlayerEvents
            {
                GameOver = true
            };

            gameToTest.HandlePlayerEvent(this, dummyEvent);

            Assert.AreEqual(true, gameToTest.GameOver);
        }
Example #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Minesweeper");
            Console.WriteLine("Use the arrow keys only to navigate and esc to quit");
            //Create the Game
            var theGame = GenerateGame.GenerateAGame(8, 8, 50, 3, 0, 1);

            Console.WriteLine("You are on " + theGame.Board.HorizontalArray.Length.ToString() + "x" +
                              theGame.Board.VerticalAxis.ToString() + " board starting from " +
                              theGame.Board.HorizontalArray[theGame.Player.CurrentPosition.Horizontal] +
                              theGame.Player.CurrentPosition.Vertical.ToString());

            Console.WriteLine("Good luck!");
            Console.WriteLine("Oh and there are " + theGame.Board.NumberOfMines.ToString() + " mines");


            while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
            {
                var input = Console.ReadKey();


                //Check for Game Over
                if (theGame.GameOver)
                {
                    Console.WriteLine("Game Over");
                    break;
                }

                if (input.Key == ConsoleKey.UpArrow || input.Key == ConsoleKey.DownArrow || input.Key == ConsoleKey.LeftArrow || input.Key == ConsoleKey.RightArrow)
                {
                    theGame.Player.ProcessKeyStroke(input.Key.ToString());
                }
                else if (input.Key == ConsoleKey.Escape)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Invalid key");
                }
            }
        }
Example #5
0
        public void GameInstantiatesWithAPlayer3Lives()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 5, 3, 0, 1);

            Assert.AreEqual(3, gameToTest.Player.NoOfLives);
        }
Example #6
0
        public void GameInstantiatesWith30Mines()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 30, 5, 0, 1);

            Assert.AreEqual(30, gameToTest.Board.NumberOfMines);
        }